index-data.vue 14 KB

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