index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" @selection-change="selectListChange"
  8. row-key="id">
  9. <!-- 状态列 -->
  10. <!-- 操作列 -->
  11. </ele-pro-table>
  12. </el-card>
  13. <!-- 编辑弹窗 -->
  14. <user-edit :visible.sync="showEdit" :data="current" @done="reload" ref="userEdit" />
  15. <!-- 配置工艺参数 -->
  16. <user-setting :visible.sync="showSetting" :data="current" ref="userSetting" />
  17. </div>
  18. </template>
  19. <script>
  20. import UserSearch from './components/user-search.vue';
  21. import UserEdit from './components/user-edit.vue';
  22. import UserSetting from './components/user-setting.vue';
  23. import producetask from '@/api/technology/production';
  24. export default {
  25. name: 'technologyProduction',
  26. components: {
  27. UserSearch,
  28. UserEdit,
  29. UserSetting
  30. },
  31. props: {
  32. tableData: {
  33. type: Array,
  34. default: () => []
  35. },
  36. isRadio: {
  37. type: Boolean,
  38. default: false
  39. }
  40. },
  41. data() {
  42. return {
  43. // 表格列配置
  44. columns: [
  45. {
  46. columnKey: 'selection',
  47. type: 'selection',
  48. width: 45,
  49. align: 'center',
  50. selectable: (row, index) => {
  51. return !this.tableData.some((it) => it.sourceTaskId == row.id);
  52. },
  53. reserveSelection: true,
  54. fixed: 'left'
  55. },
  56. {
  57. prop: 'code',
  58. label: '工序编码',
  59. // sortable: 'custom',
  60. showOverflowTooltip: true,
  61. align: 'center',
  62. minWidth: 110
  63. },
  64. {
  65. prop: 'name',
  66. label: '工序名称',
  67. showOverflowTooltip: true,
  68. align: 'center',
  69. minWidth: 110
  70. },
  71. {
  72. align: 'center',
  73. prop: 'controlName',
  74. label: '工序控制码',
  75. showOverflowTooltip: true,
  76. minWidth: 110
  77. },
  78. {
  79. prop: 'workCenterName',
  80. label: '所属工作中心',
  81. align: 'center',
  82. showOverflowTooltip: true,
  83. minWidth: 110
  84. }
  85. ],
  86. // 表格选中数据
  87. selection: [],
  88. // 当前编辑数据
  89. current: null,
  90. // 是否显示编辑弹窗
  91. showEdit: false,
  92. // 是否显示参数弹窗
  93. showSetting: false,
  94. rowData: []
  95. };
  96. },
  97. methods: {
  98. /*配置工艺参数 */
  99. openSetting(row) {
  100. this.current = row;
  101. this.showSetting = true;
  102. },
  103. /* 表格数据源 */
  104. async datasource({ page, limit, where, order }) {
  105. const res = await producetask.list({
  106. ...where,
  107. ...order,
  108. pageNum: page,
  109. isDetail: true,
  110. size: limit
  111. });
  112. return res;
  113. },
  114. /* 刷新表格 */
  115. reload(where) {
  116. this.$refs.table.reload({ page: 1, where: where });
  117. },
  118. /* 打开编辑弹窗 */
  119. openEdit(row) {
  120. this.current = row;
  121. this.showEdit = true;
  122. this.$refs.userEdit.$refs.form &&
  123. this.$refs.userEdit.$refs.form.clearValidate();
  124. },
  125. /* 删除 */
  126. remove(row) {
  127. const loading = this.$loading({ lock: true });
  128. producetask
  129. .delete([row.id])
  130. .then((msg) => {
  131. loading.close();
  132. this.$message.success('删除' + msg);
  133. this.reload();
  134. })
  135. .catch((e) => {
  136. loading.close();
  137. // this.$message.error(e.message);
  138. });
  139. },
  140. /* 批量删除 */
  141. removeBatch() {
  142. if (!this.selection.length) {
  143. this.$message.error('请至少选择一条数据');
  144. return;
  145. }
  146. this.$confirm('确定要删除选中的工序吗?', '提示', {
  147. type: 'warning'
  148. })
  149. .then(() => {
  150. const loading = this.$loading({ lock: true });
  151. producetask
  152. .delete(this.selection.map((d) => d.id))
  153. .then((msg) => {
  154. loading.close();
  155. this.$message.success('删除' + msg);
  156. this.reload();
  157. })
  158. .catch((e) => {
  159. loading.close();
  160. // this.$message.error(e.message);
  161. });
  162. })
  163. .catch(() => { });
  164. },
  165. // 表格某一行的单击事件
  166. selectListChange(selection) {
  167. if (this.isRadio) {
  168. if (Array.isArray(selection) && selection.length > 1) {//点击勾选框
  169. this.$refs.table.toggleRowSelection(selection[0], false);
  170. this.$refs.table.toggleRowSelection(selection[1], true);
  171. } else if (!Array.isArray(selection)) {//点击行
  172. this.$refs.table.toggleRowSelection(selection, false);
  173. this.$refs.table.toggleRowSelection(selection, true);
  174. } else {
  175. this.rowData = []
  176. this.rowData = Array.isArray(selection) ? selection[0] : selection;
  177. }
  178. } else {
  179. this.selection = selection
  180. }
  181. },
  182. getRowData() {
  183. return this.rowData
  184. },
  185. getSelection() {
  186. return this.selection
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. :deep(.el-checkbox__input.is-disabled) {
  193. .el-checkbox__inner {
  194. background-color: rgba(142, 128, 128, 0.584) !important;
  195. }
  196. }
  197. </style>