index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <PatrolSearch @search="reload" ruleType="0"> </PatrolSearch>
  5. <ele-pro-table
  6. ref="tableRef"
  7. row-key="id"
  8. :columns="columns"
  9. :datasource="datasource"
  10. :cache-key="cacheKeyUrl"
  11. autoAmendPage
  12. >
  13. <template v-slot:toolbar>
  14. <el-button
  15. type="primary"
  16. size="mini"
  17. icon="el-icon-plus"
  18. @click="openEdit('add')"
  19. >新建</el-button
  20. >
  21. </template>
  22. <template v-slot:code="{ row }">
  23. <el-link
  24. type="primary"
  25. :underline="false"
  26. @click="openEdit('detail', row)"
  27. >{{ row.code }}
  28. </el-link>
  29. </template>
  30. <template v-slot:action="{ row }">
  31. <el-link
  32. type="primary"
  33. :underline="false"
  34. icon="el-icon-edit"
  35. @click="openEdit('edit', row)"
  36. >
  37. 修改
  38. </el-link>
  39. <el-popconfirm
  40. class="ele-action"
  41. title="确定要删除此条数据吗?"
  42. @confirm="deleteRow(row)"
  43. >
  44. <template v-slot:reference>
  45. <el-link type="danger" :underline="false" icon="el-icon-delete">
  46. 删除
  47. </el-link>
  48. </template>
  49. </el-popconfirm>
  50. </template>
  51. </ele-pro-table>
  52. </el-card>
  53. <programRulesDialog
  54. ref="programRulesDialogRef"
  55. @reload="reload"
  56. ></programRulesDialog>
  57. </div>
  58. </template>
  59. <script>
  60. import dictMixins from '@/mixins/dictMixins';
  61. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  62. import {
  63. recordrulesPlanConfigPage,
  64. recordrulesPlanConfigDelete
  65. } from '@/api/recordrules/index';
  66. import PatrolSearch from './components/patrol-search.vue';
  67. import programRulesDialog from './components/programRulesDialog.vue';
  68. export default {
  69. mixins: [dictMixins, tableColumnsMixin],
  70. components: {
  71. PatrolSearch,
  72. programRulesDialog
  73. },
  74. data() {
  75. return {
  76. columns: [
  77. {
  78. columnKey: 'index',
  79. label: '序号',
  80. type: 'index',
  81. width: 55,
  82. align: 'center',
  83. showOverflowTooltip: true,
  84. fixed: 'left'
  85. },
  86. {
  87. prop: 'code',
  88. label: '计划配置单号',
  89. align: 'center',
  90. minWidth: 130,
  91. slot: 'code'
  92. },
  93. {
  94. prop: 'name',
  95. label: '计划配置名称',
  96. align: 'center',
  97. showOverflowTooltip: true,
  98. minWidth: 110
  99. },
  100. {
  101. prop: 'ruleName',
  102. label: '记录规则名称',
  103. align: 'center',
  104. showOverflowTooltip: true,
  105. minWidth: 110,
  106. formatter: (row) => {
  107. return row.list.map((i) => i.ruleName).join(',');
  108. }
  109. },
  110. {
  111. prop: '',
  112. label: '记录部门',
  113. align: 'center',
  114. showOverflowTooltip: true,
  115. minWidth: 110,
  116. formatter: (row) => {
  117. if (row.type == 0) {
  118. return row.executeUsers.map((i) => i.groupName).join(',');
  119. }
  120. return '';
  121. }
  122. },
  123. {
  124. prop: '',
  125. label: '负责人',
  126. align: 'center',
  127. showOverflowTooltip: true,
  128. minWidth: 110,
  129. formatter: (row) => {
  130. if (row.type == 0) {
  131. return row.executeUsers.map((i) => i.userName).join(',');
  132. }
  133. return '';
  134. }
  135. },
  136. {
  137. prop: 'executeUsers',
  138. label: '班组',
  139. align: 'center',
  140. showOverflowTooltip: true,
  141. minWidth: 110,
  142. formatter: (row) => {
  143. if (row.type == 1) {
  144. return row.executeUsers.map((i) => i.teamName).join(',');
  145. }
  146. return '';
  147. }
  148. },
  149. {
  150. prop: '',
  151. label: '记录对象',
  152. align: 'center',
  153. showOverflowTooltip: true,
  154. minWidth: 110,
  155. formatter: (row) => {
  156. return row.list
  157. .map((i) => i.workshops.map((i) => i.workshopName))
  158. .flat()
  159. .join(',');
  160. }
  161. },
  162. {
  163. prop: 'autoOrder',
  164. label: '自动派单',
  165. align: 'center',
  166. showOverflowTooltip: true,
  167. minWidth: 110,
  168. formatter: (row) => {
  169. return row.autoOrder ? '是' : '否';
  170. }
  171. },
  172. {
  173. prop: 'status',
  174. label: '状态',
  175. align: 'center',
  176. showOverflowTooltip: true,
  177. minWidth: 110,
  178. formatter: (row) => {
  179. return row.status ? '开启' : '关闭';
  180. }
  181. },
  182. {
  183. prop: 'createUserName',
  184. label: '创建人',
  185. align: 'center',
  186. showOverflowTooltip: true,
  187. minWidth: 110
  188. },
  189. {
  190. prop: 'createTime',
  191. label: '创建时间',
  192. align: 'center',
  193. showOverflowTooltip: true,
  194. minWidth: 110
  195. },
  196. {
  197. columnKey: 'action',
  198. label: '操作',
  199. width: 220,
  200. align: 'center',
  201. resizable: false,
  202. fixed: 'right',
  203. slot: 'action',
  204. showOverflowTooltip: true
  205. }
  206. ],
  207. cacheKeyUrl: 'mes-211191938-record-plan-index'
  208. };
  209. },
  210. computed: {},
  211. methods: {
  212. // 刷新表格
  213. reload(where = {}) {
  214. this.$refs.tableRef.reload({
  215. where
  216. });
  217. },
  218. /* 表格数据源 */
  219. datasource({ page, limit, where, order }) {
  220. // 参数
  221. const body = {
  222. ...where,
  223. ...order,
  224. pageNum: page,
  225. size: limit
  226. };
  227. return this.getList(body);
  228. },
  229. async getList(body) {
  230. const data = await recordrulesPlanConfigPage(body);
  231. data.list = data.list.map((item) => {
  232. // children 改名
  233. item.list = item.children;
  234. delete item.children;
  235. return item;
  236. });
  237. return data;
  238. },
  239. search(where) {
  240. this.reload(where);
  241. },
  242. openEdit(type, data) {
  243. console.log(type);
  244. this.$refs.programRulesDialogRef.open(type, data);
  245. },
  246. async deleteRow(row) {
  247. await recordrulesPlanConfigDelete([row.id]);
  248. this.$message.success('删除成功');
  249. this.reload();
  250. }
  251. }
  252. };
  253. </script>
  254. <style></style>