index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. <template>
  2. <div class="user">
  3. <div class="tree">
  4. <treeList
  5. title="产品分类"
  6. submitType="1"
  7. :data="treeListData"
  8. v-model="sourceList.pagination.productClassifyId"
  9. @change="treeChange"
  10. @changeTreeList="getTreeList"
  11. >
  12. </treeList>
  13. </div>
  14. <div class="content">
  15. <byTable
  16. :source="sourceList.data"
  17. :pagination="sourceList.pagination"
  18. :config="config"
  19. :loading="loading"
  20. highlight-current-row
  21. :selectConfig="selectConfig"
  22. :table-events="{
  23. //element talbe事件都能传
  24. select: select,
  25. }"
  26. :action-list="[
  27. {
  28. text: 'Excel导入',
  29. action: () => openExcel(),
  30. disabled: false,
  31. },
  32. {
  33. text: '添加产品',
  34. action: () => openModal('add'),
  35. disabled: false,
  36. },
  37. ]"
  38. @get-list="getList"
  39. >
  40. <template #pic="{ item }">
  41. <div v-if="item.fileList.length > 0">
  42. <img
  43. :src="item.fileList[0].fileUrl"
  44. class="pic"
  45. @click="handleClickFile(item.fileList[0])"
  46. />
  47. </div>
  48. <div v-else></div>
  49. </template>
  50. </byTable>
  51. </div>
  52. <el-dialog
  53. :title="modalType == 'add' ? '添加' : '编辑'"
  54. v-model="dialogVisible"
  55. width="500"
  56. v-loading="loadingOne"
  57. >
  58. <byForm
  59. :formConfig="formConfig"
  60. :formOption="formOption"
  61. v-model="formData.data"
  62. :rules="rules"
  63. ref="byform"
  64. >
  65. <template #productPic>
  66. <div>
  67. <el-upload
  68. v-model:fileList="fileList"
  69. action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
  70. :data="uploadData"
  71. list-type="picture-card"
  72. :on-remove="handleRemove"
  73. :on-success="handleSuccess"
  74. :before-upload="handleBeforeUpload"
  75. accept=".gif, .jpeg, .jpg, .png"
  76. >
  77. <el-icon><Plus /></el-icon>
  78. </el-upload>
  79. </div>
  80. </template>
  81. <template #combination>
  82. <div>
  83. <div
  84. style="
  85. font-size: 14px;
  86. font-weight: bold;
  87. margin-bottom: 10px;
  88. color: #333333;
  89. "
  90. v-show="formData.data.combination == 1"
  91. >
  92. 组合明细
  93. </div>
  94. <el-button
  95. type="primary"
  96. @click="openProduct = true"
  97. style="margin-bottom: 10px"
  98. v-show="formData.data.combination == 1"
  99. >
  100. 添加
  101. </el-button>
  102. <el-table
  103. :data="formData.data.productCombinationList"
  104. v-show="formData.data.combination == 1"
  105. >
  106. <el-table-column prop="code" label="产品编码" />
  107. <el-table-column prop="name" label="产品名称" />
  108. <el-table-column
  109. prop="linkQuantity"
  110. label="组合数量"
  111. min-width="150"
  112. >
  113. <template #default="{ row, $index }">
  114. <el-form-item
  115. :prop="'productCombinationList.' + $index + '.linkQuantity'"
  116. :rules="rules.linkQuantity"
  117. :inline-message="true"
  118. >
  119. <el-input v-model="row.linkQuantity" placeholder="请输入" />
  120. </el-form-item>
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="zip" label="操作" width="100">
  124. <template #default="{ $index }">
  125. <el-button
  126. type="primary"
  127. link
  128. @click="handleRemoveProduct($index)"
  129. >删除</el-button
  130. >
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. </div>
  135. </template>
  136. <template #one>
  137. <div style="width: 100%">
  138. <el-row>
  139. <el-col :span="4">
  140. <el-input
  141. v-model="formData.data.victoriatouristJson.newProductsDay1"
  142. placeholder="请输入"
  143. disabled
  144. />
  145. </el-col>
  146. <el-col :span="1" style="text-align: center"> ~ </el-col>
  147. <el-col :span="4">
  148. <el-input
  149. v-model="formData.data.victoriatouristJson.newProductsDay"
  150. placeholder="请输入"
  151. @change="changeDay(10)"
  152. >
  153. </el-input>
  154. </el-col>
  155. <el-col :span="1" style="text-align: center"> : </el-col>
  156. <el-col :span="6">
  157. <el-input
  158. v-model="
  159. formData.data.victoriatouristJson.newProductsExpectedSales
  160. "
  161. placeholder="预期销量"
  162. />
  163. </el-col>
  164. </el-row>
  165. </div>
  166. </template>
  167. <template #two>
  168. <div style="width: 100%">
  169. <el-row>
  170. <el-col :span="4">
  171. <el-input
  172. v-model="formData.data.victoriatouristJson.growUpDay1"
  173. placeholder="请输入"
  174. disabled
  175. />
  176. </el-col>
  177. <el-col :span="1" style="text-align: center"> ~ </el-col>
  178. <el-col :span="4">
  179. <el-input
  180. v-model="formData.data.victoriatouristJson.growUpDay"
  181. placeholder="请输入"
  182. @change="changeDay(20)"
  183. >
  184. </el-input>
  185. </el-col>
  186. <el-col :span="1" style="text-align: center"> : </el-col>
  187. <el-col :span="6">
  188. <el-input
  189. v-model="
  190. formData.data.victoriatouristJson.growUpExpectedSales
  191. "
  192. placeholder="预期销量"
  193. />
  194. </el-col>
  195. </el-row>
  196. </div>
  197. </template>
  198. <template #three>
  199. <el-row style="width: 100%">
  200. <el-col :span="5">
  201. 大于{{ formData.data.victoriatouristJson.attDay }}天:
  202. </el-col>
  203. <el-col :span="6">
  204. <el-input
  205. v-model="formData.data.victoriatouristJson.matureExpectedSales"
  206. placeholder="预期销量"
  207. />
  208. </el-col>
  209. </el-row>
  210. </template>
  211. </byForm>
  212. <template #footer>
  213. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  214. <el-button
  215. type="primary"
  216. @click="submitForm('byform')"
  217. size="large"
  218. :loading="submitLoading"
  219. >
  220. 确 定
  221. </el-button>
  222. </template>
  223. </el-dialog>
  224. <el-dialog
  225. title="Excel导入"
  226. v-model="openExcelDialog"
  227. width="400"
  228. v-loading="loading"
  229. >
  230. <template #footer>
  231. <el-button @click="openExcelDialog = false" size="large"
  232. >取 消</el-button
  233. >
  234. <el-button
  235. type="primary"
  236. @click="submitExcel()"
  237. size="large"
  238. :loading="submitLoading"
  239. >
  240. 确 定
  241. </el-button>
  242. </template>
  243. </el-dialog>
  244. <el-dialog title="移交" v-model="moveDept" width="400" v-loading="loading">
  245. <div style="margin-bottom: 15px">请选择部门</div>
  246. <el-tree-select
  247. v-model="moveForm.deptId"
  248. :data="deptList"
  249. :render-after-expand="false"
  250. check-strictly
  251. :node-key="'deptId'"
  252. :props="defaultProps"
  253. />
  254. <template #footer>
  255. <el-button @click="moveDept = false">取 消</el-button>
  256. <el-button
  257. type="primary"
  258. @click="submitMove()"
  259. :loading="submitLoading"
  260. >
  261. 确 定
  262. </el-button>
  263. </template>
  264. </el-dialog>
  265. <el-dialog
  266. v-model="openProduct"
  267. title="选择产品"
  268. width="70%"
  269. append-to-body
  270. >
  271. <SelectProduct @handleSelect="handleSelect"></SelectProduct>
  272. <template #footer>
  273. <span class="dialog-footer">
  274. <el-button @click="openProduct = false">取消</el-button>
  275. </span>
  276. </template>
  277. </el-dialog>
  278. </div>
  279. </template>
  280. <script setup>
  281. /* eslint-disable vue/no-unused-components */
  282. import { ElMessage, ElMessageBox } from "element-plus";
  283. import byTable from "@/components/byTable/index";
  284. import byForm from "@/components/byForm/index";
  285. import treeList from "@/components/product/treeList";
  286. import SelectProduct from "@/components/WDLY/product/SelectProduct";
  287. import useUserStore from "@/store/modules/user";
  288. // 引入插件解决json.parse()会导致id值错误
  289. import { parse, stringify } from "lossless-json";
  290. import { computed, defineComponent, ref } from "vue";
  291. let openProduct = ref(false);
  292. const loading = ref(false);
  293. const loadingOne = ref(false);
  294. const submitLoading = ref(false);
  295. const sourceList = ref({
  296. data: [],
  297. pagination: {
  298. total: 3,
  299. pageNum: 1,
  300. pageSize: 10,
  301. type: "",
  302. productClassifyId: "",
  303. keyword: "",
  304. definition: "1",
  305. },
  306. });
  307. let dialogVisible = ref(false);
  308. let openExcelDialog = ref(false);
  309. let moveDept = ref(false);
  310. const deptIdCopy = ref("");
  311. let modalType = ref("add");
  312. let rules = ref({
  313. productClassifyId: [
  314. { required: true, message: "请选择产品分类", trigger: "change" },
  315. ],
  316. type: [{ required: true, message: "请选择产品类型", trigger: "change" }],
  317. name: [{ required: true, message: "请输入产品名称", trigger: "blur" }],
  318. unit: [{ required: true, message: "请选择单位", trigger: "change" }],
  319. linkQuantity: [
  320. { required: true, message: "请输入组合数量", trigger: "blur" },
  321. ],
  322. });
  323. const { proxy } = getCurrentInstance();
  324. const selectConfig = reactive([
  325. {
  326. label: "产品类型",
  327. prop: "type",
  328. data: [],
  329. },
  330. {
  331. label: "生命周期",
  332. prop: "lifeCycle",
  333. data: [
  334. {
  335. label: "新品",
  336. value: "1",
  337. },
  338. {
  339. label: "成长",
  340. value: "2",
  341. },
  342. {
  343. label: "成熟",
  344. value: "3",
  345. },
  346. ],
  347. },
  348. ]);
  349. const config = computed(() => {
  350. return [
  351. {
  352. attrs: {
  353. label: "产品类型",
  354. prop: "type",
  355. },
  356. render(type) {
  357. return proxy.dictDataEcho(type, productType.value);
  358. },
  359. },
  360. {
  361. attrs: {
  362. label: "产品编码",
  363. prop: "code",
  364. },
  365. },
  366. {
  367. attrs: {
  368. label: "产品名称",
  369. prop: "name",
  370. },
  371. },
  372. {
  373. attrs: {
  374. label: "图片",
  375. prop: "unit",
  376. slot: "pic",
  377. },
  378. },
  379. {
  380. attrs: {
  381. label: "单位",
  382. prop: "unit",
  383. },
  384. render(unit) {
  385. return proxy.dictDataEcho(unit, productUnit.value);
  386. },
  387. },
  388. {
  389. attrs: {
  390. label: "规格型号",
  391. prop: "spec",
  392. },
  393. },
  394. {
  395. attrs: {
  396. label: "管理部门",
  397. prop: "deptName",
  398. },
  399. },
  400. {
  401. attrs: {
  402. label: "生命周期",
  403. prop: "lifeCycle",
  404. },
  405. render(lifeCycle) {
  406. return lifeCycle == "1" ? "新品" : lifeCycle == "2" ? "成长" : "成熟";
  407. },
  408. },
  409. {
  410. attrs: {
  411. label: "京东供价",
  412. prop: "jdPurchasePrice",
  413. },
  414. },
  415. {
  416. attrs: {
  417. label: "标准售价",
  418. prop: "sellingPrice",
  419. },
  420. },
  421. {
  422. attrs: {
  423. label: "标准采购价",
  424. prop: "purchasePrice",
  425. },
  426. },
  427. {
  428. attrs: {
  429. label: "产品备注",
  430. prop: "remark",
  431. },
  432. },
  433. {
  434. attrs: {
  435. label: "操作",
  436. width: "200",
  437. align: "right",
  438. },
  439. // 渲染 el-button,一般用在最后一列。
  440. renderHTML(row) {
  441. return [
  442. {
  443. attrs: {
  444. label: "修改",
  445. type: "primary",
  446. text: true,
  447. },
  448. el: "button",
  449. click() {
  450. getDtl(row);
  451. },
  452. },
  453. {
  454. attrs: {
  455. label: "移交",
  456. type: "primary",
  457. text: true,
  458. },
  459. el: "button",
  460. click() {
  461. getDtlOne(row);
  462. },
  463. },
  464. {
  465. attrs: {
  466. label: "删除",
  467. type: "danger",
  468. text: true,
  469. },
  470. el: "button",
  471. click() {
  472. // 弹窗提示是否删除
  473. ElMessageBox.confirm(
  474. "此操作将永久删除该数据, 是否继续?",
  475. "提示",
  476. {
  477. confirmButtonText: "确定",
  478. cancelButtonText: "取消",
  479. type: "warning",
  480. }
  481. ).then(() => {
  482. // 删除
  483. proxy
  484. .post("/productInfo/delete", {
  485. id: row.id,
  486. })
  487. .then((res) => {
  488. ElMessage({
  489. message: "删除成功",
  490. type: "success",
  491. });
  492. getList();
  493. });
  494. });
  495. },
  496. },
  497. ];
  498. },
  499. },
  500. ];
  501. });
  502. const uploadData = ref({});
  503. const fileList = ref([]);
  504. const fileListCopy = ref([]);
  505. let formData = reactive({
  506. data: {},
  507. });
  508. const formOption = reactive({
  509. inline: true,
  510. labelWidth: 100,
  511. itemWidth: 100,
  512. rules: [],
  513. });
  514. const byform = ref(null);
  515. const treeListData = ref([]);
  516. const formConfig = computed(() => {
  517. return [
  518. {
  519. type: "treeSelect",
  520. prop: "productClassifyId",
  521. label: "产品分类",
  522. data: [],
  523. },
  524. {
  525. type: "select",
  526. prop: "type",
  527. label: "产品类型",
  528. required: true,
  529. data: [],
  530. },
  531. {
  532. type: "input",
  533. prop: "name",
  534. label: "产品名称",
  535. },
  536. {
  537. type: "input",
  538. prop: "spec",
  539. label: "规格型号",
  540. },
  541. {
  542. type: "select",
  543. prop: "unit",
  544. label: "单位",
  545. required: true,
  546. data: productUnit.value.map((x) => ({
  547. label: x.dictValue,
  548. value: x.dictKey,
  549. })),
  550. },
  551. {
  552. type: "slot",
  553. slotName: "productPic",
  554. prop: "fileList",
  555. label: "产品图片",
  556. },
  557. {
  558. type: "input",
  559. prop: "remark",
  560. label: "备注",
  561. itemType: "textarea",
  562. },
  563. {
  564. type: "radio",
  565. prop: "combination",
  566. label: "是否组合",
  567. required: true,
  568. border: true,
  569. data: [
  570. { label: "是", value: "1" },
  571. { label: "否", value: "0" },
  572. ],
  573. },
  574. {
  575. type: "json",
  576. prop: "victoriatouristJson",
  577. json: [
  578. {
  579. type: "input",
  580. prop: "jdPurchasePrice",
  581. label: "京东供价",
  582. itemWidth: 33,
  583. style: {
  584. width: "100%",
  585. "margin-right": "10px",
  586. },
  587. },
  588. {
  589. type: "input",
  590. prop: "sellingPrice",
  591. label: "标准售价",
  592. itemWidth: 33,
  593. },
  594. {
  595. type: "input",
  596. prop: "purchasePrice",
  597. label: "标准采购价",
  598. itemWidth: 33,
  599. },
  600. {
  601. type: "date",
  602. prop: "clearancePeriod",
  603. label: "库存清空期限",
  604. itemWidth: 50,
  605. format: "MM-DD",
  606. },
  607. ],
  608. },
  609. {
  610. type: "slot",
  611. slotName: "combination",
  612. label: "",
  613. },
  614. {
  615. type: "title",
  616. title: "生命周期规则",
  617. label: "",
  618. },
  619. {
  620. type: "slot",
  621. slotName: "one",
  622. label: "新品期",
  623. },
  624. {
  625. type: "slot",
  626. slotName: "two",
  627. label: "成长期",
  628. },
  629. {
  630. type: "slot",
  631. slotName: "three",
  632. label: "成熟期",
  633. },
  634. ];
  635. });
  636. const newPassword = () => {
  637. formData.data.password = generatePassword();
  638. };
  639. const generatePassword = () => {
  640. var length = 12,
  641. charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
  642. password = "";
  643. for (var i = 0, n = charset.length; i < length; ++i) {
  644. password += charset.charAt(Math.floor(Math.random() * n));
  645. }
  646. return password;
  647. };
  648. const getList = async (req) => {
  649. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  650. loading.value = true;
  651. proxy
  652. .post("/productInfo/pageByWdly", sourceList.value.pagination)
  653. .then((message) => {
  654. console.log(message);
  655. sourceList.value.data = message.rows.map((x) => ({
  656. ...x,
  657. fileList: [],
  658. ...JSON.parse(x.victoriatouristJson),
  659. }));
  660. sourceList.value.pagination.total = message.total;
  661. setTimeout(() => {
  662. loading.value = false;
  663. }, 200);
  664. const productIdList = message.rows.map((x) => x.id);
  665. // 请求文件数据并回显
  666. if (productIdList.length > 0) {
  667. proxy
  668. .post("/fileInfo/getList", { businessIdList: productIdList })
  669. .then((fileObj) => {
  670. for (let i = 0; i < sourceList.value.data.length; i++) {
  671. const e = sourceList.value.data[i];
  672. for (const key in fileObj) {
  673. if (e.id === key) {
  674. e.fileList = fileObj[key];
  675. }
  676. }
  677. }
  678. });
  679. }
  680. });
  681. };
  682. const treeChange = (e) => {
  683. sourceList.value.pagination.productClassifyId = e.id;
  684. getList({ productClassifyId: e.id });
  685. };
  686. const openModal = () => {
  687. dialogVisible.value = true;
  688. modalType.value = "add";
  689. formData.data = {
  690. definition: "1",
  691. // type: "1",
  692. fileList: [],
  693. combination: "1",
  694. victoriatouristJson: {
  695. combination: 1,
  696. newProductsDay1: 0,
  697. newProductsDay: 60,
  698. growUpDay1: 61,
  699. growUpDay: 120,
  700. attDay: 120,
  701. },
  702. productCombinationList: [],
  703. };
  704. fileList.value = [];
  705. fileListCopy.value = [];
  706. };
  707. const openExcel = () => {
  708. openExcelDialog.value = true;
  709. };
  710. const submitExcel = () => {
  711. openExcelDialog.value = false;
  712. };
  713. const TreetenantId = ref("");
  714. const selection = ref({
  715. data: [],
  716. });
  717. const select = (_selection, row) => {
  718. selection.value.data = _selection;
  719. console.log(_selection.length);
  720. };
  721. const tree = ref(null);
  722. let submitProductData = ref({});
  723. const submitForm = () => {
  724. byform.value.handleSubmit((valid) => {
  725. submitProductData.value = { ...formData.data };
  726. const list = formData.data.productCombinationList;
  727. let jsonObj = JSON.parse(formData.data.victoriatouristJson);
  728. if (formData.data.combination == 1) {
  729. if (!(list.length > 0)) {
  730. formData.data.victoriatouristJson = jsonObj;
  731. return ElMessage({
  732. message: "请添加组合明细",
  733. type: "info",
  734. });
  735. }
  736. }
  737. if (jsonObj.growUpDay <= Number(jsonObj.growUpDay1)) {
  738. formData.data.victoriatouristJson = jsonObj;
  739. return ElMessage({
  740. message: "生命周期规则输入有误!",
  741. type: "info",
  742. });
  743. }
  744. loadingOne.value = true;
  745. jsonObj.deptId = deptIdCopy.value;
  746. formData.data.victoriatouristJson = jsonObj;
  747. jsonObj.productCombinationList = list;
  748. jsonObj.combination = formData.data.combination;
  749. delete formData.data.productCombinationList;
  750. delete formData.data.combination;
  751. formData.data.victoriatouristJson = JSON.stringify(jsonObj);
  752. formData.data.fileList = fileListCopy.value.map((x) => ({
  753. id: x.id,
  754. fileName: x.fileName,
  755. }));
  756. submitLoading.value = true;
  757. let url =
  758. modalType.value == "add" ? "/productInfo/addByWdly" : "/productInfo/edit";
  759. proxy.post(url, formData.data).then(
  760. (res) => {
  761. ElMessage({
  762. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  763. type: "success",
  764. });
  765. dialogVisible.value = false;
  766. loadingOne.value = false;
  767. submitLoading.value = false;
  768. getList();
  769. },
  770. (err) => {
  771. formData.data = { ...submitProductData.value };
  772. formData.data.victoriatouristJson = JSON.parse(
  773. submitProductData.value.victoriatouristJson
  774. );
  775. loadingOne.value = false;
  776. submitLoading.value = false;
  777. }
  778. );
  779. });
  780. };
  781. const getTreeList = () => {
  782. proxy
  783. .post("/productClassify/tree", { parentId: "", name: "", definition: "1" })
  784. .then((message) => {
  785. treeListData.value = message;
  786. formConfig.value[0].data = message;
  787. });
  788. };
  789. const deptList = ref([]);
  790. const defaultProps = {
  791. children: "children",
  792. label: "deptName",
  793. };
  794. const getDept = () => {
  795. proxy
  796. .get("/tenantDept/list", {
  797. pageNum: 1,
  798. pageSize: 999,
  799. tenantId: useUserStore().user.tenantId,
  800. })
  801. .then((res) => {
  802. deptList.value = proxy.handleTree(res.data, "deptId");
  803. });
  804. };
  805. const getDtl = (row) => {
  806. modalType.value = "edit";
  807. proxy.post("/productInfo/detail", { id: row.id }).then((res) => {
  808. if (res.victoriatouristJson) {
  809. if (res.victoriatouristJson.deptId) {
  810. deptIdCopy.value = parse(res.victoriatouristJson).deptId.value;
  811. }
  812. }
  813. fileList.value = row.fileList.map((x) => ({ ...x, url: x.fileUrl }));
  814. fileListCopy.value = [...fileList.value];
  815. res.type = res.type + ""; //type回显
  816. res.definition = "1"; //产品
  817. res.victoriatouristJson = res.victoriatouristJson
  818. ? JSON.parse(res.victoriatouristJson)
  819. : {};
  820. res.combination = res.victoriatouristJson.combination
  821. ? res.victoriatouristJson.combination + ""
  822. : "0";
  823. res.productCombinationList = res.victoriatouristJson.productCombinationList;
  824. formData.data = res;
  825. dialogVisible.value = true;
  826. });
  827. };
  828. getTreeList();
  829. getDept();
  830. // getDict()
  831. getList();
  832. const handleBeforeUpload = async (file) => {
  833. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  834. uploadData.value = res.uploadBody;
  835. fileListCopy.value.push({
  836. id: res.id,
  837. fileName: res.fileName,
  838. path: res.fileUrl,
  839. url: res.fileUrl,
  840. uid: file.uid,
  841. });
  842. };
  843. const handleSuccess = (res, file, files) => {
  844. // 查当前file的index值去赋值对应的copy变量的值
  845. // let uid = file.uid;
  846. // const index = fileList.value.findIndex((x) => x.uid === uid);
  847. // fileListCopy.value[index].uid = uid;
  848. };
  849. const handleRemove = (file) => {
  850. const index = fileListCopy.value.findIndex(
  851. (x) => x.uid === file.uid || x.id === file.id
  852. );
  853. fileListCopy.value.splice(index, 1);
  854. };
  855. const handleClickFile = (file) => {
  856. window.open(file.fileUrl, "_blank");
  857. };
  858. const handleRemoveProduct = (index) => {
  859. formData.data.productCombinationList.splice(index, 1);
  860. return ElMessage({
  861. message: "删除成功!",
  862. type: "success",
  863. });
  864. };
  865. const pushGoods = (goods) => {
  866. const arr = goods.map((x) => ({
  867. linkProductId: x.id,
  868. linkQuantity: "",
  869. name: x.name,
  870. code: x.code,
  871. }));
  872. formData.data.productCombinationList =
  873. formData.data.productCombinationList.concat(arr);
  874. return ElMessage({
  875. message: "添加成功!",
  876. type: "success",
  877. });
  878. };
  879. const changeDay = (type) => {
  880. if (type == 10) {
  881. formData.data.victoriatouristJson.growUpDay1 =
  882. Number(formData.data.victoriatouristJson.newProductsDay) + 1;
  883. } else if (type == 20) {
  884. formData.data.victoriatouristJson.attDay = Number(
  885. formData.data.victoriatouristJson.growUpDay
  886. );
  887. }
  888. };
  889. const handleSelect = (row) => {
  890. const flag = formData.data.productCombinationList.some(
  891. (x) => x.linkProductId === row.id
  892. );
  893. if (flag)
  894. return ElMessage({
  895. message: "该产品已选择",
  896. type: "info",
  897. });
  898. const product = {
  899. linkProductId: row.id,
  900. linkQuantity: "",
  901. name: row.name,
  902. code: row.code,
  903. };
  904. formData.data.productCombinationList.push(product);
  905. return ElMessage({
  906. message: "选择成功",
  907. type: "success",
  908. });
  909. };
  910. let moveForm = ref({});
  911. let rowData = {};
  912. const getDtlOne = (row) => {
  913. moveForm.value.deptId = row.deptId ? row.deptId.toString() : "";
  914. moveDept.value = true;
  915. rowData = row;
  916. };
  917. const submitMove = () => {
  918. if (!moveForm.value.deptId) {
  919. return ElMessage({
  920. message: "请选择部门!",
  921. type: "info",
  922. });
  923. }
  924. proxy
  925. .post("/productInfo/transfer", {
  926. id: rowData.id,
  927. deptId: moveForm.value.deptId,
  928. })
  929. .then((res) => {
  930. ElMessage({
  931. message: "移交成功",
  932. type: "success",
  933. });
  934. getList();
  935. moveDept.value = false;
  936. });
  937. };
  938. const productUnit = ref([]);
  939. const productType = ref([]);
  940. const getDict = () => {
  941. proxy.getDict(["unit", "product_type"]).then((res) => {
  942. productUnit.value = res["unit"];
  943. productType.value = res["product_type"];
  944. formConfig.value[1].data = productType.value.map((x) => ({
  945. label: x.dictValue,
  946. value: x.dictKey,
  947. }));
  948. selectConfig[0].data = productType.value.map((x) => ({
  949. label: x.dictValue,
  950. value: x.dictKey,
  951. }));
  952. });
  953. };
  954. getDict();
  955. </script>
  956. <style lang="scss" scoped>
  957. .user {
  958. padding: 20px;
  959. display: flex;
  960. justify-content: space-between;
  961. .tree {
  962. width: 300px;
  963. }
  964. .content {
  965. width: calc(100% - 320px);
  966. }
  967. }
  968. .pic {
  969. object-fit: contain;
  970. width: 50px;
  971. height: 50px;
  972. cursor: pointer;
  973. vertical-align: middle;
  974. }
  975. :deep(.el-date-picker-header) {
  976. span:nth-child(3) {
  977. display: none !important;
  978. }
  979. button:nth-child(1) {
  980. display: none !important;
  981. }
  982. button:nth-child(5) {
  983. display: none !important;
  984. }
  985. }
  986. :deep(.el-date-picker__prev-btn .el-picker-panel__icon-btn) {
  987. display: none;
  988. }
  989. :deep(.el-date-picker__next-btn .el-picker-panel__icon-btn) {
  990. display: none;
  991. }
  992. :deep(.el-date-picker__header .el-date-picker__header-label) {
  993. display: none;
  994. }
  995. </style>