index.vue 7.6 KB

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