index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  1. <template>
  2. <div class="pageIndexClass">
  3. <div class="content">
  4. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
  5. highlight-current-row :action-list="[
  6. ]" @get-list="getList">
  7. <template #pic="{item}">
  8. <div style="width: 100%">
  9. <img v-if="item.fileUrl" :src="item.fileUrl" class="pic" @click="openImg(item.fileUrl)" />
  10. </div>
  11. </template>
  12. <template #size="{ item }">
  13. <div>
  14. <span>{{ item.productLength }}</span>*
  15. <span>{{ item.productWidth }}</span>*
  16. <span>{{ item.productHeight }}</span>
  17. </div>
  18. </template>
  19. <template #accountPeriod="{item}">
  20. <div style="width:100%">
  21. <el-date-picker v-model="item.accountPeriod" type="month" placeholder="请选择" style="width: 100%" value-format="YYYY-MM"
  22. :disabled-date="disabledFn" :clearable="false" @change="(val)=>handleChangeAccountPeriod(val,item)" />
  23. </div>
  24. </template>
  25. <template #arrivalBatch="{item}">
  26. <div style="width:100%">
  27. <el-input v-model="item.arrivalBatch" placeholder=" " @change="(val)=>changeData(val,item)"></el-input>
  28. </div>
  29. </template>
  30. <template #adjustAmount="{item}">
  31. <div style="width:100%">
  32. <el-input-number v-model="item.adjustAmount" :placeholder="' '" onmousewheel="return false;" :precision="2" :controls="false" :min="0"
  33. @change="(val,)=>changeDataOne(row,item)" style="width:100%">
  34. </el-input-number>
  35. </div>
  36. </template>
  37. <template #diffRemark="{item}">
  38. <div style="width:100%">
  39. <el-input v-model="item.diffRemark" placeholder=" " @change="(val)=>changeDataOne(val,item)"></el-input>
  40. </div>
  41. </template>
  42. <template #diffFileList="{item,index}">
  43. <div style="width:100%">
  44. <el-upload :file-list="item.diffFileList" :action="uploadUrl" :data="item.uploadData" :limit="2" :list-type="'text'"
  45. :before-upload="(file)=>handleBeforeUpload(file,index)" :on-success="()=>handleFileSuccess(index)"
  46. :on-remove="(file)=>handleRemoveFileOne(file,index)" :on-preview="onPreviewFile" :on-exceed="()=>msgTip(`上传文件数量不可大于2`, 2)">
  47. <el-button type="primary" text>上传</el-button>
  48. </el-upload>
  49. </div>
  50. </template>
  51. </byTable>
  52. </div>
  53. <el-dialog title="其他入库" v-if="dialogVisible" v-model="dialogVisible" width="1200" v-loading="loadingDialog">
  54. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
  55. <template #details>
  56. <div style="width: 100%">
  57. <el-button type="primary" @click="openProduct = true" :disabled="['100','103'].includes(formData.data.type)">添加明细</el-button>
  58. <el-table :data="formData.data.list" style="width: 100%; margin-top: 16px">
  59. <el-table-column label="图片" width="70" align="center">
  60. <template #default="{ row, $index }">
  61. <div style="width: 100%">
  62. <img v-if="row.fileUrl" :src="row.fileUrl" class="pic" @click="handleClickFile(row.fileUrl)" />
  63. </div>
  64. </template>
  65. </el-table-column>
  66. <el-table-column prop="productCode" label="编码" width="160" />
  67. <el-table-column prop="productName" label="名称" min-width="220" />
  68. <el-table-column label="规格尺寸 (cm)" min-width="160">
  69. <template #default="{ row, $index }">
  70. <div style="width: 100%">
  71. {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
  72. </div>
  73. </template>
  74. </el-table-column>
  75. <!-- <el-table-column prop="productUnit" label="单位" width="100" :formatter="
  76. (row) => dictKeyValue(row.productUnit, materialUnitData)
  77. " /> -->
  78. <el-table-column label="入库数量" width="140">
  79. <template #default="{ row, $index }">
  80. <div style="width: 100%">
  81. <el-form-item :prop="'list.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" class="margin-b-0">
  82. <el-input-number v-model="row.quantity" placeholder="请输入数量" style="width: 100%" :precision="0" :controls="false" :min="1"
  83. onmousewheel="return false;" :disabled="['100','103'].includes(formData.data.type)" />
  84. </el-form-item>
  85. </div>
  86. </template>
  87. </el-table-column>
  88. <el-table-column align="center" label="操作" width="80" fixed="right" v-if="!['100','103'].includes(formData.data.type)">
  89. <template #default="{ row, $index }">
  90. <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. </template>
  96. </byForm>
  97. <template #footer>
  98. <el-button @click="dialogVisible = false" size="default">取 消</el-button>
  99. <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
  100. </template>
  101. </el-dialog>
  102. <el-dialog v-if="openProduct" v-model="openProduct" title="商品选择" width="90%" append-to-body>
  103. <SelectAllGood @selectGood="selectGood"></SelectAllGood>
  104. <!-- <SelectMaterial @selectMaterial="selectMaterial"></SelectMaterial> -->
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <script setup>
  109. import { computed, ref } from "vue";
  110. import byTable from "@/components/byTable/index";
  111. import byForm from "@/components/byForm/index";
  112. import { ElMessage } from "element-plus";
  113. import SelectAllGood from "@/components/product/SelectAllGood";
  114. // import SelectMaterial from "@/components/product/SelectMaterial.vue";
  115. import moment from "moment";
  116. const { proxy } = getCurrentInstance();
  117. const warehouseList = ref([]);
  118. const warehouseListOne = ref([]);
  119. const materialUnitData = computed(
  120. () => proxy.useUserStore().allDict["material_unit"]
  121. );
  122. const inBoundStatus = ref([
  123. {
  124. label: "待入库",
  125. value: 0,
  126. },
  127. {
  128. label: "部分入库",
  129. value: 1,
  130. },
  131. {
  132. label: "入库完成",
  133. value: 2,
  134. },
  135. ]);
  136. const inBoundReason = ref([
  137. {
  138. label: "借用归还",
  139. value: "100",
  140. },
  141. {
  142. label: "退料入库",
  143. value: "101",
  144. },
  145. {
  146. label: "废料入库",
  147. value: "102",
  148. },
  149. {
  150. label: "丢件寻回",
  151. value: "103",
  152. },
  153. {
  154. label: "超领归还",
  155. value: "108",
  156. },
  157. {
  158. label: "错领归还",
  159. value: "109",
  160. },
  161. {
  162. label: "其他入库",
  163. value: "110",
  164. },
  165. ]);
  166. const produceOrder = ref([]);
  167. const lendData = ref([]);
  168. const lendDataOne = ref([]);
  169. const sourceList = ref({
  170. data: [],
  171. pagination: {
  172. total: 0,
  173. pageNum: 1,
  174. pageSize: 10,
  175. keyword: "",
  176. warehouseId: "",
  177. type: "",
  178. opType: "1",
  179. beginTime: "",
  180. endTime: "",
  181. },
  182. });
  183. const loading = ref(false);
  184. const selectConfig = computed(() => {
  185. return [
  186. // {
  187. // label: "业务公司",
  188. // prop: "companyId",
  189. // data: proxy.useUserStore().allDict["list_company_data"],
  190. // },
  191. // {
  192. // label: "仓库名称",
  193. // prop: "warehouseId",
  194. // data: warehouseList.value,
  195. // },
  196. // {
  197. // label: "入库原因",
  198. // prop: "type",
  199. // data: inBoundReason.value,
  200. // },
  201. {
  202. type: "time",
  203. label: "入库时间",
  204. placeholder: "开始日期",
  205. prop: "beginTime",
  206. placeholderOne: "结束日期",
  207. propOne: "endTime",
  208. },
  209. ];
  210. });
  211. const config = computed(() => {
  212. return [
  213. {
  214. attrs: {
  215. label: "业务公司",
  216. prop: "companyName",
  217. width: 110,
  218. fixed: "left",
  219. },
  220. },
  221. {
  222. attrs: {
  223. label: "采购单号",
  224. prop: "purchaseCode",
  225. width: 140,
  226. fixed: "left",
  227. },
  228. },
  229. {
  230. attrs: {
  231. label: "供应商",
  232. prop: "supplierName",
  233. width: 150,
  234. fixed: "left",
  235. },
  236. },
  237. {
  238. attrs: {
  239. label: "到货日期",
  240. prop: "arrivalTime",
  241. width: 100,
  242. },
  243. render(val) {
  244. if (val) {
  245. return val.slice(0, 10);
  246. }
  247. },
  248. },
  249. {
  250. attrs: {
  251. label: "商品图片",
  252. slot: "pic",
  253. align: "center",
  254. width: 80,
  255. },
  256. },
  257. {
  258. attrs: {
  259. label: "商品编码",
  260. prop: "productCode",
  261. width: 190,
  262. },
  263. },
  264. {
  265. attrs: {
  266. label: "商品名称",
  267. prop: "productName",
  268. "min-width": 220,
  269. },
  270. },
  271. {
  272. attrs: {
  273. label: "规格尺寸 (cm)",
  274. slot: "size",
  275. width: 130,
  276. },
  277. },
  278. {
  279. attrs: {
  280. label: "单位",
  281. prop: "productUnit",
  282. width: 100,
  283. },
  284. },
  285. {
  286. attrs: {
  287. label: "到货数量",
  288. prop: "quantity",
  289. width: 100,
  290. },
  291. },
  292. {
  293. attrs: {
  294. label: "单价",
  295. prop: "price",
  296. width: 100,
  297. },
  298. },
  299. {
  300. attrs: {
  301. label: "金额",
  302. prop: "amount",
  303. width: 100,
  304. },
  305. },
  306. {
  307. attrs: {
  308. label: "实际入库数量",
  309. prop: "receiptQuantity",
  310. width: 110,
  311. },
  312. },
  313. {
  314. attrs: {
  315. label: "入库时间",
  316. prop: "actualInTime",
  317. width: 110,
  318. },
  319. },
  320. {
  321. attrs: {
  322. label: "入库状态",
  323. prop: "receiptStatus",
  324. width: 100,
  325. },
  326. render(val) {
  327. return proxy.dictValueLabel(val, inBoundStatus.value);
  328. },
  329. },
  330. {
  331. attrs: {
  332. label: "账期",
  333. prop: "accountPeriod",
  334. slot: "accountPeriod",
  335. width: 135,
  336. },
  337. },
  338. {
  339. attrs: {
  340. label: "批次",
  341. prop: "arrivalBatch",
  342. slot: "arrivalBatch",
  343. width: 130,
  344. },
  345. },
  346. {
  347. attrs: {
  348. label: "调整金额",
  349. prop: "adjustAmount",
  350. slot: "adjustAmount",
  351. width: 110,
  352. },
  353. },
  354. {
  355. attrs: {
  356. label: "结算金额",
  357. prop: "settleAmount",
  358. width: 100,
  359. },
  360. },
  361. {
  362. attrs: {
  363. label: "差异原因",
  364. prop: "diffRemark",
  365. slot: "diffRemark",
  366. width: 130,
  367. },
  368. },
  369. {
  370. attrs: {
  371. label: "差异附件",
  372. prop: "diffFileList",
  373. slot: "diffFileList",
  374. width: 230,
  375. },
  376. },
  377. ];
  378. });
  379. const getDict = () => {
  380. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  381. if (res.rows && res.rows.length > 0) {
  382. warehouseList.value = res.rows.map((item) => {
  383. return {
  384. label: item.name,
  385. value: item.id,
  386. };
  387. });
  388. }
  389. });
  390. proxy
  391. .post("produceOrder/page", {
  392. pageNum: 1,
  393. pageSize: 9999,
  394. neProduceStatus: "10,99",
  395. })
  396. .then((res) => {
  397. produceOrder.value = res.rows.map((x) => ({
  398. label: x.code,
  399. value: x.id,
  400. }));
  401. produceOrder.value.unshift({
  402. label: "无",
  403. value: -1,
  404. });
  405. });
  406. proxy
  407. .post("/stockJournal/page", {
  408. pageNum: 1,
  409. pageSize: 9999,
  410. isRestitution: 0,
  411. type: "3",
  412. })
  413. .then((res) => {
  414. lendData.value = res.rows.map((x) => ({
  415. label:
  416. x.code +
  417. " " +
  418. x.expectRestitutionTime.slice(0, 10) +
  419. " " +
  420. x.exWarehousePerson +
  421. " " +
  422. x.remarks,
  423. value: x.id,
  424. }));
  425. });
  426. proxy
  427. .post("/reportLossesDetails/page", {
  428. pageNum: 1,
  429. pageSize: 9999,
  430. type: "2",
  431. })
  432. .then((res) => {
  433. lendDataOne.value = res.rows.map((x) => ({
  434. ...x,
  435. label:
  436. // x.code +
  437. // " " +
  438. x.repoTime.slice(0, 10) + " " + x.respUserName + " 数量" + x.quantity,
  439. value: x.id,
  440. }));
  441. });
  442. };
  443. const getList = async (req) => {
  444. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  445. loading.value = true;
  446. proxy.post("/arrivalDetail/page", sourceList.value.pagination).then((res) => {
  447. sourceList.value.data = res.rows.map((x) => ({
  448. ...x,
  449. diffFileList: [],
  450. fileData: {},
  451. uploadData: {},
  452. }));
  453. sourceList.value.pagination.total = res.total;
  454. setTimeout(() => {
  455. loading.value = false;
  456. }, 200);
  457. const productIdList = res.rows.map((x) => x.productId);
  458. // 请求文件数据并回显
  459. if (productIdList.length > 0) {
  460. proxy.getFileData({
  461. businessIdList: productIdList,
  462. data: sourceList.value.data,
  463. att: "productId",
  464. businessType: "0",
  465. fileAtt: "fileList",
  466. filePathAtt: "fileUrl",
  467. });
  468. }
  469. const ids = res.rows.map((x) => x.id);
  470. // 请求文件数据并回显
  471. if (ids.length > 0) {
  472. proxy.getFileData({
  473. businessIdList: ids,
  474. data: sourceList.value.data,
  475. att: "id",
  476. businessType: "10",
  477. fileAtt: "diffFileList",
  478. filePathAtt: "fileUrl",
  479. });
  480. }
  481. });
  482. };
  483. getDict();
  484. getList();
  485. const dialogVisible = ref(false);
  486. const loadingDialog = ref(false);
  487. const submit = ref(null);
  488. const openProduct = ref(false);
  489. const formOption = reactive({
  490. inline: true,
  491. labelWidth: 100,
  492. itemWidth: 100,
  493. rules: [],
  494. });
  495. const formData = reactive({
  496. data: {},
  497. });
  498. const formConfig = computed(() => {
  499. return [
  500. {
  501. type: "title1",
  502. title: "基本信息",
  503. },
  504. {
  505. type: "treeSelect",
  506. prop: "companyId",
  507. label: "业务公司",
  508. data: proxy.useUserStore().allDict["tree_company_data"],
  509. propsTreeLabel: "deptName",
  510. propsTreeValue: "deptId",
  511. itemWidth: 50,
  512. fn: (val) => {
  513. proxy
  514. .post("/warehouse/page", {
  515. pageNum: 1,
  516. pageSize: 999,
  517. companyId: val,
  518. })
  519. .then((res) => {
  520. if (res.rows && res.rows.length > 0) {
  521. warehouseListOne.value = res.rows.map((item) => {
  522. return {
  523. label: item.name,
  524. value: item.id,
  525. };
  526. });
  527. }
  528. });
  529. },
  530. },
  531. {
  532. type: "select",
  533. prop: "warehouseId",
  534. label: "仓库名称",
  535. required: true,
  536. data: warehouseListOne.value,
  537. itemWidth: 50,
  538. },
  539. {
  540. type: "input",
  541. prop: "exWarehousePerson",
  542. label: "申请入库人",
  543. itemWidth: 50,
  544. },
  545. {
  546. type: "select",
  547. prop: "type",
  548. label: "入库原因",
  549. required: true,
  550. data: inBoundReason.value,
  551. fn: (val) => {
  552. formData.data.list = [];
  553. if (["101", "102", "108", "109", "110"].includes(val)) {
  554. formData.data.borrowId = "";
  555. formData.data.loseId = "";
  556. } else if (val == "103") {
  557. formData.data.borrowId = "";
  558. formData.data.prodOrderId = "";
  559. } else {
  560. formData.data.loseId = "";
  561. formData.data.prodOrderId = "";
  562. }
  563. },
  564. itemWidth: 50,
  565. },
  566. {
  567. type: "select",
  568. prop: "prodOrderId",
  569. label: "生产订单",
  570. data: produceOrder.value,
  571. filterable: true,
  572. itemWidth: 50,
  573. isShow: ["101", "102", "108", "109", "110"].includes(formData.data.type),
  574. },
  575. {
  576. type: "select",
  577. prop: "borrowId",
  578. label: "借出单",
  579. data: lendData.value,
  580. filterable: true,
  581. itemWidth: 50,
  582. isShow: formData.data.type == "100",
  583. fn: (val) => {
  584. if (val) {
  585. proxy.post("/stockJournal/detail", { id: val }).then((res) => {
  586. if (res.list && res.list.length < 1) {
  587. return;
  588. }
  589. let ids = res.list.map((x) => x.productId);
  590. formData.data.list = res.list.map((x) => ({
  591. fileUrl: "",
  592. productCode: x.productCode,
  593. productId: x.productId,
  594. productName: x.productName,
  595. productLength: x.productLength,
  596. productWidth: x.productWidth,
  597. productHeight: x.productHeight,
  598. quantity: x.quantity,
  599. }));
  600. proxy.getFileData({
  601. businessIdList: ids,
  602. data: formData.data.list,
  603. att: "productId",
  604. businessType: "0",
  605. fileAtt: "fileList",
  606. filePathAtt: "fileUrl",
  607. });
  608. });
  609. }
  610. },
  611. },
  612. {
  613. type: "select",
  614. prop: "loseId",
  615. label: "丢件单",
  616. data: lendDataOne.value,
  617. filterable: true,
  618. itemWidth: 50,
  619. isShow: formData.data.type == "103",
  620. fn: (val) => {
  621. const current = lendDataOne.value.find((x) => x.value == val);
  622. if (current && current.materialId) {
  623. let ids = [current.materialId];
  624. formData.data.list = [
  625. {
  626. fileUrl: "",
  627. productCode: current.materialCode,
  628. productId: current.materialId,
  629. productName: current.materialName,
  630. productLength: current.materialLength,
  631. productWidth: current.materialWidth,
  632. productHeight: current.materialHeight,
  633. quantity: current.quantity,
  634. },
  635. ];
  636. proxy.getFileData({
  637. businessIdList: ids,
  638. data: formData.data.list,
  639. att: "productId",
  640. businessType: "0",
  641. fileAtt: "fileList",
  642. filePathAtt: "fileUrl",
  643. });
  644. }
  645. },
  646. },
  647. {
  648. type: "input",
  649. itemType: "textarea",
  650. prop: "remarks",
  651. label: "备注",
  652. itemWidth: 100,
  653. },
  654. {
  655. type: "slot",
  656. slotName: "details",
  657. label: "入库明细",
  658. },
  659. ];
  660. });
  661. const rules = ref({
  662. companyId: [{ required: true, message: "请选择业务公司", trigger: "change" }],
  663. warehouseId: [{ required: true, message: "请选择仓库", trigger: "change" }],
  664. exWarehousePerson: [
  665. { required: true, message: "请输入领料人", trigger: "blur" },
  666. ],
  667. type: [{ required: true, message: "请选择入库原因", trigger: "change" }],
  668. prodOrderId: [
  669. { required: true, message: "请选择生产订单", trigger: "change" },
  670. ],
  671. borrowId: [
  672. { required: true, message: "请选择借用出库单", trigger: "change" },
  673. ],
  674. loseId: [{ required: true, message: "请选择丢件单", trigger: "change" }],
  675. quantity: [{ required: true, message: "请输入入库数量", trigger: "blur" }],
  676. remarks: [{ required: true, message: "请输入备注", trigger: "blur" }],
  677. });
  678. const openModal = () => {
  679. getDict();
  680. formData.data = {
  681. type: "",
  682. list: [],
  683. };
  684. loadingDialog.value = false;
  685. dialogVisible.value = true;
  686. };
  687. const pushGoods = (goods) => {
  688. if (goods && goods.length > 0) {
  689. let afterFiltering = [];
  690. if (formData.data.list && formData.data.list.length > 0) {
  691. afterFiltering = goods.filter((item) => {
  692. let data = formData.data.list.filter(
  693. (itemProduct) => itemProduct.productId === item.id
  694. );
  695. if (data && data.length > 0) {
  696. return false;
  697. }
  698. return true;
  699. });
  700. } else {
  701. afterFiltering = goods;
  702. }
  703. formData.data.list = formData.data.list.concat(
  704. afterFiltering.map((item) => {
  705. return {
  706. productCode: item.code,
  707. productId: item.id,
  708. productName: item.name,
  709. productSpec: item.spec,
  710. productUnit: item.unit,
  711. quantity: undefined,
  712. };
  713. })
  714. );
  715. ElMessage({
  716. message: "添加成功!",
  717. type: "success",
  718. });
  719. openProduct.value = false;
  720. } else {
  721. ElMessage("请选择至少一件产品");
  722. }
  723. };
  724. const selectMaterial = (row) => {
  725. let flag = formData.data.list.some((x) => x.productId == row.id);
  726. if (!flag) {
  727. formData.data.list.push({
  728. productCode: row.customCode,
  729. productId: row.id,
  730. productName: row.name,
  731. productSpec: row.spec,
  732. productUnit: row.unit,
  733. quantity: null,
  734. });
  735. proxy.msgTip("选择成功");
  736. } else {
  737. proxy.msgTip("该物料已选择", 2);
  738. }
  739. };
  740. const selectGood = (row) => {
  741. let fileUrl = "";
  742. if (row.fileList && row.fileList.length > 0) {
  743. fileUrl = row.fileList[0].fileUrl;
  744. }
  745. formData.data.list.push({
  746. fileUrl: fileUrl,
  747. productCode: row.customCode,
  748. productId: row.id,
  749. productName: row.name,
  750. productLength: row["length"],
  751. productWidth: row.width,
  752. productHeight: row.height,
  753. quantity: null,
  754. });
  755. proxy.msgTip("选择成功");
  756. };
  757. const submitForm = () => {
  758. submit.value.handleSubmit(() => {
  759. if (!(formData.data.list.length > 0)) {
  760. return proxy.msgTip("请添加入库明细");
  761. }
  762. loadingDialog.value = true;
  763. proxy.post("/stock/add", formData.data).then(
  764. () => {
  765. ElMessage({
  766. message: "提交成功",
  767. type: "success",
  768. });
  769. dialogVisible.value = false;
  770. getList();
  771. },
  772. (err) => {
  773. console.log(err);
  774. loadingDialog.value = false;
  775. }
  776. );
  777. });
  778. };
  779. const handleDelete = (index) => {
  780. formData.data.list.splice(index, 1);
  781. };
  782. const acquireSelectList = () => {
  783. let data = [];
  784. if (formData.data.list && formData.data.list.length > 0) {
  785. data = formData.data.list.map((item) => {
  786. return {
  787. id: item.productId,
  788. name: item.productName,
  789. };
  790. });
  791. }
  792. return data;
  793. };
  794. const handleClickFile = (fileUrl) => {
  795. window.open(fileUrl, "_blank");
  796. };
  797. const disabledFn = (date) => {
  798. // 当前日期
  799. let current = moment(date).format("YYYY-MM");
  800. // 禁用已选日期和比当前日期小的
  801. // return moment(current).add(1, "month").isBefore(moment());
  802. return moment(current).isAfter(moment());
  803. };
  804. const handleChangeAccountPeriod = (val, row) => {
  805. proxy
  806. .post("/arrivalDetail/editAccountPeriods", {
  807. id: row.id,
  808. accountPeriod: val,
  809. })
  810. .then(
  811. (res) => {
  812. // return proxy.msgTip("操作成功");
  813. },
  814. (err) => {}
  815. );
  816. };
  817. const changeData = (val, item) => {
  818. let data = {
  819. id: item.id,
  820. arrivalBatch: val,
  821. };
  822. proxy.post("/arrivalDetail/editArrivalBatch", data).then((res) => {});
  823. };
  824. const changeDataOne = (val, item) => {
  825. proxy.post("/arrivalDetail/edit", { ...item }).then((res) => {});
  826. };
  827. const handleBeforeUpload = async (file, index) => {
  828. const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
  829. file.id = res.id;
  830. file.fileUrl = res.fileUrl;
  831. sourceList.value.data[index].uploadData = res.uploadBody;
  832. sourceList.value.data[index].fileData = res;
  833. return true;
  834. };
  835. const handleFileSuccess = (index, att) => {
  836. if (
  837. sourceList.value.data[index].fileData &&
  838. sourceList.value.data[index].fileData.fileUrl
  839. ) {
  840. let file = sourceList.value.data[index].fileData;
  841. sourceList.value.data[index].diffFileList.push({
  842. id: file.id,
  843. fileName: file.fileName,
  844. name: file.fileName,
  845. url: file.fileUrl,
  846. fileUrl: file.fileUrl,
  847. });
  848. sourceList.value.data[index].fileData = {};
  849. proxy
  850. .post("/arrivalDetail/uploadDiffFile", {
  851. diffFileList: sourceList.value.data[index].diffFileList,
  852. id: sourceList.value.data[index].id,
  853. })
  854. .then((res) => {});
  855. }
  856. };
  857. const handleRemoveFileOne = (file, index) => {
  858. proxy
  859. .post("/arrivalDetail/uploadDiffFile", {
  860. diffFileList: sourceList.value.data[index].diffFileList,
  861. id: sourceList.value.data[index].id,
  862. })
  863. .then((res) => {});
  864. // let sonIndex = sourceList.value.data[index].diffFileList.findIndex(
  865. // (x) => x.id == file.id || x.id == file.raw.id
  866. // );
  867. // if (sonIndex > -1) {
  868. // sourceList.value.data[index].diffFileList.splice(sonIndex, 1);
  869. // proxy
  870. // .post("/arrivalDetail/uploadDiffFile", {
  871. // diffFileList: sourceList.value.data[index].diffFileList,
  872. // id: sourceList.value.data[index].id,
  873. // })
  874. // .then((res) => {});
  875. // }
  876. };
  877. const onPreviewFile = (file) => {
  878. if (file && file.fileUrl) {
  879. window.open(file.fileUrl, "_blank");
  880. } else {
  881. window.open(file.raw.fileUrl, "_blank");
  882. }
  883. };
  884. </script>
  885. <style lang="scss" scoped>
  886. .tenant {
  887. padding: 20px;
  888. }
  889. ::v-deep(.el-input-number .el-input__inner) {
  890. text-align: left;
  891. }
  892. </style>