CardManage.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="card-manage">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <template v-if="checkPrivilege('condition', 'condition')">
  6. <el-form-item label="题卡名称:">
  7. <el-input
  8. v-model.trim="filter.name"
  9. placeholder="名称"
  10. clearable
  11. ></el-input>
  12. </el-form-item>
  13. <el-form-item label="创建方式:" label-width="90px">
  14. <el-select
  15. v-model="filter.createType"
  16. style="width: 120px;"
  17. placeholder="创建方式"
  18. clearable
  19. >
  20. <el-option
  21. v-for="(val, key) in CARD_CREATE_TYPE"
  22. :key="key"
  23. :value="key"
  24. :label="val"
  25. ></el-option>
  26. </el-select>
  27. </el-form-item>
  28. </template>
  29. <el-form-item>
  30. <el-button
  31. v-if="checkPrivilege('button', 'select')"
  32. type="primary"
  33. @click="toPage(1)"
  34. >查询</el-button
  35. >
  36. </el-form-item>
  37. </el-form>
  38. <div class="part-box-action">
  39. <el-button
  40. v-if="checkPrivilege('button', 'add')"
  41. type="primary"
  42. icon="el-icon-circle-plus-outline"
  43. @click="toAdd"
  44. >添加题卡</el-button
  45. >
  46. </div>
  47. </div>
  48. <div class="part-box part-box-pad">
  49. <el-table ref="TableList" :data="cardList">
  50. <el-table-column
  51. type="index"
  52. label="序号"
  53. width="70"
  54. :index="indexMethod"
  55. ></el-table-column>
  56. <el-table-column prop="name" label="题卡名称"></el-table-column>
  57. <el-table-column prop="type" label="类型"></el-table-column>
  58. <el-table-column prop="orgs" label="适用学院">
  59. <template slot-scope="scope">
  60. <more-text :data="scope.row.orgNames"></more-text>
  61. </template>
  62. </el-table-column>
  63. <el-table-column prop="createType" label="创建方式"></el-table-column>
  64. <el-table-column prop="remark" label="备注">
  65. <span slot-scope="scope">{{
  66. scope.row.remark | defaultFieldFilter
  67. }}</span>
  68. </el-table-column>
  69. <el-table-column prop="createTime" label="创建时间" width="180">
  70. <span slot-scope="scope">{{
  71. scope.row.createTime | timestampFilter
  72. }}</span>
  73. </el-table-column>
  74. <el-table-column class-name="action-column" label="操作" width="140">
  75. <template slot-scope="scope">
  76. <el-button
  77. v-if="checkPrivilege('link', 'preview')"
  78. class="btn-primary"
  79. type="text"
  80. @click="toPreview(scope.row)"
  81. >查看</el-button
  82. >
  83. <el-button
  84. v-if="
  85. checkPrivilege('link', 'edit') &&
  86. scope.row.createType !== 'UPLOAD'
  87. "
  88. class="btn-primary"
  89. type="text"
  90. @click="toEditCard(scope.row)"
  91. >编辑题卡</el-button
  92. >
  93. <el-button
  94. v-if="checkPrivilege('link', 'edit')"
  95. class="btn-primary"
  96. type="text"
  97. @click="toEditInfo(scope.row)"
  98. >编辑信息</el-button
  99. >
  100. <el-button
  101. v-if="checkPrivilege('link', 'delete')"
  102. class="btn-danger"
  103. type="text"
  104. @click="toDelete(scope.row)"
  105. >删除</el-button
  106. >
  107. </template>
  108. </el-table-column>
  109. </el-table>
  110. <div class="part-page">
  111. <el-pagination
  112. background
  113. layout="total,prev, pager, next"
  114. :current-page="current"
  115. :total="total"
  116. :page-size="size"
  117. @current-change="toPage"
  118. >
  119. </el-pagination>
  120. </div>
  121. </div>
  122. <!-- ModifyCardInfo -->
  123. <modify-card-info
  124. ref="ModifyCardInfo"
  125. :instance="curCard"
  126. @modified="getList"
  127. ></modify-card-info>
  128. </div>
  129. </template>
  130. <script>
  131. import { CARD_CREATE_TYPE } from "../../../constants/enumerate";
  132. import { cardListPage, deleteCard } from "../api";
  133. import ModifyCardInfo from "../components/ModifyCardInfo";
  134. export default {
  135. name: "card-manage",
  136. components: { ModifyCardInfo },
  137. data() {
  138. return {
  139. filter: {
  140. name: "",
  141. createType: ""
  142. },
  143. current: 1,
  144. size: this.GLOBAL.pageSize,
  145. total: 0,
  146. CARD_CREATE_TYPE,
  147. cardList: [
  148. {
  149. id: "11",
  150. name: "标准题卡001",
  151. type: "",
  152. orgs: [],
  153. orgNames: ["一中"],
  154. createType: "STANDARD",
  155. remark: "",
  156. createTime: "152145785632145"
  157. }
  158. ],
  159. curCard: {}
  160. };
  161. },
  162. methods: {
  163. async getList() {
  164. if (!this.checkPrivilege("list", "list")) return;
  165. const datas = {
  166. ...this.filter,
  167. pageNumber: this.current,
  168. pageSize: this.size
  169. };
  170. const data = await cardListPage(datas);
  171. this.cardList = data.records;
  172. this.total = data.total;
  173. },
  174. toPage(page) {
  175. this.current = page;
  176. this.getList();
  177. },
  178. toAdd() {
  179. this.curCard = {};
  180. this.$refs.ModifyCardInfo.open();
  181. },
  182. toPreview(row) {
  183. this.curCard = row;
  184. this.$router.push({
  185. name: row.createType === "STANDARD" ? "CardPreview" : "CardFreePreview",
  186. params: {
  187. cardId: row.id,
  188. viewType: "view"
  189. }
  190. });
  191. },
  192. toEditCard(row) {
  193. this.curCard = row;
  194. this.$router.push({
  195. name: row.createType === "STANDARD" ? "CardEdit" : "CardFreeEdit",
  196. params: {
  197. cardId: row.id
  198. }
  199. });
  200. },
  201. toEditInfo(row) {
  202. this.curCard = row;
  203. this.$refs.ModifyCardInfo.open();
  204. },
  205. toDelete(row) {
  206. this.$confirm(`确定要删除题卡【${row.name}】吗?`, "提示", {
  207. type: "warning"
  208. })
  209. .then(async () => {
  210. await deleteCard(row.id);
  211. this.$message.success("删除成功!");
  212. this.deletePageLastItem();
  213. })
  214. .catch(() => {});
  215. }
  216. }
  217. };
  218. </script>