index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  1. <template>
  2. <div class="box">
  3. <div class="tree">
  4. <treeList title="产品分类" submitType="1" :data="treeListData" v-model="sourceList.pagination.productClassifyId" @change="treeChange"
  5. @changeTreeList="getTreeList">
  6. </treeList>
  7. </div>
  8. <div class="content">
  9. <byTable :source="sourceList.data" :tableHeight="tableHeight" :pagination="sourceList.pagination" :config="config" :loading="loading"
  10. highlight-current-row :selectConfig="selectConfig" :action-list="[
  11. {
  12. text: '导出Excel',
  13. action: () => exportExcel(),
  14. disabled: false,
  15. },
  16. {
  17. text: '添加',
  18. action: () => openModal('add'),
  19. disabled: false,
  20. },]" @get-list="getList">
  21. <template #name="{ item }">
  22. <div>
  23. <span class="el-click">{{ item.name }}</span>
  24. </div>
  25. </template>
  26. <template #pic="{ item }">
  27. <div v-if="item.fileList.length > 0">
  28. <img :src="item.fileList[0].fileUrl" class="pic" @click="handleClickFile(item.fileList[0])" />
  29. </div>
  30. <div v-else></div>
  31. </template>
  32. <template #size="{ item }">
  33. <div v-if="item['length'] && item.width && item.height">
  34. <span>{{ item['length'] }}</span>*
  35. <span>{{ item.width }}</span>*
  36. <span>{{ item.height }}</span>
  37. </div>
  38. <div v-else></div>
  39. </template>
  40. <template #price="{ item }">
  41. <div v-if="item.price">
  42. <span> {{ moneyFormat(item.price ,2)}}</span>
  43. </div>
  44. <div v-else></div>
  45. </template>
  46. </byTable>
  47. </div>
  48. <el-dialog :title="modalType == 'add' ? '添加产品' : '编辑产品'" v-model="dialogVisible" width="80%" destroy-on-close>
  49. <div class="public_height_dialog">
  50. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom" v-loading="submitLoading">
  51. <template #nameEnglish>
  52. <div style="width: 100%">
  53. <el-input v-model="formData.data.nameEnglish" placeholder="请输入" onkeyup="value=value.replace(/[^\x00-\xff]/g, '')"></el-input>
  54. </div>
  55. </template>
  56. <template #productionFile>
  57. <div style="width: 100%">
  58. <span style="color:#409eff;cursor:pointer" @click="handleClickUpload('prodFilePath',true)"
  59. v-if="!formData.data.prodFilePath">点击上传</span>
  60. <span style="color:#409eff;cursor:pointer" @click="handleClickUpload('prodFilePath',false)" v-else>点击查看</span>
  61. </div>
  62. </template>
  63. <template #productionFileOne>
  64. <div style="width: 100%">
  65. <el-button type="primary" plain @click="handleClickUpload('prodImgPath',true)" v-if="!formData.data.prodImgPath">点击上传</el-button>
  66. <el-button type="primary" plain @click="handleClickUpload('prodImgPath',false)" v-else>点击查看</el-button>
  67. </div>
  68. </template>
  69. <template #size>
  70. <div style="width: 100%">
  71. <el-form-item label="尺寸" class="margin-b-0 wid100" required>
  72. <el-row>
  73. <el-col :span="8">
  74. <el-form-item prop="length" label-width="0px" class="margin-b-0 wid100">
  75. <el-input-number v-model="formData.data['length']" placeholder="长 (cm)" style="width: 100%" :precision="2" :controls="false"
  76. :min="0" onmousewheel="return false;" @change="getPriceData" />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item prop="width" label-width="0px" class="margin-b-0 wid100">
  81. <el-input-number v-model="formData.data.width" placeholder="宽 (cm)" style="width: 100%" :precision="2" :controls="false"
  82. :min="0" onmousewheel="return false;" @change="getPriceData" />
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="8">
  86. <el-form-item prop="height" label-width="0px" class="margin-b-0 wid100">
  87. <el-input-number v-model="formData.data.height" placeholder="高 (cm)" style="width: 100%" :precision="2" :controls="false"
  88. :min="0" onmousewheel="return false;" @change="getPriceData" />
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. </el-form-item>
  93. </div>
  94. </template>
  95. </byForm>
  96. </div>
  97. <template #footer>
  98. <el-button @click="dialogVisible = false" size="defualt" v-debounce>取 消</el-button>
  99. <el-button type="primary" @click="submitForm()" size="defualt" v-debounce>确 定</el-button>
  100. </template>
  101. </el-dialog>
  102. <el-dialog :title="'BOM 配置'" v-model="bomDialog" width="900" destroy-on-close>
  103. <!-- <div class="public_height_dialog"> -->
  104. <byForm :formConfig="bomFormConfig" :formOption="bomFormOption" v-model="formData.bomData" :rules="bomRules" ref="bomFormDom"
  105. v-loading="submitLoading">
  106. <!-- <template #accessories>
  107. <div style="width: 100%">
  108. <el-button type="primary" @click="openSelectMaterial = true" plain>选择</el-button>
  109. <el-table :data="formData.bomData.productBomDetailList" style="width: 100%; margin-top: 16px" border>
  110. <el-table-column prop="materialName" label="物料名称" min-width="130" />
  111. <el-table-column prop="materialCode" label="物料编码" width="150" />
  112. <el-table-column label="数量" width="150">
  113. <template #default="{ row, $index }">
  114. <div style="width: 100%">
  115. <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="bomRules.quantity" :inline-message="true"
  116. class="margin-b-0 wid100">
  117. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
  118. :controls="false" :min="1" />
  119. </el-form-item>
  120. </div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="操作" width="60" align="center" fixed="right">
  124. <template #default="{ $index }">
  125. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. </div>
  130. </template>
  131. <template #detail>
  132. <div style="width: 100%">
  133. <el-table :data="formData.bomData.processesList" style="width: 100%; " border>
  134. <el-table-column label="序号" type="index" width="80" />
  135. <el-table-column prop="code" label="工序编码" />
  136. <el-table-column prop="name" label="工序名称" />
  137. </el-table>
  138. </div>
  139. </template> -->
  140. <template #detail>
  141. <div style="width: 100%">
  142. <div style="text-align:center;margin-bottom:10px">
  143. 【{{formData.bomData.name}} {{formData.bomData.code}}】BOM单
  144. </div>
  145. <table border class="table" style="width:100%">
  146. <tbody>
  147. <tr>
  148. <td style="width:90px">原材料</td>
  149. <td style="padding:10px">
  150. <el-select v-model="formData.bomData.rawMaterialId" placeholder="请选择原材料" style="width:100%">
  151. <el-option v-for="item in rawMaterialData" :key="item.value" :label="item.label" :value="item.value" filterable />
  152. </el-select>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td>
  157. 包材辅材
  158. </td>
  159. <td style="padding:20px 20px 20px">
  160. <div style="text-align:left"><el-button type="primary" @click="openSelectMaterial = true" plain>选择</el-button></div>
  161. <el-table :data="formData.bomData.productBomDetailList" style="width: 100%;">
  162. <el-table-column prop="materialName" label="物料名称" min-width="130" />
  163. <el-table-column prop="materialCode" label="物料编码" width="150" />
  164. <el-table-column label="数量" width="150">
  165. <template #default="{ row, $index }">
  166. <div style="width: 100%">
  167. <el-form-item :prop="'productBomDetailList.' + $index + '.quantity'" :rules="bomRules.quantity" :inline-message="true"
  168. class="margin-b-0 wid100">
  169. <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%"
  170. :precision="0" :controls="false" :min="1" />
  171. </el-form-item>
  172. </div>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="操作" width="60" align="center" fixed="right">
  176. <template #default="{ $index }">
  177. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. </td>
  182. </tr>
  183. <tr>
  184. <td>
  185. 生产工序
  186. </td>
  187. <td style="padding:0 20px 20px">
  188. <el-table :data="formData.bomData.processesList" style="width: 100%; ">
  189. <el-table-column label="序号" type="index" width="80" />
  190. <el-table-column prop="code" label="工序编码" />
  191. <el-table-column prop="name" label="工序名称" />
  192. </el-table>
  193. </td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. </div>
  198. </template>
  199. </byForm>
  200. <!-- </div> -->
  201. <template #footer>
  202. <el-button @click="bomDialog = false" size="defualt" v-debounce>取 消</el-button>
  203. <el-button type="primary" @click="submitBomForm()" size="defualt" v-debounce>确 定</el-button>
  204. </template>
  205. </el-dialog>
  206. <el-dialog :title="'物料选择'" v-model="openSelectMaterial" width="90%" destroy-on-close>
  207. <SelectMaterial :isNeRawMaterial="'1'" @selectMaterial="selectMaterial"></SelectMaterial>
  208. <template #footer>
  209. <el-button @click="bomDialog = false" size="defualt" v-debounce>取 消</el-button>
  210. </template>
  211. </el-dialog>
  212. <el-dialog title="导入产品" v-model="openExcelDialog" width="400">
  213. <div v-loading="excelLoading">
  214. <el-upload :action="actionUrl + '/productInfo/excelImportByEhsd'" :headers="headers" :on-success="handleSuccess" :on-progress="handleProgress"
  215. :show-file-list="false" :on-error="handleError" accept=".xlsx">
  216. <el-button type="primary">点击导入</el-button>
  217. </el-upload>
  218. </div>
  219. <template #footer>
  220. <el-button @click="openExcelDialog = false" size="default" v-debounce>取 消</el-button>
  221. </template>
  222. </el-dialog>
  223. </div>
  224. </template>
  225. <script setup>
  226. import byTable from "@/components/byTable/index";
  227. import byForm from "@/components/byForm/index";
  228. import treeList from "@/components/product/treeList";
  229. import SelectMaterial from "@/components/product/SelectMaterial.vue";
  230. import { getToken } from "@/utils/auth";
  231. const { proxy } = getCurrentInstance();
  232. const actionUrl = import.meta.env.VITE_APP_BASE_API;
  233. const loading = ref(false);
  234. const submitLoading = ref(false);
  235. const treeData = ref([]);
  236. const treeDataOne = ref([]);
  237. const treeListData = ref([]);
  238. const technologyData = ref([]);
  239. const companyData = ref([]);
  240. const currencyData = computed(
  241. () => proxy.useUserStore().allDict["account_currency"]
  242. );
  243. const headers = ref({ Authorization: "Bearer " + getToken() });
  244. const tableHeight = ref(0);
  245. const getTableHeight = () => {
  246. tableHeight.value = window.innerHeight - 245;
  247. };
  248. getTableHeight();
  249. window.addEventListener("resize", () => {
  250. getTableHeight();
  251. });
  252. const sourceList = ref({
  253. data: [],
  254. pagination: {
  255. total: 3,
  256. pageNum: 1,
  257. pageSize: 10,
  258. type: "",
  259. productClassifyId: "",
  260. keyword: "",
  261. definition: "1",
  262. companyId: "",
  263. },
  264. });
  265. const dialogVisible = ref(false);
  266. const openExcelDialog = ref(false);
  267. const excelLoading = ref(false);
  268. const modalType = ref("add");
  269. const rules = ref({
  270. companyId: [{ required: true, message: "请选择归属公司", trigger: "change" }],
  271. productClassifyId: [
  272. { required: true, message: "请选择产品分类", trigger: "change" },
  273. ],
  274. name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
  275. customCode: [{ required: true, message: "请输入产品编号", trigger: "blur" }],
  276. length: [{ required: true, message: "请输入长 (cm)", trigger: "blur" }],
  277. width: [{ required: true, message: "请输入宽 (cm)", trigger: "blur" }],
  278. height: [{ required: true, message: "请输入高 (cm)", trigger: "blur" }],
  279. technologyId: [
  280. { required: true, message: "请选择生产工艺", trigger: "change" },
  281. ],
  282. rawMaterialId: [
  283. { required: true, message: "请选择原材料", trigger: "change" },
  284. ],
  285. });
  286. const props = defineProps({
  287. selectStatus: Boolean,
  288. });
  289. const selectConfig = computed(() => [
  290. {
  291. label: "业务公司",
  292. prop: "companyId",
  293. data: companyData.value,
  294. },
  295. ]);
  296. const config = computed(() => {
  297. return [
  298. {
  299. attrs: {
  300. label: "图片",
  301. slot: "pic",
  302. align: "center",
  303. width: 80,
  304. },
  305. },
  306. {
  307. attrs: {
  308. label: "业务公司",
  309. prop: "companyName",
  310. width: 150,
  311. },
  312. },
  313. {
  314. attrs: {
  315. label: "产品分类",
  316. prop: "classifyName",
  317. "min-width": 200,
  318. },
  319. },
  320. {
  321. attrs: {
  322. label: "产品编码",
  323. prop: "customCode",
  324. width: 180,
  325. },
  326. },
  327. {
  328. attrs: {
  329. label: "产品名称",
  330. slot: "name",
  331. "min-width": 200,
  332. },
  333. },
  334. // {
  335. // attrs: {
  336. // label: "产品英文名",
  337. // prop: "nameEnglish",
  338. // "min-width": 120,
  339. // },
  340. // },
  341. // {
  342. // attrs: {
  343. // label: "产品规格",
  344. // prop: "spec",
  345. // width: 120,
  346. // },
  347. // },
  348. {
  349. attrs: {
  350. label: "尺寸 (cm)",
  351. slot: "size",
  352. width: 130,
  353. },
  354. },
  355. {
  356. attrs: {
  357. label: "颜色",
  358. prop: "color",
  359. width: 100,
  360. },
  361. },
  362. {
  363. attrs: {
  364. label: "净重",
  365. prop: "netWeight",
  366. width: 100,
  367. },
  368. render(val) {
  369. if (val) {
  370. return val + " kg";
  371. }
  372. },
  373. },
  374. {
  375. attrs: {
  376. label: "销售价",
  377. prop: "price",
  378. width: 100,
  379. },
  380. render(val) {
  381. return proxy.moneyFormat(val, 2);
  382. },
  383. },
  384. // {
  385. // attrs: {
  386. // label: "海关编码",
  387. // prop: "hsCode",
  388. // width: 100,
  389. // },
  390. // },
  391. {
  392. attrs: {
  393. label: "原材料编码",
  394. prop: "rawMaterialCode",
  395. width: 120,
  396. },
  397. },
  398. {
  399. attrs: {
  400. label: "原材料",
  401. prop: "rawMaterialName",
  402. "min-width": 300,
  403. },
  404. },
  405. {
  406. attrs: {
  407. label: "操作",
  408. width: "160",
  409. align: "center",
  410. fixed: "right",
  411. },
  412. renderHTML(row) {
  413. return [
  414. // {
  415. // attrs: {
  416. // label: "选择",
  417. // type: "primary",
  418. // text: true,
  419. // },
  420. // el: "button",
  421. // click() {
  422. // clickSelect(row);
  423. // },
  424. // }
  425. {
  426. attrs: {
  427. label: "BOM",
  428. type: "primary",
  429. text: true,
  430. },
  431. el: "button",
  432. click() {
  433. bomSetting(row);
  434. },
  435. },
  436. {
  437. attrs: {
  438. label: "修改",
  439. type: "primary",
  440. text: true,
  441. },
  442. el: "button",
  443. click() {
  444. getDtl(row);
  445. },
  446. },
  447. {
  448. attrs: {
  449. label: "删除",
  450. type: "danger",
  451. text: true,
  452. },
  453. el: "button",
  454. click() {
  455. proxy
  456. .msgConfirm()
  457. .then((res) => {
  458. proxy
  459. .post("/productInfo/delete", {
  460. id: row.id,
  461. })
  462. .then((res) => {
  463. proxy.msgTip("删除成功", 1);
  464. getList();
  465. });
  466. })
  467. .catch((err) => {});
  468. },
  469. },
  470. ];
  471. },
  472. },
  473. ];
  474. });
  475. const getPriceData = () => {
  476. if (
  477. formData.data["length"] &&
  478. formData.data.width &&
  479. formData.data.technologyId &&
  480. formData.data.rawMaterialId
  481. ) {
  482. proxy
  483. .post("/productInfo/getProductPrice", {
  484. id: formData.data.id || "",
  485. length: formData.data["length"],
  486. width: formData.data.width,
  487. technologyId: formData.data.technologyId,
  488. rawMaterialId: formData.data.rawMaterialId,
  489. })
  490. .then((res) => {
  491. formData.data.price = res.price;
  492. });
  493. }
  494. };
  495. const formData = reactive({
  496. data: {},
  497. bomData: {},
  498. });
  499. const formOption = reactive({
  500. disabled: false,
  501. inline: true,
  502. labelWidth: 100,
  503. itemWidth: 100,
  504. });
  505. const formDom = ref(null);
  506. const formConfig = computed(() => {
  507. return [
  508. {
  509. type: "title1",
  510. title: "基本信息",
  511. },
  512. {
  513. type: "treeSelect",
  514. prop: "companyId",
  515. label: "业务公司",
  516. data: treeDataOne.value,
  517. propsTreeLabel: "deptName",
  518. propsTreeValue: "deptId",
  519. itemWidth: 50,
  520. },
  521. {
  522. type: "treeSelect",
  523. prop: "productClassifyId",
  524. label: "产品分类",
  525. data: treeData.value,
  526. itemWidth: 50,
  527. disabled: false,
  528. },
  529. {
  530. type: "input",
  531. prop: "name",
  532. label: "产品名称",
  533. itemWidth: 50,
  534. disabled: false,
  535. },
  536. {
  537. type: "slot",
  538. slotName: "nameEnglish",
  539. label: "英文名",
  540. itemWidth: 50,
  541. },
  542. {
  543. type: "input",
  544. prop: "customCode",
  545. label: "产品编号",
  546. itemWidth: 50,
  547. disabled: false,
  548. },
  549. {
  550. type: "uploadImg",
  551. // listType: "picture-card",
  552. // limit: 1,
  553. // accept: ".gif, .jpeg, .jpg, .png",
  554. prop: "fileList",
  555. imgProp: "imageUrl",
  556. label: "产品缩略图",
  557. },
  558. {
  559. type: "slot",
  560. slotName: "productionFileOne",
  561. label: "产品原图",
  562. itemWidth: 100,
  563. },
  564. {
  565. type: "upload",
  566. listType: "text",
  567. accept: "",
  568. limit: 1,
  569. prop: "prodFileList",
  570. label: "生产文件",
  571. },
  572. // {
  573. // type: "slot",
  574. // slotName: "productionFile",
  575. // label: "生产文件",
  576. // itemWidth: 100,
  577. // },
  578. {
  579. type: "title1",
  580. title: "属性信息",
  581. },
  582. {
  583. type: "select",
  584. prop: "rawMaterialId",
  585. label: "原材料",
  586. itemWidth: 50,
  587. data: rawMaterialData.value,
  588. filterable: true,
  589. disabled: false,
  590. fn: (val) => {
  591. // let current = rawMaterialData.value.find((x) => x.value == val);
  592. // if (current) {
  593. // formData.data.price = Number(
  594. // parseFloat(
  595. // current["length"] * current.width * current.price
  596. // ).toFixed(2)
  597. // );
  598. // }
  599. getPriceData();
  600. },
  601. },
  602. {
  603. type: "number",
  604. prop: "price",
  605. label: "销售价",
  606. precision: 2,
  607. min: 0.01,
  608. controls: false,
  609. itemWidth: 50,
  610. disabled: true,
  611. },
  612. // {
  613. // type: "selectInput",
  614. // prop: "price",
  615. // selectProp: "currency",
  616. // label: "销售价",
  617. // itemWidth: 50,
  618. // disabledSelect: true,
  619. // data: currencyData.value,
  620. // disabled: true,
  621. // },
  622. {
  623. type: "select",
  624. prop: "technologyId",
  625. label: "生产工艺",
  626. itemWidth: 50,
  627. data: technologyData.value,
  628. filterable: true,
  629. disabled: false,
  630. fn: () => {
  631. getPriceData();
  632. },
  633. },
  634. // {
  635. // type: "input",
  636. // prop: "spec",
  637. // label: "规格型号",
  638. // itemWidth: 50,
  639. // disabled: false,
  640. // },
  641. {
  642. type: "input",
  643. prop: "color",
  644. label: "颜色",
  645. itemWidth: 50,
  646. disabled: false,
  647. },
  648. {
  649. type: "slot",
  650. slotName: "size",
  651. prop: "",
  652. label: "",
  653. itemWidth: 50,
  654. disabled: false,
  655. },
  656. // {
  657. // type: "select",
  658. // prop: "innerPackMethod",
  659. // label: "内包装方式",
  660. // required: true,
  661. // itemWidth: 50,
  662. // multiple: true,
  663. // data: innerMethon.value,
  664. // filterable: true,
  665. // placeholder: "内包装方式",
  666. // style: {
  667. // width: "100%",
  668. // },
  669. // disabled: false,
  670. // },
  671. // {
  672. // type: "select",
  673. // prop: "outerPackMethod",
  674. // label: "外包装方式",
  675. // required: true,
  676. // itemWidth: 50,
  677. // multiple: true,
  678. // data: outsideMethon.value,
  679. // filterable: true,
  680. // placeholder: "外包装方式",
  681. // style: {
  682. // width: "100%",
  683. // },
  684. // disabled: false,
  685. // },
  686. {
  687. type: "number",
  688. prop: "netWeight",
  689. label: "净重(kg)",
  690. precision: 2,
  691. min: 0,
  692. controls: false,
  693. itemWidth: 50,
  694. },
  695. {
  696. type: "input",
  697. prop: "hsCode",
  698. label: "海关编码",
  699. itemWidth: 50,
  700. disabled: false,
  701. },
  702. {
  703. type: "input",
  704. itemType: "textarea",
  705. prop: "remark",
  706. label: "备注",
  707. itemWidth: 100,
  708. },
  709. ];
  710. });
  711. const getList = (req) => {
  712. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  713. loading.value = true;
  714. proxy.post("/productInfo/page", sourceList.value.pagination).then(
  715. (res) => {
  716. sourceList.value.data = res.rows.map((x) => ({
  717. ...x,
  718. fileList: [],
  719. }));
  720. sourceList.value.pagination.total = res.total;
  721. setTimeout(() => {
  722. loading.value = false;
  723. }, 200);
  724. let productIdList = res.rows.map((x) => x.id);
  725. // 请求文件数据并回显
  726. if (productIdList.length > 0) {
  727. // proxy.getFile(productIdList, sourceList.value.data, "id");
  728. proxy
  729. .post("/fileInfo/getList", { businessIdList: productIdList })
  730. .then((fileObj) => {
  731. for (let i = 0; i < sourceList.value.data.length; i++) {
  732. const ele = sourceList.value.data[i];
  733. for (const key in fileObj) {
  734. if (
  735. ele.id == key &&
  736. fileObj[ele.id] &&
  737. fileObj[ele.id].length > 0
  738. ) {
  739. ele.fileList = fileObj[ele.id].filter(
  740. (x) => x.businessType == "0"
  741. );
  742. }
  743. }
  744. }
  745. });
  746. }
  747. },
  748. (err) => {
  749. loading.value = false;
  750. }
  751. );
  752. };
  753. const getDict = () => {
  754. proxy
  755. .get("/tenantDept/list", {
  756. pageNum: 1,
  757. pageSize: 9999,
  758. keyword: "",
  759. tenantId: proxy.useUserStore().user.tenantId,
  760. type: 0,
  761. })
  762. .then((res) => {
  763. companyData.value = res.data.map((x) => ({
  764. ...x,
  765. label: x.deptName,
  766. value: x.deptId,
  767. }));
  768. treeDataOne.value = proxy.handleTree(res.data, "deptId");
  769. });
  770. };
  771. getDict();
  772. const treeChange = (e) => {
  773. if (e.id != undefined) {
  774. sourceList.value.pagination.productClassifyId = e.id;
  775. getList({ productClassifyId: e.id });
  776. }
  777. };
  778. const openModal = () => {
  779. dialogVisible.value = true;
  780. modalType.value = "add";
  781. formData.data = {
  782. definition: "1",
  783. fileList: [],
  784. currency: "",
  785. prodFileList: [],
  786. };
  787. // if (currencyData.value && currencyData.value.length > 0) {
  788. // formData.data.currency = currencyData.value[0].dictKey;
  789. // }
  790. };
  791. const openExcel = () => {
  792. openExcelDialog.value = true;
  793. };
  794. const submitForm = () => {
  795. formDom.value.handleSubmit((valid) => {
  796. if (!formData.data.fileList.length > 0) {
  797. return proxy.msgTip("请上传图片", 2);
  798. }
  799. // formData.data.fileList = formData.data.fileList.map((x) => ({
  800. // id: x.id,
  801. // fileName: x.fileName,
  802. // fileUrl: x.fileUrl,
  803. // }));
  804. submitLoading.value = true;
  805. proxy.post("/productInfo/" + modalType.value, formData.data).then(
  806. (res) => {
  807. proxy.msgTip("操作成功", 1);
  808. dialogVisible.value = false;
  809. submitLoading.value = false;
  810. getList();
  811. },
  812. (err) => {
  813. submitLoading.value = false;
  814. }
  815. );
  816. });
  817. };
  818. const getTreeList = () => {
  819. proxy
  820. .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
  821. .then((message) => {
  822. treeListData.value = [
  823. {
  824. id: "",
  825. label: "全部",
  826. parentId: "",
  827. children: message,
  828. },
  829. ];
  830. treeData.value = message;
  831. });
  832. };
  833. const getTechnologyData = () => {
  834. proxy.post("/technology/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  835. technologyData.value = res.rows;
  836. });
  837. };
  838. const getDtl = (row) => {
  839. modalType.value = "edit";
  840. proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
  841. formData.data = res;
  842. formData.data.fileList = row.fileList.map((x) => ({
  843. ...x,
  844. url: x.fileUrl,
  845. name: x.fileName,
  846. }));
  847. if (formData.data.fileList.length > 0) {
  848. formData.data.imageUrl = formData.data.fileList[0].fileUrl;
  849. }
  850. proxy
  851. .post("/fileInfo/getList", { businessIdList: [row.id] })
  852. .then((fileObj) => {
  853. if (fileObj[row.id] && fileObj[row.id].length > 0) {
  854. formData.data.prodFileList = fileObj[row.id]
  855. .filter((x) => x.businessType == "2")
  856. .map((item) => {
  857. return {
  858. ...item,
  859. name: item.fileName,
  860. url: item.fileUrl,
  861. };
  862. });
  863. } else {
  864. formData.data.prodFileList = [];
  865. }
  866. });
  867. dialogVisible.value = true;
  868. });
  869. };
  870. const rawMaterialData = ref([]);
  871. const getRawMaterialData = () => {
  872. proxy.post("/productInfo/page", { productClassifyId: 100 }).then((res) => {
  873. rawMaterialData.value = res.rows.map((x) => ({
  874. ...x,
  875. label:
  876. x.name +
  877. "," +
  878. x.customCode +
  879. "," +
  880. `${x["length"]}*${x.width}*${x.height}(cm)` +
  881. "," +
  882. x.color,
  883. value: x.id,
  884. }));
  885. });
  886. };
  887. getRawMaterialData();
  888. const bomDialog = ref(false);
  889. const bomFormDom = ref(null);
  890. const bomFormOption = reactive({
  891. disabled: false,
  892. inline: true,
  893. labelWidth: 100,
  894. itemWidth: 100,
  895. });
  896. const bomFormConfig = computed(() => {
  897. return [
  898. // {
  899. // type: "title1",
  900. // title: "BOM 信息",
  901. // },
  902. // {
  903. // type: "select",
  904. // prop: "rawMaterialId",
  905. // label: "原材料",
  906. // itemWidth: 100,
  907. // data: rawMaterialData.value,
  908. // filterable: true,
  909. // disabled: false,
  910. // },
  911. // {
  912. // type: "slot",
  913. // slotName: "accessories",
  914. // label: "包材辅料",
  915. // itemWidth: 100,
  916. // },
  917. // {
  918. // type: "title1",
  919. // title: "生产工序",
  920. // },
  921. {
  922. type: "slot",
  923. slotName: "detail",
  924. label: "",
  925. },
  926. ];
  927. });
  928. const bomRules = ref({
  929. rawMaterialId: [
  930. { required: true, message: "请选择原材料", trigger: "change" },
  931. ],
  932. quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
  933. });
  934. const bomSetting = (row) => {
  935. bomDialog.value = true;
  936. proxy.post("/productBomInfo/detail", { id: row.id }).then((res) => {
  937. formData.bomData = {
  938. name: row.name,
  939. code: row.customCode,
  940. id: res.id,
  941. rawMaterialId: res.rawMaterialId,
  942. productBomDetailList: [],
  943. processesList: res.processesList,
  944. };
  945. if (res.productBomDetailList && res.productBomDetailList.length > 0) {
  946. formData.bomData.productBomDetailList = res.productBomDetailList.filter(
  947. (x) => x.type == 2
  948. );
  949. } else {
  950. formData.bomData.productBomDetailList = [];
  951. }
  952. });
  953. };
  954. const submitBomForm = () => {
  955. bomFormDom.value.handleSubmit((valid) => {
  956. if (!formData.bomData.productBomDetailList.length > 0) {
  957. return proxy.msgTip("请选择包材辅料", 2);
  958. }
  959. formData.bomData.productBomDetailList.push({
  960. materialId: formData.bomData.rawMaterialId,
  961. type: 1,
  962. quantity: 1,
  963. });
  964. submitLoading.value = true;
  965. proxy.post("/productBomInfo/edit", formData.bomData).then(
  966. (res) => {
  967. proxy.msgTip("操作成功", 1);
  968. getList();
  969. bomDialog.value = false;
  970. submitLoading.value = false;
  971. },
  972. (err) => {
  973. submitLoading.value = false;
  974. }
  975. );
  976. });
  977. };
  978. const openSelectMaterial = ref(false);
  979. const selectMaterial = (row) => {
  980. let flag = formData.bomData.productBomDetailList.some(
  981. (x) => x.materialId == row.id
  982. );
  983. if (!flag) {
  984. formData.bomData.productBomDetailList.push({
  985. type: 2,
  986. materialName: row.name,
  987. materialCode: row.customCode,
  988. materialId: row.id,
  989. quantity: null,
  990. });
  991. proxy.msgTip("选择成功");
  992. } else {
  993. proxy.msgTip("该物料已选择", 2);
  994. }
  995. };
  996. const handleRemove = (index) => {
  997. formData.bomData.productBomDetailList.splice(index, 1);
  998. };
  999. const handleClickFile = (file) => {
  1000. window.open(file.fileUrl, "_blank");
  1001. };
  1002. const handleProgress = () => {
  1003. excelLoading.value = true;
  1004. };
  1005. const handleError = (err) => {
  1006. proxy.msgTip(`${err},请重试`, 2);
  1007. openExcelDialog.value = false;
  1008. excelLoading.value = false;
  1009. };
  1010. const handleSuccess = (res) => {
  1011. if (res.code != 200) {
  1012. return proxy.msgTip(`${err},请重试`, 2);
  1013. } else {
  1014. proxy.msgTip(`导入成功`, 1);
  1015. openExcelDialog.value = false;
  1016. excelLoading.value = false;
  1017. getList();
  1018. }
  1019. };
  1020. const clickSelect = (item) => {
  1021. proxy.$emit("selectProduct", item);
  1022. };
  1023. const handleClickUpload = async (att, flag) => {
  1024. let res = null;
  1025. let path = "";
  1026. if (flag) {
  1027. proxy.msgTip("请稍后", 2);
  1028. res = await proxy.post("/fileService/createTempFolder");
  1029. if (res && res.path) {
  1030. formData.data[att] = res.path;
  1031. path = res.path;
  1032. }
  1033. } else {
  1034. path = formData.data[att];
  1035. }
  1036. let a = document.createElement("a");
  1037. a.href = "printer://" + "ftp://121.37.194.75/" + path + "/";
  1038. a.style.display = "none";
  1039. document.body.appendChild(a);
  1040. a.click();
  1041. document.body.removeChild(a);
  1042. };
  1043. getTechnologyData();
  1044. getTreeList();
  1045. getList();
  1046. const exportExcel = () => {
  1047. proxy.msgTip("正在导出,请稍后", 2);
  1048. proxy
  1049. .postTwo("/productInfo/exportExcel", sourceList.value.pagination)
  1050. .then((res) => {
  1051. proxy.downloadFile(res, "产品数据.xlsx");
  1052. });
  1053. };
  1054. </script>
  1055. <style lang="scss" scoped>
  1056. .box {
  1057. padding: 10px;
  1058. display: flex;
  1059. justify-content: space-between;
  1060. .tree {
  1061. width: 300px;
  1062. }
  1063. .content {
  1064. width: calc(100% - 310px);
  1065. }
  1066. }
  1067. .pic {
  1068. object-fit: contain;
  1069. width: 50px;
  1070. height: 50px;
  1071. cursor: pointer;
  1072. vertical-align: middle;
  1073. }
  1074. .table {
  1075. border-collapse: collapse;
  1076. border-spacing: 0;
  1077. td {
  1078. text-align: center;
  1079. padding: 2px 4px;
  1080. // padding: 5px 10px;
  1081. }
  1082. }
  1083. </style>