CardRule.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="card-rule">
  3. <div class="part-box part-box-filter part-box-flex">
  4. <el-form ref="FilterForm" label-position="left" label-width="85px" inline>
  5. <el-form-item label="规则名称:">
  6. <el-input
  7. style="width: 200px;"
  8. v-model.trim="filter.name"
  9. placeholder="请输入内容"
  10. clearable
  11. ></el-input>
  12. </el-form-item>
  13. <el-form-item label="创建时间:">
  14. <el-date-picker
  15. v-model="filter.createTime"
  16. type="date"
  17. value-format="timestamp"
  18. placeholder="选择日期时间"
  19. >
  20. </el-date-picker>
  21. </el-form-item>
  22. <el-form-item label="启用/禁用:" label-width="90px">
  23. <el-select
  24. v-model="filter.enable"
  25. style="width: 100px;"
  26. placeholder="请选择"
  27. clearable
  28. >
  29. <el-option
  30. v-for="(val, key) in ABLE_TYPE"
  31. :key="key"
  32. :value="key"
  33. :label="val"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="primary" icon="icon icon-search" @click="toPage(1)"
  39. >查询</el-button
  40. >
  41. </el-form-item>
  42. </el-form>
  43. <div class="part-box-action">
  44. <el-button type="warning" icon="icon icon-plus" @click="toAdd"
  45. >添加</el-button
  46. >
  47. </div>
  48. </div>
  49. <div class="part-box">
  50. <el-table ref="TableList" :data="rules" border stripe>
  51. <el-table-column
  52. type="index"
  53. label="序号"
  54. width="70"
  55. align="center"
  56. :index="indexMethod"
  57. ></el-table-column>
  58. <el-table-column prop="name" label="题卡规则名称"></el-table-column>
  59. <el-table-column prop="orgs" label="适用学院">
  60. <template slot-scope="scope">
  61. {{ scope.row.orgs | orgsFilter }}
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="remark" label="备注"></el-table-column>
  65. <el-table-column prop="enable" label="启用/禁用">
  66. <template slot-scope="scope">
  67. {{ scope.row.enable | enableFilter }}
  68. </template>
  69. </el-table-column>
  70. <el-table-column prop="createTime" label="创建时间">
  71. <span slot-scope="scope">{{
  72. scope.row.createTime | timestampFilter
  73. }}</span>
  74. </el-table-column>
  75. <el-table-column
  76. class-name="action-column"
  77. label="操作"
  78. align="center"
  79. width="120px"
  80. >
  81. <template slot-scope="scope">
  82. <el-button
  83. class="btn-table-icon"
  84. type="text"
  85. icon="icon icon-edit"
  86. @click="toEdit(scope.row)"
  87. title="编辑"
  88. ></el-button>
  89. <el-button
  90. class="btn-table-icon"
  91. type="text"
  92. icon="icon icon-circle-right"
  93. @click="toDetail(scope.row)"
  94. title="查看"
  95. ></el-button>
  96. <el-button
  97. class="btn-table-icon"
  98. type="text"
  99. :icon="
  100. scope.row.enable
  101. ? 'icon icon-circle-stop'
  102. : 'icon icon-circle-caret-right'
  103. "
  104. @click="toEnable(scope.row)"
  105. :title="scope.row.enable ? '禁用' : '启用'"
  106. ></el-button>
  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. <!-- ModifyCardRule -->
  123. <modify-card-rule
  124. ref="ModifyCardRule"
  125. :instance="curRule"
  126. :editable="ruleCanEdit"
  127. @modified="getList"
  128. ></modify-card-rule>
  129. </div>
  130. </template>
  131. <script>
  132. import { ABLE_TYPE } from "@/constants/enumerate";
  133. import { commonRuleDetail, cardRuleListPage, ableCardRule } from "../api";
  134. import ModifyCardRule from "../components/ModifyCardRule";
  135. export default {
  136. name: "card-rule",
  137. components: {
  138. ModifyCardRule
  139. },
  140. data() {
  141. return {
  142. filter: {
  143. enable: null,
  144. name: "",
  145. createTime: null
  146. },
  147. current: 1,
  148. size: this.GLOBAL.pageSize,
  149. total: 0,
  150. rules: [],
  151. curRule: {},
  152. ruleCanEdit: true,
  153. commonRule: {},
  154. ABLE_TYPE
  155. };
  156. },
  157. created() {
  158. this.getList();
  159. this.getCommonRuleDetail();
  160. },
  161. methods: {
  162. async getCommonRuleDetail() {
  163. this.commonRule = await commonRuleDetail();
  164. },
  165. async getList() {
  166. const datas = {
  167. ...this.filter,
  168. pageNumber: this.current,
  169. pageSize: this.size
  170. };
  171. datas.enable = !!datas.enable;
  172. const data = await cardRuleListPage(datas);
  173. this.rules = data.records;
  174. this.total = data.total;
  175. },
  176. toPage(page) {
  177. this.current = page;
  178. this.getList();
  179. },
  180. toAdd() {
  181. this.curRule = {
  182. requiredFields: this.commonRule.requiredFields.filter(
  183. item => item.enable
  184. ),
  185. extendFields: this.commonRule.extendFields
  186. .filter(item => item.enable)
  187. .map(item => {
  188. item.enable = false;
  189. return item;
  190. })
  191. };
  192. this.ruleCanEdit = true;
  193. this.$refs.ModifyCardRule.open();
  194. },
  195. toEdit(row) {
  196. this.curRule = row;
  197. this.ruleCanEdit = true;
  198. this.$refs.ModifyCardRule.open();
  199. },
  200. toDetail(row) {
  201. this.curRule = row;
  202. this.ruleCanEdit = false;
  203. this.$refs.ModifyCardRule.open();
  204. },
  205. async toEnable(row) {
  206. const enable = !row.enable;
  207. await ableCardRule({
  208. id: row.id,
  209. enable
  210. });
  211. row.enable = enable;
  212. }
  213. }
  214. };
  215. </script>