index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. :pageSize="this.$store.state.tablePageSize"
  19. @columns-change="handleColumnChange"
  20. :cache-key="cacheKeyUrl"
  21. >
  22. <!-- 表头工具栏 -->
  23. <template v-slot:toolbar>
  24. <el-button
  25. size="small"
  26. type="primary"
  27. icon="el-icon-plus"
  28. class="ele-btn-icon"
  29. @click="openEdit()"
  30. v-if="$hasPermission('main:workcenter:save')"
  31. >
  32. 新建
  33. </el-button>
  34. </template>
  35. <template v-slot:factoryId="{ row }">
  36. {{ checkfactoryId(row.factoryId) }}
  37. </template>
  38. <template v-slot:categoryType="{ row }">
  39. {{ checkcategoryType(row.categoryType) }}
  40. </template>
  41. <!-- <template v-slot:leaderUserId="{ row }">
  42. {{ checkleaderUserId(row.leaderUserId) }}
  43. </template> -->
  44. <!-- 状态列 -->
  45. <!-- 操作列 -->
  46. <template v-slot:action="{ row }">
  47. <el-link
  48. type="primary"
  49. :underline="false"
  50. icon="el-icon-edit"
  51. @click="openEdit(row,'copy')"
  52. v-if="$hasPermission('main:workcenter:save')"
  53. >
  54. 复制
  55. </el-link>
  56. <el-link
  57. type="primary"
  58. :underline="false"
  59. icon="el-icon-edit"
  60. @click="openEdit(row,'edit')"
  61. v-if="$hasPermission('main:workcenter:update')"
  62. >
  63. 修改
  64. </el-link>
  65. <el-popconfirm
  66. class="ele-action"
  67. title="确定要删除当前工序吗?"
  68. @confirm="remove(row)"
  69. v-if="$hasPermission('main:workcenter:delete')"
  70. >
  71. <template v-slot:reference>
  72. <el-link type="danger" :underline="false" icon="el-icon-delete">
  73. 删除
  74. </el-link>
  75. </template>
  76. </el-popconfirm>
  77. </template>
  78. </ele-pro-table>
  79. </el-card>
  80. <!-- 编辑弹窗 -->
  81. <user-edit
  82. :visible.sync="showEdit"
  83. :flist="fList"
  84. :data="current"
  85. :userList="userList"
  86. :categoryTypes="categoryTypes"
  87. @done="reload"
  88. ref="userEdit"
  89. />
  90. <!-- 导入弹窗 -->
  91. </div>
  92. </template>
  93. <script>
  94. import tabMixins from '@/mixins/tableColumnsMixin';
  95. import UserSearch from './components/user-search.vue';
  96. import UserEdit from './components/user-edit.vue';
  97. import work from '@/api/technology/work';
  98. import route from '@/api/technology/route';
  99. export default {
  100. name: 'technologyWork',
  101. mixins: [tabMixins],
  102. components: {
  103. UserSearch,
  104. UserEdit
  105. },
  106. data() {
  107. return {
  108. // 表格列配置
  109. columns: [
  110. {
  111. prop: 'factoryId',
  112. label: '所属工厂',
  113. slot: 'factoryId',
  114. showOverflowTooltip: true,
  115. align: 'center',
  116. minWidth: 110
  117. },
  118. {
  119. prop: 'code',
  120. label: '工作中心编码',
  121. showOverflowTooltip: true,
  122. align: 'center',
  123. minWidth: 110
  124. },
  125. {
  126. prop: 'name',
  127. label: '工作中心名称',
  128. showOverflowTooltip: true,
  129. align: 'center',
  130. minWidth: 110
  131. },
  132. {
  133. prop: 'categoryType',
  134. label: '工作中心类别',
  135. slot: 'categoryType',
  136. showOverflowTooltip: true,
  137. align: 'center'
  138. },
  139. {
  140. prop: 'leaderUserName',
  141. label: '负责人',
  142. // slot: 'leaderUserId',
  143. showOverflowTooltip: true,
  144. align: 'center'
  145. },
  146. {
  147. columnKey: 'action',
  148. label: '操作',
  149. width: 220,
  150. align: 'center',
  151. resizable: false,
  152. slot: 'action',
  153. showOverflowTooltip: true
  154. }
  155. ],
  156. categoryTypes: [
  157. { label: '设备', value: 0 },
  158. { label: '设备组', value: 1 },
  159. { label: '人工', value: 2 },
  160. { label: '人工组', value: 3 },
  161. { label: '生产线', value: 4 },
  162. { label: '委外生产', value: 5 }
  163. ],
  164. // 厂房列表
  165. fList: [],
  166. // 人员列表
  167. userList: [],
  168. // 表格选中数据
  169. selection: [],
  170. // 当前编辑数据
  171. current: null,
  172. // 是否显示编辑弹窗
  173. showEdit: false,
  174. // 是否显示导入弹窗
  175. showImport: false,
  176. loading: false,
  177. cacheKeyUrl: '439a8ef9-technology-work'
  178. };
  179. },
  180. created() {
  181. this.getfLise();
  182. this.getUserPage();
  183. },
  184. methods: {
  185. /*回显工厂 */
  186. checkfactoryId(id) {
  187. let obj = this.fList.find((f) => f.id == id);
  188. return obj?.name;
  189. },
  190. /*回显类别 */
  191. checkcategoryType(value) {
  192. return this.categoryTypes.find((f) => f.value == value).label;
  193. },
  194. /*回显负责人 */
  195. checkleaderUserId(id) {
  196. let obj = this.userList.find((f) => f.id == id);
  197. return obj?.name;
  198. },
  199. /*人员列表 */
  200. async getUserPage() {
  201. const res = await work.getUserPage();
  202. this.userList = res.list;
  203. },
  204. /*厂房列表 */
  205. async getfLise() {
  206. const res = await route.Flist({
  207. pageNum: 1,
  208. size: -1,
  209. type: 1
  210. });
  211. this.fList = res.list;
  212. },
  213. /* 表格数据源 */
  214. async datasource({ page, limit, where, order }) {
  215. const res = await work.list({
  216. ...where,
  217. ...order,
  218. pageNum: page,
  219. size: limit
  220. });
  221. return res;
  222. },
  223. /* 刷新表格 */
  224. reload(where) {
  225. this.$refs.table.reload({ page: 1, where: where });
  226. },
  227. /* 打开编辑弹窗 */
  228. openEdit(row,type) {
  229. this.current = row;
  230. if(this.current){
  231. this.current.type=type
  232. }
  233. this.showEdit = true;
  234. this.$refs.userEdit.$refs.form &&
  235. this.$refs.userEdit.$refs.form.clearValidate();
  236. },
  237. /* 打开导入弹窗 */
  238. openImport() {
  239. this.showImport = true;
  240. },
  241. /* 删除 */
  242. remove(row) {
  243. // const loading = this.$loading({ lock: true });
  244. this.loading = true;
  245. work
  246. .delete([row.id])
  247. .then((msg) => {
  248. // loading.close();
  249. this.loading = false;
  250. this.$message.success('删除' + msg);
  251. this.reload();
  252. })
  253. .catch((e) => {
  254. loading.close();
  255. // this.$message.error(e.message);
  256. });
  257. },
  258. /* 批量删除 */
  259. removeBatch() {
  260. if (!this.selection.length) {
  261. this.$message.error('请至少选择一条数据');
  262. return;
  263. }
  264. this.$confirm('确定要删除选中的工序吗?', '提示', {
  265. type: 'warning'
  266. })
  267. .then(() => {
  268. const loading = this.$loading({ lock: true });
  269. producetask
  270. .delete(this.selection.map((d) => d.id))
  271. .then((msg) => {
  272. loading.close();
  273. this.$message.success('删除' + msg);
  274. this.reload();
  275. })
  276. .catch((e) => {
  277. loading.close();
  278. // this.$message.error(e.message);
  279. });
  280. })
  281. .catch(() => {});
  282. }
  283. }
  284. };
  285. </script>