index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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.sync="selection" row-key="id">
  8. <!-- 表头工具栏 -->
  9. <template v-slot:toolbar>
  10. <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit()">
  11. 新建
  12. </el-button>
  13. <el-button size="small" type="danger" icon="el-icon-delete" class="ele-btn-icon" @click="removeBatch">
  14. 删除
  15. </el-button>
  16. </template>
  17. <template v-slot:name="{ row }">
  18. <el-link v-if="row.type == 2" type="primary" :underline="false" @click="sampleParam(row)">
  19. {{ row.name }}
  20. </el-link>
  21. <span v-else> {{ row.name }}</span>
  22. </template>
  23. <!-- 状态列 -->
  24. <template v-slot:type="{ row }">
  25. {{ typeLabel(row.type) }}
  26. </template>
  27. <!-- 操作列 -->
  28. <template v-slot:action="{ row }">
  29. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row)">
  30. 修改
  31. </el-link>
  32. <el-link type="primary" :underline="false" icon="el-icon-setting" @click="openSetting(row)">
  33. 配置工艺参数
  34. </el-link>
  35. <el-popconfirm class="ele-action" title="确定要删除当前工序吗?" @confirm="remove(row)">
  36. <template v-slot:reference>
  37. <el-link type="danger" :underline="false" icon="el-icon-delete">
  38. 删除
  39. </el-link>
  40. </template>
  41. </el-popconfirm>
  42. </template>
  43. </ele-pro-table>
  44. </el-card>
  45. <!-- 编辑弹窗 -->
  46. <user-edit :visible.sync="showEdit" :data="current" :controlList="controlList" @done="reload" ref="userEdit"
  47. :typeList="typeList" />
  48. <!-- 配置工艺参数 -->
  49. <user-setting :visible.sync="showSetting" :data="current" ref="userSetting" />
  50. <SampleParam v-if="sampleShow" :taskId="taskId" @close="close"></SampleParam>
  51. </div>
  52. </template>
  53. <script>
  54. import UserSearch from './components/user-search.vue';
  55. import UserEdit from './components/user-edit.vue';
  56. import UserSetting from './components/user-setting.vue';
  57. import SampleParam from './components/sampleParam.vue'
  58. import producetask from '@/api/technology/production';
  59. import control from '@/api/technology/control';
  60. export default {
  61. name: 'technologyProduction',
  62. components: {
  63. UserSearch,
  64. UserEdit,
  65. UserSetting,
  66. SampleParam
  67. },
  68. data() {
  69. return {
  70. // 表格列配置
  71. columns: [
  72. {
  73. columnKey: 'selection',
  74. type: 'selection',
  75. width: 45,
  76. align: 'center',
  77. fixed: 'left'
  78. },
  79. {
  80. prop: 'code',
  81. label: '工序编码',
  82. // sortable: 'custom',
  83. showOverflowTooltip: true,
  84. align: 'center',
  85. minWidth: 110
  86. },
  87. {
  88. slot: 'name',
  89. label: '工序名称',
  90. showOverflowTooltip: true,
  91. align: 'center',
  92. minWidth: 110
  93. },
  94. {
  95. slot: 'type',
  96. label: '工序类型',
  97. showOverflowTooltip: true,
  98. align: 'center',
  99. minWidth: 110
  100. },
  101. {
  102. align: 'center',
  103. prop: 'controlName',
  104. label: '工序控制码',
  105. showOverflowTooltip: true,
  106. minWidth: 110
  107. },
  108. {
  109. prop: 'workCenterName',
  110. label: '所属工作中心',
  111. align: 'center',
  112. showOverflowTooltip: true,
  113. minWidth: 110
  114. },
  115. {
  116. prop: 'sort',
  117. label: '排序',
  118. align: 'center',
  119. },
  120. {
  121. columnKey: 'action',
  122. label: '操作',
  123. width: 260,
  124. align: 'center',
  125. resizable: false,
  126. slot: 'action',
  127. showOverflowTooltip: true
  128. }
  129. ],
  130. // 表格选中数据
  131. selection: [],
  132. // 当前编辑数据
  133. current: null,
  134. // 是否显示编辑弹窗
  135. showEdit: false,
  136. // 是否显示参数弹窗
  137. showSetting: false,
  138. controlList: [],
  139. typeList: [
  140. {
  141. value: 1,
  142. label: '普通工序'
  143. },
  144. {
  145. value: 2,
  146. label: '抽样质检'
  147. }, {
  148. value: 3,
  149. label: '普通质检'
  150. }, {
  151. value: 4,
  152. label: '包装工序'
  153. },
  154. {
  155. value: 6,
  156. label: '常规质检'
  157. },
  158. ],
  159. sampleShow: false,
  160. taskId: null
  161. };
  162. },
  163. methods: {
  164. typeLabel(type) {
  165. return this.typeList.find(m => m.value == type) && this.typeList.find(m => m.value == type).label
  166. },
  167. /*配置工艺参数 */
  168. openSetting(row) {
  169. this.current = row;
  170. this.showSetting = true;
  171. },
  172. /* 表格数据源 */
  173. async datasource({ page, limit, where, order }) {
  174. const res = await producetask.list({
  175. ...where,
  176. ...order,
  177. pageNum: page,
  178. size: limit
  179. });
  180. return res;
  181. },
  182. /* 刷新表格 */
  183. reload(where) {
  184. this.$refs.table.reload({ page: 1, where: where });
  185. },
  186. /* 打开编辑弹窗 */
  187. openEdit(row) {
  188. this.getControlList()
  189. this.current = row;
  190. this.showEdit = true;
  191. this.$refs.userEdit.$refs.form &&
  192. this.$refs.userEdit.$refs.form.clearValidate();
  193. },
  194. getControlList() {
  195. const params = {
  196. pageNum: 1, size: -1
  197. }
  198. control.list().then(res => {
  199. this.controlList = res.list
  200. })
  201. },
  202. /* 删除 */
  203. remove(row) {
  204. const loading = this.$loading({ lock: true });
  205. producetask
  206. .delete([row.id])
  207. .then((msg) => {
  208. loading.close();
  209. this.$message.success('删除' + msg);
  210. this.reload();
  211. })
  212. .catch((e) => {
  213. loading.close();
  214. // this.$message.error(e.message);
  215. });
  216. },
  217. /* 批量删除 */
  218. removeBatch() {
  219. if (!this.selection.length) {
  220. this.$message.error('请至少选择一条数据');
  221. return;
  222. }
  223. this.$confirm('确定要删除选中的工序吗?', '提示', {
  224. type: 'warning'
  225. })
  226. .then(() => {
  227. const loading = this.$loading({ lock: true });
  228. producetask
  229. .delete(this.selection.map((d) => d.id))
  230. .then((msg) => {
  231. loading.close();
  232. this.$message.success('删除' + msg);
  233. this.reload();
  234. })
  235. .catch((e) => {
  236. loading.close();
  237. // this.$message.error(e.message);
  238. });
  239. })
  240. .catch(() => { });
  241. },
  242. sampleParam(row) {
  243. this.taskId = row.id
  244. this.sampleShow = true
  245. },
  246. close(done) {
  247. this.sampleShow = false
  248. }
  249. }
  250. };
  251. </script>