index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <div>
  3. <el-row :gutter="10">
  4. <el-col :span="4" v-if="!props.expressStatus">
  5. <el-card :class="props.selectStatus ? 'select-card' : 'box-card'">
  6. <el-input v-model="filterTree" placeholder="请输入BOM分类" />
  7. <el-tree
  8. ref="treeCategory"
  9. :data="categoryTreeData"
  10. :props="{ children: 'children', label: 'name' }"
  11. node-key="id"
  12. default-expand-all
  13. :expand-on-click-node="false"
  14. :indent="10"
  15. :filter-node-method="filterNodeMethod"
  16. @node-click="handleNodeClick" />
  17. </el-card>
  18. </el-col>
  19. <el-col :span="props.expressStatus ? 24 : 20">
  20. <el-card :class="props.selectStatus ? 'select-card' : 'box-card'">
  21. <byTable
  22. :source="sourceList.data"
  23. :pagination="sourceList.pagination"
  24. :config="config"
  25. :loading="loading"
  26. :searchConfig="searchConfig"
  27. :defaultExpandAll="props.selectStatus"
  28. highlight-current-row
  29. :action-list="[
  30. props.selectStatus
  31. ? ''
  32. : {
  33. text: '添加BOM',
  34. action: () => clickModal(),
  35. },
  36. props.selectStatus
  37. ? ''
  38. : {
  39. text: '操作日志',
  40. action: () => viewLogs(),
  41. },
  42. ]"
  43. @get-list="getList"
  44. @clickReset="clickReset">
  45. <template #typeExpand="{ item }">
  46. <div style="box-sizing: border-box">
  47. <div
  48. v-for="spec in item.bomSpecList"
  49. :key="spec.id"
  50. style="display: flex; padding: 8px 16px; align-items: center; box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1); margin-bottom: 8px">
  51. <div style="width: 80px">
  52. <div v-if="spec.mainImgUrl">
  53. <img
  54. style="width: 40px; height: 40px; object-fit: contain; vertical-align: middle; border: none; cursor: pointer"
  55. :src="spec.mainImgUrl"
  56. @click="openFile(spec.mainImgUrl)" />
  57. </div>
  58. <div
  59. v-else
  60. class="el-icon-picture-outline"
  61. style="width: 40px; height: 40px; font-size: 36px; line-height: 40px; text-align: center; color: rgb(229 228 228)"></div>
  62. </div>
  63. <div style="width: 180px">
  64. {{ spec.code }}
  65. </div>
  66. <div style="flex: 1">
  67. {{ spec.name }}
  68. </div>
  69. <div style="width: 180px">
  70. {{ `${spec.length} * ${spec.width} * ${spec.height}(cm³)` }}
  71. </div>
  72. <div style="width: 60px; text-align: center" v-if="props.selectStatus && !props.priceSystemId">
  73. <el-button type="primary" text @click="selectBOM(spec)" :disabled="selectBtnStatus">选择</el-button>
  74. </div>
  75. <div style="width: 140px; padding: 0 12px" v-if="props.priceSystemId">
  76. <el-input-number
  77. onmousewheel="return false;"
  78. v-model="spec.internalSellingPrice"
  79. placeholder="对内销售价"
  80. style="width: 100%"
  81. :controls="false"
  82. :min="0"
  83. :precision="2"
  84. @change="changePrice(spec)" />
  85. </div>
  86. <div style="width: 140px; padding: 0 12px" v-if="props.priceSystemId">
  87. <el-input-number
  88. onmousewheel="return false;"
  89. v-model="spec.externalSellingPrice"
  90. placeholder="对外销售价"
  91. style="width: 100%"
  92. :controls="false"
  93. :min="0"
  94. :precision="2"
  95. @change="changePrice(spec)" />
  96. </div>
  97. </div>
  98. </div>
  99. </template>
  100. <template #name="{ item }">
  101. <div>
  102. <a style="color: #409eff; cursor: pointer; word-break: break-all" @click="clickName(item)">{{ item.name }}</a>
  103. </div>
  104. </template>
  105. <template #priceBillingStandardId="{ item }">
  106. <div style="width: 100%">
  107. <el-select v-model="item.priceBillingStandardId" placeholder="加工报价" clearable @change="changePriceBillingStandard(item)">
  108. <el-option v-for="item in priceBillingStandardList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  109. </el-select>
  110. </div>
  111. </template>
  112. <template #internalSellingPrice>
  113. <div style="width: 100%"></div>
  114. </template>
  115. <template #externalSellingPrice>
  116. <div style="width: 100%"></div>
  117. </template>
  118. </byTable>
  119. </el-card>
  120. </el-col>
  121. </el-row>
  122. <el-dialog :title="modalTitle" v-if="openDialog" v-model="openDialog" width="90%">
  123. <MakeBOM :rowData="rowData" :detailStatus="detailStatus" @clickCancel="clickCancel"></MakeBOM>
  124. </el-dialog>
  125. <el-dialog title="操作日志" v-if="openLogs" v-model="openLogs" width="50%">
  126. <byTable
  127. :source="logsList.data"
  128. :pagination="logsList.pagination"
  129. :config="configLogs"
  130. :loading="loadingLogs"
  131. highlight-current-row
  132. @get-list="getLogsList">
  133. </byTable>
  134. <template #footer>
  135. <el-button @click="openLogs = false" size="large">关 闭</el-button>
  136. </template>
  137. </el-dialog>
  138. </div>
  139. </template>
  140. <script setup>
  141. import byTable from "@/components/byTable/index";
  142. import { ElMessage, ElMessageBox } from "element-plus";
  143. import MakeBOM from "@/components/makeBOM/index";
  144. const { proxy } = getCurrentInstance();
  145. const props = defineProps({
  146. selectStatus: Boolean,
  147. bomClassifyIdList: Array,
  148. expressStatus: Boolean,
  149. priceSystemId: String,
  150. });
  151. const filterTree = ref("");
  152. const treeCategory = ref(null);
  153. const categoryTreeData = ref([]);
  154. const getTreeList = () => {
  155. proxy.post("/bomClassify/tree", {}).then((res) => {
  156. if (res && res.length > 0) {
  157. if (props.bomClassifyIdList) {
  158. categoryTreeData.value = res.filter((item) => props.bomClassifyIdList.includes(item.id));
  159. } else {
  160. categoryTreeData.value = res;
  161. }
  162. }
  163. });
  164. };
  165. getTreeList();
  166. watch(filterTree, (val) => {
  167. treeCategory.value.filter(val);
  168. });
  169. const filterNodeMethod = (value, data) => {
  170. if (!value) return true;
  171. return data.name.includes(value);
  172. };
  173. const handleNodeClick = (val) => {
  174. getList({ bomClassifyId: val.id });
  175. };
  176. const sourceList = ref({
  177. data: [],
  178. pagination: {
  179. total: 0,
  180. pageNum: 1,
  181. pageSize: 10,
  182. name: "",
  183. code: "",
  184. species: "",
  185. chromatophore: "",
  186. frontGrain: "",
  187. reverseGrain: "",
  188. colour: "",
  189. bomClassifyId: "",
  190. bomClassifyIdList: [],
  191. priceSystemId: "",
  192. },
  193. });
  194. const loading = ref(false);
  195. const searchConfig = computed(() => {
  196. return [
  197. {
  198. type: "input",
  199. prop: "name",
  200. label: "品名",
  201. },
  202. {
  203. type: "input",
  204. prop: "code",
  205. label: "品号",
  206. },
  207. {
  208. type: "select",
  209. prop: "species",
  210. dictKey: "bom_species",
  211. label: "种类",
  212. },
  213. {
  214. type: "select",
  215. prop: "chromatophore",
  216. dictKey: "bom_chromatophore",
  217. label: "色层",
  218. },
  219. {
  220. type: "select",
  221. prop: "embossingProcess",
  222. dictKey: "bom_embossingProcess",
  223. label: "压纹工艺",
  224. },
  225. {
  226. type: "select",
  227. prop: "frontGrain",
  228. dictKey: "bom_frontGrain",
  229. label: "正面纹路",
  230. },
  231. {
  232. type: "select",
  233. prop: "reverseGrain",
  234. dictKey: "bom_reverseGrain",
  235. label: "背面纹路",
  236. },
  237. {
  238. type: "input",
  239. prop: "colour",
  240. label: "颜色",
  241. },
  242. ];
  243. });
  244. const config = computed(() => {
  245. return [
  246. {
  247. type: "expand",
  248. attrs: {
  249. label: " ",
  250. slot: "typeExpand",
  251. width: 50,
  252. },
  253. },
  254. {
  255. attrs: {
  256. label: "群组品名",
  257. slot: "name",
  258. "min-width": 240,
  259. },
  260. },
  261. {
  262. attrs: {
  263. label: "项目小类",
  264. prop: "itemSubclass",
  265. width: 120,
  266. },
  267. render(val) {
  268. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_itemSubclass"]);
  269. },
  270. },
  271. {
  272. attrs: {
  273. label: "种类",
  274. prop: "species",
  275. width: 120,
  276. },
  277. render(val) {
  278. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_species"]);
  279. },
  280. },
  281. {
  282. attrs: {
  283. label: "色层",
  284. prop: "chromatophore",
  285. width: 100,
  286. },
  287. render(val) {
  288. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_chromatophore"]);
  289. },
  290. },
  291. props.priceSystemId
  292. ? {
  293. attrs: {
  294. label: "加工报价",
  295. slot: "priceBillingStandardId",
  296. width: 160,
  297. },
  298. }
  299. : {
  300. attrs: {
  301. label: "压纹工艺",
  302. prop: "embossingProcess",
  303. width: 120,
  304. },
  305. render(val) {
  306. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_embossingProcess"]);
  307. },
  308. },
  309. props.priceSystemId
  310. ? {
  311. attrs: {
  312. label: "对内销售价(含税)",
  313. slot: "internalSellingPrice",
  314. width: 140,
  315. },
  316. }
  317. : {
  318. attrs: {
  319. label: "正面纹路",
  320. prop: "frontGrain",
  321. width: 120,
  322. },
  323. render(val) {
  324. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_frontGrain"]);
  325. },
  326. },
  327. props.priceSystemId
  328. ? {
  329. attrs: {
  330. label: "对内销售价(含税)",
  331. slot: "externalSellingPrice",
  332. width: 140,
  333. },
  334. }
  335. : {
  336. attrs: {
  337. label: "背面纹路",
  338. prop: "reverseGrain",
  339. width: 120,
  340. },
  341. render(val) {
  342. return proxy.dictKeyValue(val, proxy.useUserStore().allDict["bom_reverseGrain"]);
  343. },
  344. },
  345. props.priceSystemId
  346. ? {
  347. attrs: {
  348. width: 16,
  349. },
  350. }
  351. : {
  352. attrs: {
  353. label: "操作",
  354. width: 120,
  355. align: "center",
  356. fixed: "right",
  357. },
  358. renderHTML(row) {
  359. return [
  360. props.selectStatus
  361. ? {}
  362. : {
  363. attrs: {
  364. label: "编辑",
  365. type: "primary",
  366. text: true,
  367. },
  368. el: "button",
  369. click() {
  370. clickUpdate(row);
  371. },
  372. },
  373. props.selectStatus
  374. ? {}
  375. : {
  376. attrs: {
  377. label: "删除",
  378. type: "primary",
  379. text: true,
  380. },
  381. el: "button",
  382. click() {
  383. clickDelete(row);
  384. },
  385. },
  386. ];
  387. },
  388. },
  389. ];
  390. });
  391. const getList = async (req, status) => {
  392. if (status) {
  393. sourceList.value.pagination = {
  394. pageNum: sourceList.value.pagination.pageNum,
  395. pageSize: sourceList.value.pagination.pageSize,
  396. };
  397. } else {
  398. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  399. }
  400. if (props.bomClassifyIdList) {
  401. sourceList.value.pagination.bomClassifyIdList = props.bomClassifyIdList;
  402. }
  403. if (props.expressStatus) {
  404. sourceList.value.pagination.bomClassifyId = "1682221528948760578";
  405. }
  406. loading.value = true;
  407. let path = "/bom/page";
  408. if (props.priceSystemId) {
  409. path = "/priceSystem/getBomPriceDetail";
  410. sourceList.value.pagination.priceSystemId = props.priceSystemId;
  411. }
  412. proxy.post(path, sourceList.value.pagination).then((res) => {
  413. sourceList.value.data = res.rows;
  414. sourceList.value.pagination.total = res.total;
  415. setTimeout(() => {
  416. loading.value = false;
  417. }, 200);
  418. });
  419. };
  420. getList();
  421. const clickReset = () => {
  422. treeCategory.value.setCurrentKey(null);
  423. getList("", true);
  424. };
  425. const modalTitle = ref("添加BOM");
  426. const openDialog = ref(false);
  427. const rowData = ref({});
  428. const detailStatus = ref(false);
  429. const clickModal = () => {
  430. modalTitle.value = "添加BOM";
  431. rowData.value = {};
  432. detailStatus.value = false;
  433. openDialog.value = true;
  434. };
  435. const clickUpdate = (row) => {
  436. modalTitle.value = "编辑BOM";
  437. rowData.value = row;
  438. detailStatus.value = false;
  439. openDialog.value = true;
  440. };
  441. const clickDelete = (row) => {
  442. ElMessageBox.confirm("你是否确认此操作", "提示", {
  443. confirmButtonText: "确定",
  444. cancelButtonText: "取消",
  445. type: "warning",
  446. })
  447. .then(() => {
  448. proxy.post("/bom/delete", { id: row.id }).then(() => {
  449. ElMessage({ message: "删除成功", type: "success" });
  450. getList();
  451. });
  452. })
  453. .catch(() => {});
  454. };
  455. const clickCancel = (status) => {
  456. openDialog.value = false;
  457. if (status) {
  458. getList();
  459. }
  460. };
  461. const openFile = (path) => {
  462. window.open(path);
  463. };
  464. const clickName = (row) => {
  465. modalTitle.value = "BOM详情";
  466. rowData.value = row;
  467. detailStatus.value = true;
  468. openDialog.value = true;
  469. };
  470. const openLogs = ref(false);
  471. const loadingLogs = ref(false);
  472. const logsList = ref({
  473. data: [],
  474. pagination: {
  475. total: 0,
  476. pageNum: 1,
  477. pageSize: 10,
  478. },
  479. });
  480. const type = ref([
  481. { dictKey: "1", dictValue: "新增" },
  482. { dictKey: "2", dictValue: "修改" },
  483. { dictKey: "3", dictValue: "删除" },
  484. ]);
  485. const configLogs = computed(() => {
  486. return [
  487. {
  488. attrs: {
  489. label: "操作时间",
  490. prop: "createTime",
  491. width: 160,
  492. align: "center",
  493. },
  494. },
  495. {
  496. attrs: {
  497. label: "操作人",
  498. prop: "operator",
  499. align: "center",
  500. },
  501. },
  502. {
  503. attrs: {
  504. label: "BOM品号",
  505. prop: "code",
  506. align: "center",
  507. },
  508. },
  509. {
  510. attrs: {
  511. label: "行为",
  512. prop: "type",
  513. width: 100,
  514. align: "center",
  515. },
  516. render(val) {
  517. return proxy.dictKeyValue(val, type.value);
  518. },
  519. },
  520. ];
  521. });
  522. const viewLogs = () => {
  523. logsList.value.data = [];
  524. logsList.value.pagination.total = 0;
  525. openLogs.value = true;
  526. getLogsList({ pageNum: 1, pageSize: 10 });
  527. };
  528. const getLogsList = async (req) => {
  529. logsList.value.pagination = { ...logsList.value.pagination, ...req };
  530. loadingLogs.value = true;
  531. proxy.post("/bomOperatingLog/page", logsList.value.pagination).then((res) => {
  532. logsList.value.data = res.rows;
  533. logsList.value.pagination.total = res.total;
  534. setTimeout(() => {
  535. loadingLogs.value = false;
  536. }, 200);
  537. });
  538. };
  539. const emit = defineEmits(["selectBOM"]);
  540. const selectBtnStatus = ref(false);
  541. const selectBOM = (item) => {
  542. selectBtnStatus.value = true;
  543. emit("selectBOM", item);
  544. setTimeout(() => {
  545. selectBtnStatus.value = false;
  546. }, 200);
  547. };
  548. const priceBillingStandardList = ref([]);
  549. const getPriceBillingStandard = () => {
  550. proxy.post("/priceBillingStandard/list", {}).then((res) => {
  551. if (res && res.length > 0) {
  552. priceBillingStandardList.value = res.map((item) => {
  553. return {
  554. dictKey: item.id,
  555. dictValue: item.name,
  556. };
  557. });
  558. }
  559. });
  560. };
  561. if (props.priceSystemId) {
  562. getPriceBillingStandard();
  563. }
  564. const changePriceBillingStandard = (row) => {
  565. let data = {
  566. priceSystemId: props.priceSystemId,
  567. bomId: row.id,
  568. priceBillingStandardId: row.priceBillingStandardId,
  569. };
  570. proxy.post("/priceSystemBom/saveOrEdit", data).then();
  571. };
  572. const changePrice = (row) => {
  573. let data = {
  574. priceSystemId: props.priceSystemId,
  575. bomSpecId: row.id,
  576. internalSellingPrice: row.internalSellingPrice,
  577. externalSellingPrice: row.externalSellingPrice,
  578. };
  579. proxy.post("/priceSystemBomSpec/saveOrEdit", data).then();
  580. };
  581. </script>
  582. <style lang="scss" scoped>
  583. :deep(.el-dialog) {
  584. margin-top: 10px !important;
  585. margin-bottom: 10px !important;
  586. }
  587. .select-card {
  588. height: calc(100vh - 184px);
  589. overflow-y: auto;
  590. overflow-x: hidden;
  591. }
  592. </style>