index-data.vue 13 KB

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