index-data.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. :need-page="true"
  9. :selection.sync="selection"
  10. :current.sync="rowCurrent"
  11. highlight-current-row
  12. height="calc(100vh - 412px)"
  13. full-height="calc(100vh - 116px)"
  14. tool-class="ele-toolbar-form"
  15. cache-key="systemDictDataTable"
  16. >
  17. <!-- 表头工具栏 -->
  18. <template v-slot:toolbar>
  19. <el-button
  20. size="small"
  21. type="primary"
  22. icon="el-icon-plus"
  23. class="ele-btn-icon"
  24. @click="openEdit({}, 2)"
  25. >
  26. 新建
  27. </el-button>
  28. <div class="upload" v-if="rootTreeId == 6">
  29. <el-upload
  30. v-if="!isLoading"
  31. :show-file-list="false"
  32. class="upload-demo"
  33. action=""
  34. :before-upload="beforeUpload"
  35. :on-success="successUpload"
  36. :on-error="errorUpload"
  37. >
  38. <slot>
  39. <el-button size="small" type="primary">导入</el-button>
  40. </slot>
  41. </el-upload>
  42. <el-button v-else size="small" type="primary" :loading="isLoading"
  43. >导入</el-button
  44. >
  45. </div>
  46. <!-- <el-button
  47. v-if="rootTreeId == 9"
  48. size="small"
  49. type="primary"
  50. @click="handleLink('4')"
  51. >关联设备</el-button
  52. >
  53. <el-button
  54. v-if="rootTreeId == 9"
  55. size="small"
  56. type="primary"
  57. @click="handleLink('5')"
  58. >关联模具</el-button
  59. >
  60. <el-button
  61. v-if="rootTreeId == 9"
  62. size="small"
  63. type="primary"
  64. @click="handleLink('8')"
  65. >关联舟皿</el-button
  66. >
  67. <el-button
  68. v-if="rootTreeId == 4"
  69. size="small"
  70. type="primary"
  71. @click="handleLink('5')"
  72. >关联模具</el-button
  73. >
  74. <el-button
  75. v-if="rootTreeId == 4"
  76. size="small"
  77. type="primary"
  78. @click="handleLink('6')"
  79. >关联备品备件</el-button
  80. >-->
  81. </template>
  82. <template v-slot:action="{ row }">
  83. <el-link type="primary" :underline="false" @click="openEdit(row, 1)">
  84. 复制
  85. </el-link>
  86. <el-link type="primary" :underline="false" @click="openEdit(row, 0)">
  87. 修改
  88. </el-link>
  89. <el-popconfirm
  90. class="ele-action"
  91. title="确定要删除此物料吗?"
  92. @confirm="remove(row)"
  93. >
  94. <template v-slot:reference>
  95. <el-link type="danger" :underline="false"> 删除 </el-link>
  96. </template>
  97. </el-popconfirm>
  98. <el-link
  99. type="primary"
  100. v-if="row.isProduct == 1"
  101. :underline="false"
  102. @click="openParam(row)"
  103. >
  104. 工艺参数
  105. </el-link>
  106. <el-link
  107. type="primary"
  108. v-if="row.isProduct == 1"
  109. :underline="false"
  110. @click="toBomManager(row)"
  111. >
  112. BOM管理
  113. </el-link>
  114. <el-link
  115. type="primary"
  116. v-if="row.isProduct == 1"
  117. :underline="false"
  118. @click="openMaterial(row)"
  119. >
  120. 物料BOM
  121. </el-link>
  122. <!-- <el-link
  123. type="primary"
  124. v-if="row.isProduct == 1"
  125. :underline="false"
  126. @click="openMould(row)"
  127. >
  128. 模具
  129. </el-link> -->
  130. <el-link
  131. type="primary"
  132. v-if="row.categoryLevelPathIdParent == 7"
  133. :underline="false"
  134. @click="handAllocation(row)"
  135. >
  136. 货位
  137. </el-link>
  138. <el-link
  139. type="primary"
  140. v-if="row.categoryLevelPathIdParent == 11"
  141. :underline="false"
  142. @click="handleAridRegion(row)"
  143. >
  144. 干燥区
  145. </el-link>
  146. </template>
  147. </ele-pro-table>
  148. <!-- 编辑弹窗 -->
  149. <!-- <dict-edit :visible.sync="showEdit" :id="id" @done="reload" /> -->
  150. <!-- 选择物料 -->
  151. <MaterialModal
  152. :visible.sync="materialEdit"
  153. :data="current"
  154. ref="materialRefs"
  155. ></MaterialModal>
  156. <!-- 工艺参数 -->
  157. <ParamEdit
  158. :visible.sync="paramEditShow"
  159. :paramData="current"
  160. ref="paramRefs"
  161. ></ParamEdit>
  162. <!-- 模具 -->
  163. <mouldDialog
  164. :visible.sync="mouldShow"
  165. :data="current"
  166. ref="mouldRefs"
  167. ></mouldDialog>
  168. <linkMaterialDialog ref="linkMaterialDialogRef" @success="success" />
  169. <!-- 货位 -->
  170. <goodsAllocation ref="allocationRef"></goodsAllocation>
  171. <!-- 干燥区 -->
  172. <aridRegion ref="aridRegionRef"></aridRegion>
  173. <!-- 导入错误弹框 -->
  174. <el-dialog
  175. title="导入失败"
  176. :visible.sync="exportErrorDioalogVisible"
  177. width="60%"
  178. >
  179. <el-table :data="errorData" style="width: 100%">
  180. <el-table-column label="名称" prop="name"> </el-table-column>
  181. <el-table-column label="型号" prop="modeType"> </el-table-column>
  182. <el-table-column label="编号" prop="codeNo"> </el-table-column>
  183. <el-table-column label="物料组" prop="code"> </el-table-column>
  184. <el-table-column label="失败原因" prop="remark"> </el-table-column>
  185. </el-table>
  186. <span slot="footer" class="dialog-footer">
  187. <el-button @click="exportErrorDioalogVisible = false">取 消</el-button>
  188. <el-button type="primary" @click="exportErrorDioalogVisible = false"
  189. >确 定</el-button
  190. >
  191. </span>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import {
  197. getMaterialList,
  198. removeMaterial,
  199. importCategorySparePart
  200. } from '@/api/material/list.js';
  201. import MaterialModal from './MaterialModal.vue';
  202. import ParamEdit from '@/views/technology/productParam/components/user-edit.vue';
  203. import mouldDialog from './mouldDialog';
  204. import linkMaterialDialog from './link-material-dialog.vue';
  205. import goodsAllocation from './goodsAllocation.vue';
  206. import aridRegion from './aridRegion';
  207. export default {
  208. components: {
  209. MaterialModal,
  210. ParamEdit,
  211. mouldDialog,
  212. linkMaterialDialog,
  213. goodsAllocation,
  214. aridRegion
  215. },
  216. props: {
  217. // 物料组id
  218. currentId: [Number, String],
  219. data: Object,
  220. rootId: [Number, String],
  221. rootTreeId: [Number, String]
  222. },
  223. data() {
  224. return {
  225. errorData: [],
  226. exportErrorDioalogVisible: false,
  227. // 表格列配置
  228. columns: [
  229. {
  230. columnKey: 'index',
  231. type: 'index',
  232. width: 50,
  233. align: 'center',
  234. showOverflowTooltip: true,
  235. label: '序号'
  236. },
  237. {
  238. prop: 'code',
  239. label: '编码',
  240. align: 'center',
  241. showOverflowTooltip: true,
  242. minWidth: 110
  243. },
  244. {
  245. prop: 'name',
  246. label: '名称',
  247. align: 'center',
  248. showOverflowTooltip: true,
  249. minWidth: 110
  250. },
  251. {
  252. prop: 'brandNum',
  253. align: 'center',
  254. label: '牌号',
  255. showOverflowTooltip: true
  256. },
  257. {
  258. prop: 'modelType',
  259. label: '型号',
  260. align: 'center',
  261. showOverflowTooltip: true
  262. },
  263. {
  264. prop: 'specification',
  265. label: '规格',
  266. align: 'center',
  267. showOverflowTooltip: true
  268. },
  269. {
  270. prop: 'level',
  271. label: '级别',
  272. align: 'center',
  273. showOverflowTooltip: true
  274. },
  275. {
  276. prop: 'measuringUnit',
  277. label: '计量单位',
  278. showOverflowTooltip: true,
  279. minWidth: 90
  280. },
  281. {
  282. prop: 'weightUnit',
  283. label: '重量单位',
  284. showOverflowTooltip: true,
  285. minWidth: 90
  286. },
  287. {
  288. prop: 'roughWeight',
  289. label: '毛重',
  290. showOverflowTooltip: true,
  291. minWidth: 90
  292. },
  293. {
  294. prop: 'netWeight',
  295. label: '净重',
  296. showOverflowTooltip: true,
  297. minWidth: 90
  298. },
  299. {
  300. prop: 'packingUnit',
  301. align: 'center',
  302. label: '包装单位',
  303. showOverflowTooltip: true
  304. },
  305. {
  306. prop: 'categoryLevelPath',
  307. label: '分类',
  308. align: 'center',
  309. showOverflowTooltip: true
  310. },
  311. {
  312. columnKey: 'action',
  313. label: '操作',
  314. width: 200,
  315. align: 'center',
  316. resizable: false,
  317. slot: 'action',
  318. fixed: 'right'
  319. }
  320. ],
  321. // 表格选中数据
  322. selection: [],
  323. // 是否显示编辑弹窗
  324. showEdit: false,
  325. id: null,
  326. materialEdit: false,
  327. paramEditShow: false,
  328. mouldShow: false,
  329. current: null,
  330. rowCurrent: null,
  331. isLoading: false
  332. };
  333. },
  334. methods: {
  335. toBomManager(row) {
  336. this.$router.push({
  337. path: '/material/BOMmanage',
  338. query: {
  339. categoryId: row.id,
  340. code: row.code
  341. }
  342. });
  343. },
  344. successUpload(response) {
  345. this.isLoading = false;
  346. },
  347. errorUpload(response) {
  348. this.isLoading = false;
  349. },
  350. // 上传备品备件
  351. beforeUpload(file) {
  352. if (file.size / 1024 / 1024 > this.size) {
  353. this.$message.error(`大小不能超过 ${this.size}MB`);
  354. return false;
  355. }
  356. if (this.limit > 0 && this.fileList.length === this.limit) {
  357. this.$message.error(`最多上传 ${this.limit}个文件`);
  358. return false;
  359. }
  360. let formData = new FormData();
  361. formData.append('file', file);
  362. this.isLoading = true;
  363. return importCategorySparePart(formData).then((res) => {
  364. if (res.data.length > 0) {
  365. this.exportErrorDioalogVisible = true;
  366. this.errorData = res.data;
  367. } else {
  368. this.$message.success('导入成功!');
  369. }
  370. this.isLoading = false;
  371. return false;
  372. });
  373. },
  374. /* 表格数据源 */
  375. datasource({ page, limit, where, order }) {
  376. return getMaterialList({
  377. pageNum: page,
  378. size: limit,
  379. ...where,
  380. categoryLevelId: this.currentId
  381. });
  382. },
  383. /* 刷新表格 */
  384. reload(where) {
  385. this.$refs.table.reload({
  386. page: 1,
  387. where: where,
  388. categoryLevelId: this.currentId
  389. });
  390. },
  391. /* 显示编辑 */
  392. openEdit(row, status) {
  393. this.$router.push({
  394. path: '/material/product/detail',
  395. query: {
  396. id: row.id ? row.id : null,
  397. status: status,
  398. rootId: this.rootId,
  399. t: new Date().getTime()
  400. }
  401. });
  402. },
  403. /* 删除 */
  404. remove(row) {
  405. const loading = this.$loading({ lock: true });
  406. removeMaterial(row.id)
  407. .then((msg) => {
  408. loading.close();
  409. this.$message.success('删除' + msg);
  410. this.reload();
  411. })
  412. .catch((e) => {
  413. loading.close();
  414. // this.$message.error(e.message);
  415. });
  416. },
  417. openMaterial(row) {
  418. this.current = row;
  419. this.materialEdit = true;
  420. this.$refs.materialRefs.$refs.form &&
  421. this.$refs.materialRefs.$refs.form.clearValidate();
  422. },
  423. openParam(row) {
  424. this.paramEditShow = true;
  425. this.current = row;
  426. this.$refs.paramRefs.$refs.form &&
  427. this.$refs.paramRefs.$refs.form.clearValidate();
  428. },
  429. openMould(row) {
  430. this.current = row;
  431. this.mouldShow = true;
  432. this.$refs.mouldRefs.$refs.form &&
  433. this.$refs.mouldRefs.$refs.form.clearValidate();
  434. },
  435. handleLink(type) {
  436. if (!this.rowCurrent) {
  437. return this.$message.error(
  438. this.rootTreeId == 9
  439. ? '请选择产品!'
  440. : this.rootTreeId == 4
  441. ? '请选择设备!'
  442. : ''
  443. );
  444. }
  445. this.$refs.linkMaterialDialogRef.open(type, this.rowCurrent);
  446. },
  447. success() {
  448. this.reload();
  449. },
  450. handAllocation(row) {
  451. this.$refs.allocationRef.open(row);
  452. },
  453. handleAridRegion(row) {
  454. this.$refs.aridRegionRef.open(row);
  455. }
  456. },
  457. watch: {
  458. // 监听物料组id变化
  459. currentId() {
  460. this.reload();
  461. }
  462. }
  463. };
  464. </script>
  465. <style lang="scss" scoped>
  466. .upload {
  467. display: inline-block;
  468. width: 100px;
  469. margin-left: 10px;
  470. }
  471. </style>