index-data.vue 13 KB

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