index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search :typeList="typeOptions" @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table
  8. ref="table"
  9. :columns="columns"
  10. :datasource="datasource"
  11. :selection.sync="selection"
  12. row-key="id"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <el-button
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="openEdit()"
  22. >
  23. 新建
  24. </el-button>
  25. <el-button
  26. size="small"
  27. type="danger"
  28. icon="el-icon-delete"
  29. class="ele-btn-icon"
  30. @click="removeBatch"
  31. plain
  32. >
  33. 删除
  34. </el-button>
  35. <el-button
  36. size="small"
  37. type="primary"
  38. icon="el-icon-upload2"
  39. class="ele-btn-icon"
  40. plain
  41. >
  42. 导出
  43. </el-button>
  44. <el-button
  45. size="small"
  46. type="primary"
  47. icon="el-icon-download"
  48. class="ele-btn-icon"
  49. plain
  50. >
  51. 导入
  52. </el-button>
  53. </template>
  54. <!-- 操作列 -->
  55. <template v-slot:action="{ row }">
  56. <el-link
  57. type="primary"
  58. :underline="false"
  59. icon="el-icon-edit"
  60. @click="openEdit(row)"
  61. >
  62. 修改
  63. </el-link>
  64. <el-link
  65. type="primary"
  66. :underline="false"
  67. icon="el-icon-setting"
  68. @click="openEdit(row, true)"
  69. >
  70. 详情
  71. </el-link>
  72. <el-popconfirm
  73. class="ele-action"
  74. title="确定要删除当前工步吗?"
  75. @confirm="remove(row)"
  76. >
  77. <template v-slot:reference>
  78. <el-link type="danger" :underline="false" icon="el-icon-delete">
  79. 删除
  80. </el-link>
  81. </template>
  82. </el-popconfirm>
  83. </template>
  84. </ele-pro-table>
  85. </el-card>
  86. <!-- 编辑弹窗 -->
  87. <user-edit
  88. :visible.sync="showEdit"
  89. :data="current"
  90. :controlList="controlList"
  91. :isView="isView"
  92. @done="reload"
  93. ref="userEdit"
  94. :typeList="typeOptions"
  95. />
  96. </div>
  97. </template>
  98. <script>
  99. import UserSearch from './components/user-search.vue';
  100. import UserEdit from './components/user-edit.vue';
  101. import {
  102. getProfessionPageList,
  103. deleteProfessiongetById
  104. } from '@/api/factoryModel';
  105. import control from '@/api/technology/control';
  106. import dictMixins from '@/mixins/dictMixins';
  107. export default {
  108. name: 'technologyProduction',
  109. components: {
  110. UserSearch,
  111. UserEdit
  112. },
  113. mixins: [dictMixins],
  114. data() {
  115. return {
  116. levelOptions: [
  117. {
  118. label: '初级',
  119. value: '1'
  120. },
  121. {
  122. label: '中级',
  123. value: '2'
  124. },
  125. {
  126. label: '高级',
  127. value: '3'
  128. }
  129. ],
  130. isView: false,
  131. // 表格列配置
  132. columns: [
  133. {
  134. columnKey: 'selection',
  135. type: 'selection',
  136. width: 45,
  137. align: 'center',
  138. fixed: 'left'
  139. },
  140. {
  141. label: '序号',
  142. type: 'index',
  143. width: 55,
  144. align: 'center'
  145. },
  146. {
  147. slot: 'type',
  148. label: '类型',
  149. showOverflowTooltip: true,
  150. align: 'center',
  151. minWidth: 110,
  152. formatter: (_row) => {
  153. return this.getDictValue('工种', _row.type);
  154. }
  155. },
  156. {
  157. align: 'center',
  158. prop: 'code',
  159. label: '编码',
  160. showOverflowTooltip: true,
  161. minWidth: 110
  162. },
  163. {
  164. slot: 'name',
  165. prop: 'name',
  166. label: '名称',
  167. showOverflowTooltip: true,
  168. align: 'center',
  169. minWidth: 110
  170. },
  171. {
  172. slot: 'level',
  173. prop: 'level',
  174. label: '等级',
  175. showOverflowTooltip: true,
  176. align: 'center',
  177. minWidth: 110,
  178. formatter: (_row) => {
  179. return this.levelOptions.filter(
  180. (item) => _row.level == item.value
  181. )[0].label;
  182. }
  183. },
  184. {
  185. slot: 'hourCost',
  186. prop: 'hourCost',
  187. label: '标准工时费',
  188. showOverflowTooltip: true,
  189. align: 'center',
  190. minWidth: 110
  191. },
  192. {
  193. slot: 'aptitude',
  194. label: '资质',
  195. showOverflowTooltip: true,
  196. align: 'center',
  197. minWidth: 110,
  198. formatter: (_row) => {
  199. return this.getDictValue('工种', _row.aptitude);
  200. }
  201. },
  202. {
  203. columnKey: 'action',
  204. label: '操作',
  205. width: 260,
  206. align: 'center',
  207. resizable: false,
  208. slot: 'action',
  209. showOverflowTooltip: true
  210. }
  211. ],
  212. // 表格选中数据
  213. selection: [],
  214. // 当前编辑数据
  215. current: null,
  216. // 是否显示编辑弹窗
  217. showEdit: false,
  218. // 是否显示参数弹窗
  219. showSetting: false,
  220. controlList: [],
  221. sampleShow: false,
  222. taskId: null
  223. };
  224. },
  225. created() {
  226. this.requestDict('工种');
  227. },
  228. computed: {
  229. typeOptions() {
  230. return this.dict[this.dictEnum['工种']];
  231. }
  232. },
  233. methods: {
  234. /*配置工艺参数 */
  235. openSetting(row) {
  236. this.current = row;
  237. this.showSetting = true;
  238. },
  239. /* 表格数据源 */
  240. async datasource({ page, limit, where, order }) {
  241. const res = await getProfessionPageList({
  242. ...where,
  243. ...order,
  244. pageNum: page,
  245. size: limit
  246. });
  247. return res;
  248. },
  249. /* 刷新表格 */
  250. reload(where) {
  251. this.$refs.table.reload({ page: 1, where: where });
  252. },
  253. /* 打开编辑弹窗 */
  254. openEdit(row, isView) {
  255. this.isView = !!isView;
  256. this.getControlList();
  257. this.current = row;
  258. this.showEdit = true;
  259. this.$refs.userEdit.$refs.form &&
  260. this.$refs.userEdit.$refs.form.clearValidate();
  261. },
  262. getControlList() {
  263. const params = {
  264. pageNum: 1,
  265. size: -1
  266. };
  267. control.list().then((res) => {
  268. this.controlList = res.list;
  269. });
  270. },
  271. /* 删除 */
  272. remove(row) {
  273. const loading = this.$loading({ lock: true });
  274. deleteProfessiongetById([row.id])
  275. .then((msg) => {
  276. loading.close();
  277. this.$message.success('删除' + msg);
  278. this.reload();
  279. })
  280. .catch((e) => {
  281. loading.close();
  282. // this.$message.error(e.message);
  283. });
  284. },
  285. /* 批量删除 */
  286. removeBatch() {
  287. if (!this.selection.length) {
  288. this.$message.error('请至少选择一条数据');
  289. return;
  290. }
  291. this.$confirm('确定要删除选中的工种吗?', '提示', {
  292. type: 'warning'
  293. })
  294. .then(() => {
  295. const loading = this.$loading({ lock: true });
  296. deleteProfessiongetById(this.selection.map((d) => d.id))
  297. .then((msg) => {
  298. loading.close();
  299. this.$message.success('删除' + msg);
  300. this.reload();
  301. })
  302. .catch((e) => {
  303. loading.close();
  304. // this.$message.error(e.message);
  305. });
  306. })
  307. .catch(() => {});
  308. },
  309. sampleParam(row) {
  310. this.taskId = row.id;
  311. this.sampleShow = true;
  312. },
  313. close(done) {
  314. this.sampleShow = false;
  315. }
  316. }
  317. };
  318. </script>