index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search
  6. @search="reload"
  7. :flist="fList"
  8. :categoryTypes="categoryTypes"
  9. />
  10. <!-- 数据表格 -->
  11. <ele-pro-table
  12. ref="table"
  13. :columns="columns"
  14. :datasource="datasource"
  15. :selection.sync="selection"
  16. v-loading="loading"
  17. row-key="code"
  18. >
  19. <!-- 表头工具栏 -->
  20. <template v-slot:toolbar>
  21. <el-button
  22. size="small"
  23. type="primary"
  24. icon="el-icon-plus"
  25. class="ele-btn-icon"
  26. @click="openEdit()"
  27. >
  28. 新建
  29. </el-button>
  30. </template>
  31. <template v-slot:factoryId="{ row }">
  32. {{ checkfactoryId(row.factoryId) }}
  33. </template>
  34. <template v-slot:categoryType="{ row }">
  35. {{ checkcategoryType(row.categoryType) }}
  36. </template>
  37. <!-- <template v-slot:leaderUserId="{ row }">
  38. {{ checkleaderUserId(row.leaderUserId) }}
  39. </template> -->
  40. <!-- 状态列 -->
  41. <!-- 操作列 -->
  42. <template v-slot:action="{ row }">
  43. <el-link
  44. type="primary"
  45. :underline="false"
  46. icon="el-icon-edit"
  47. @click="openEdit(row)"
  48. >
  49. 修改
  50. </el-link>
  51. <el-popconfirm
  52. class="ele-action"
  53. title="确定要删除当前工序吗?"
  54. @confirm="remove(row)"
  55. >
  56. <template v-slot:reference>
  57. <el-link type="danger" :underline="false" icon="el-icon-delete">
  58. 删除
  59. </el-link>
  60. </template>
  61. </el-popconfirm>
  62. </template>
  63. </ele-pro-table>
  64. </el-card>
  65. <!-- 编辑弹窗 -->
  66. <user-edit
  67. :visible.sync="showEdit"
  68. :flist="fList"
  69. :data="current"
  70. :userList="userList"
  71. :categoryTypes="categoryTypes"
  72. @done="reload"
  73. ref="userEdit"
  74. />
  75. <!-- 导入弹窗 -->
  76. </div>
  77. </template>
  78. <script>
  79. import UserSearch from './components/user-search.vue';
  80. import UserEdit from './components/user-edit.vue';
  81. import work from '@/api/technology/work';
  82. import route from '@/api/technology/route';
  83. export default {
  84. name: 'technologyWork',
  85. components: {
  86. UserSearch,
  87. UserEdit
  88. },
  89. data () {
  90. return {
  91. // 表格列配置
  92. columns: [
  93. {
  94. prop: 'factoryId',
  95. label: '所属工厂',
  96. slot: 'factoryId',
  97. showOverflowTooltip: true,
  98. align: 'center',
  99. minWidth: 110
  100. },
  101. {
  102. prop: 'code',
  103. label: '工作中心编码',
  104. showOverflowTooltip: true,
  105. align: 'center',
  106. minWidth: 110
  107. },
  108. {
  109. prop: 'name',
  110. label: '工作中心名称',
  111. showOverflowTooltip: true,
  112. align: 'center',
  113. minWidth: 110
  114. },
  115. {
  116. prop: 'categoryType',
  117. label: '工作中心类别',
  118. slot: 'categoryType',
  119. showOverflowTooltip: true,
  120. align: 'center'
  121. },
  122. {
  123. prop: 'leaderUserName',
  124. label: '负责人',
  125. // slot: 'leaderUserId',
  126. showOverflowTooltip: true,
  127. align: 'center'
  128. },
  129. {
  130. columnKey: 'action',
  131. label: '操作',
  132. width: 220,
  133. align: 'center',
  134. resizable: false,
  135. slot: 'action',
  136. showOverflowTooltip: true
  137. }
  138. ],
  139. categoryTypes: [
  140. { label: '设备', value: 0 },
  141. { label: '设备组', value: 1 },
  142. { label: '人工', value: 2 },
  143. { label: '人工组', value: 3 },
  144. { label: '生产线', value: 4 },
  145. { label: '委外生产', value: 5 }
  146. ],
  147. // 厂房列表
  148. fList: [],
  149. // 人员列表
  150. userList: [],
  151. // 表格选中数据
  152. selection: [],
  153. // 当前编辑数据
  154. current: null,
  155. // 是否显示编辑弹窗
  156. showEdit: false,
  157. // 是否显示导入弹窗
  158. showImport: false,
  159. loading: false
  160. };
  161. },
  162. created () {
  163. this.getfLise();
  164. this.getUserPage();
  165. },
  166. methods: {
  167. /*回显工厂 */
  168. checkfactoryId (id) {
  169. let obj = this.fList.find((f) => f.id == id);
  170. return obj?.name;
  171. },
  172. /*回显类别 */
  173. checkcategoryType (value) {
  174. return this.categoryTypes.find((f) => f.value == value).label;
  175. },
  176. /*回显负责人 */
  177. checkleaderUserId (id) {
  178. let obj = this.userList.find((f) => f.id == id);
  179. return obj?.name;
  180. },
  181. /*人员列表 */
  182. async getUserPage () {
  183. const res = await work.getUserPage();
  184. this.userList = res.list;
  185. },
  186. /*厂房列表 */
  187. async getfLise () {
  188. const res = await route.Flist({
  189. pageNum: 1,
  190. size: -1,
  191. type: 1
  192. });
  193. this.fList = res.list;
  194. },
  195. /* 表格数据源 */
  196. async datasource ({ page, limit, where, order }) {
  197. const res = await work.list({
  198. ...where,
  199. ...order,
  200. pageNum: page,
  201. size: limit
  202. });
  203. return res;
  204. },
  205. /* 刷新表格 */
  206. reload (where) {
  207. this.$refs.table.reload({ page: 1, where: where });
  208. },
  209. /* 打开编辑弹窗 */
  210. openEdit (row) {
  211. this.current = row;
  212. this.showEdit = true;
  213. this.$refs.userEdit.$refs.form &&
  214. this.$refs.userEdit.$refs.form.clearValidate();
  215. },
  216. /* 打开导入弹窗 */
  217. openImport () {
  218. this.showImport = true;
  219. },
  220. /* 删除 */
  221. remove (row) {
  222. // const loading = this.$loading({ lock: true });
  223. this.loading = true;
  224. work
  225. .delete([row.id])
  226. .then((msg) => {
  227. // loading.close();
  228. this.loading = false;
  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. }
  263. };
  264. </script>