index.vue 6.3 KB

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