index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  1. <template>
  2. <div class="tenant">
  3. <!-- <Banner /> -->
  4. <div class="content">
  5. <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
  6. :selectConfig="selectConfig" :table-events="{
  7. //element talbe事件都能传
  8. select: select,
  9. }" :action-list="[
  10. {
  11. text: '添加订单',
  12. action: () => openModal('add'),
  13. },
  14. ]" @get-list="getList">
  15. <template #code="{ item }">
  16. <div style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
  17. {{ item.code }}
  18. </div>
  19. </template>
  20. <template #status="{ item }">
  21. <div style="cursor: pointer; color: #409eff" @click="handleClickStatus(item)">
  22. {{ dictValueLabel(item.status, statusData) }}
  23. </div>
  24. </template>
  25. <template #address="{ item }">
  26. <div>
  27. {{ item.countryName }}, {{ item.provinceName }} ,
  28. {{ item.cityName }}, {{ item.detailedAddress }}
  29. </div>
  30. </template>
  31. </byTable>
  32. </div>
  33. <el-dialog :title="modalType == 'add' ? '添加订单' : '调仓接收'" v-model="dialogVisible" width="80%" v-loading="loading">
  34. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
  35. <template #countryId>
  36. <div style="width:100%">
  37. <el-select v-model="formData.data.countryId" placeholder="国家" style="width:100%" @change="(val) => getCityData(val, '20', true)">
  38. <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id">
  39. </el-option>
  40. </el-select>
  41. </div>
  42. </template>
  43. <template #provinceId>
  44. <div style="width:100%">
  45. <selectCity placeholder="省/洲" @change="(val) => getCityData(val, '30', true)" addressId="provinceId" addressName="provinceName"
  46. v-model="formData.data" :data="provinceData">
  47. </selectCity>
  48. </div>
  49. </template>
  50. <template #cityId>
  51. <div style="width:100%">
  52. <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData">
  53. </selectCity>
  54. </div>
  55. </template>
  56. <template #products>
  57. <div style="width: 100%">
  58. <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px">
  59. 添加产品
  60. </el-button>
  61. <el-button type="primary" @click="openExcel = true" style="margin-bottom: 10px">
  62. excel导入
  63. </el-button>
  64. <el-table :data="formData.data.orderDetailsList" show-summary :summary-method="getSummaries">
  65. <el-table-column prop="productCode" label="产品编码" width="150" />
  66. <el-table-column prop="productName" label="产品名称" min-width="150" />
  67. <el-table-column prop="price" label="单价" width="150">
  68. <template #default="{ row, $index }">
  69. <el-form-item :prop="'orderDetailsList.' + $index + '.price'" :rules="rules.price" :inline-message="true">
  70. <el-input-number v-model="row.price" :precision="4" :controls="false" :min="0" @change="totalAmount" placeholder="请输入"
  71. onmousewheel="return false;" />
  72. </el-form-item>
  73. </template>
  74. </el-table-column>
  75. <el-table-column prop="quantity" label="数量" width="150">
  76. <template #default="{ row, $index }">
  77. <el-form-item :prop="'orderDetailsList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
  78. <el-input-number v-model="row.quantity" :precision="4" :controls="false" :min="0" @change="totalAmount" placeholder="请输入"
  79. onmousewheel="return false;" />
  80. </el-form-item>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="total" label="小计" width="120" />
  84. <el-table-column prop="remark" label="备注" min-width="200">
  85. <template #default="{ row, $index }">
  86. <el-form-item :prop="'orderDetailsList.' + $index + '.remark'" :rules="rules.remark" :inline-message="true">
  87. <el-input v-model="row.remark" placeholder="请输入" />
  88. </el-form-item>
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="zip" label="操作" width="60" fixed="right" align="center">
  92. <template #default="{ $index }">
  93. <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. </div>
  98. </template>
  99. </byForm>
  100. <template #footer>
  101. <el-button @click="dialogVisible = false" size="large">取 消</el-button>
  102. <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">
  103. 确 定
  104. </el-button>
  105. </template>
  106. </el-dialog>
  107. <el-dialog v-model="openExcel" title="excel导入" width="30%" append-to-body>
  108. <div v-loading="excelLoading">
  109. <div style="margin: 15px 0">
  110. <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
  111. </div>
  112. <el-upload :action="actionUrl + '/orderInfo/excelImport'" :headers="headers" :before-upload="useImportExcelStore().updateRequestHeaders"
  113. :on-success="handleSuccess" :on-progress="handleProgress" :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
  114. <el-button type="primary" plain>点击导入</el-button>
  115. </el-upload>
  116. </div>
  117. <template #footer>
  118. <el-button @click="openExcel = false" size="large">取 消</el-button>
  119. </template>
  120. </el-dialog>
  121. <el-dialog v-model="openProduct" title="选择产品" width="70%" append-to-body>
  122. <SelectProduct @handleSelect="handleSelect"></SelectProduct>
  123. <template #footer>
  124. <span class="dialog-footer">
  125. <el-button @click="openProduct = false">取消</el-button>
  126. </span>
  127. </template>
  128. </el-dialog>
  129. <el-dialog v-model="openDetails" title="订单详情" width="40%" append-to-body>
  130. <OrderDetails :orderData="formData.orderData" :key="formData.orderData.id"></OrderDetails>
  131. <template #footer>
  132. <span class="dialog-footer">
  133. <el-button @click="openDetails = false">取消</el-button>
  134. </span>
  135. </template>
  136. </el-dialog>
  137. <el-dialog :title="'查看'" v-model="recordDialog" width="900" destroy-on-close>
  138. <byForm :formConfig="recordFormConfig" :formOption="recordFormOption" v-model="recordFormData.data">
  139. <template #products>
  140. <div style="width: 100%">
  141. <el-table :data="recordFormData.data.list">
  142. <el-table-column prop="logisticsCompanyName" label="物流/快递公司" />
  143. <el-table-column prop="code" label="物流/快递单号" />
  144. <el-table-column prop="logisticsStatus" label="物流状态" width="100" :formatter="(row) => handleShowKdStatus(row.logisticsStatus)" />
  145. <el-table-column prop="createTime" label="创建时间" width="155" />
  146. <el-table-column label="操作" width="90" align="center">
  147. <template #default="{ row, $index }">
  148. <el-button type="primary" text @click="pushKdRoute(row)">查看</el-button>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. </div>
  153. </template>
  154. </byForm>
  155. <template #footer>
  156. <el-button @click="recordDialog = false" size="large">取 消</el-button>
  157. </template>
  158. </el-dialog>
  159. </div>
  160. </template>
  161. <script setup>
  162. /* eslint-disable vue/no-unused-components */
  163. import { ElMessage, ElMessageBox } from "element-plus";
  164. import byTable from "@/components/byTable/index";
  165. import byForm from "@/components/byForm/index";
  166. import { computed, defineComponent, ref } from "vue";
  167. import useUserStore from "@/store/modules/user";
  168. import SelectProduct from "@/components/WDLY/product/SelectProduct";
  169. import OrderDetails from "@/components/WDLY/order/details";
  170. import selectCity from "@/components/selectCity/index.vue";
  171. import useImportExcelStore from "@/store/modules/importExcel";
  172. const headers = computed(() => useImportExcelStore().requestHeaders);
  173. const actionUrl = import.meta.env.VITE_APP_BASE_API;
  174. const loading = ref(false);
  175. const submitLoading = ref(false);
  176. const sourceList = ref({
  177. data: [],
  178. pagination: {
  179. total: 3,
  180. pageNum: 1,
  181. pageSize: 10,
  182. },
  183. });
  184. let dialogVisible = ref(false);
  185. let openProduct = ref(false);
  186. let openDetails = ref(false);
  187. let roomDialogVisible = ref(false);
  188. let modalType = ref("add");
  189. let rules = ref({
  190. customerInfoId: [
  191. {
  192. required: true,
  193. message: "请选择客户",
  194. trigger: "change",
  195. },
  196. ],
  197. type: [
  198. {
  199. required: true,
  200. message: "请选择订单类型",
  201. trigger: "change",
  202. },
  203. ],
  204. // countryId: [
  205. // {
  206. // required: true,
  207. // message: "请选择国家",
  208. // trigger: "change",
  209. // },
  210. // ],
  211. // provinceId: [
  212. // {
  213. // required: true,
  214. // message: "请选择省/洲",
  215. // trigger: "change",
  216. // },
  217. // ],
  218. // cityId: [
  219. // {
  220. // required: true,
  221. // message: "请选择城市",
  222. // trigger: "change",
  223. // },
  224. // ],
  225. // contacts: [
  226. // {
  227. // required: true,
  228. // message: "请输入姓名",
  229. // trigger: "blur",
  230. // },
  231. // ],
  232. // phone: [
  233. // {
  234. // required: true,
  235. // message: "请输入联系电话",
  236. // trigger: "blur",
  237. // },
  238. // ],
  239. detailedAddress: [
  240. {
  241. required: true,
  242. message: "请输入详细地址",
  243. trigger: "blur",
  244. },
  245. ],
  246. price: [
  247. {
  248. required: true,
  249. message: "请输入单价",
  250. trigger: "blur",
  251. },
  252. ],
  253. quantity: [
  254. {
  255. required: true,
  256. message: "请输入数量",
  257. trigger: "blur",
  258. },
  259. ],
  260. });
  261. const { proxy } = getCurrentInstance();
  262. const statusData = [
  263. {
  264. label: "进行中",
  265. value: "1",
  266. },
  267. {
  268. label: "已完成",
  269. value: "2",
  270. },
  271. {
  272. label: "已取消",
  273. value: "3",
  274. },
  275. ];
  276. const selectConfig = reactive([
  277. {
  278. label: "订单类型",
  279. prop: "type",
  280. data: [],
  281. },
  282. {
  283. label: "订单状态",
  284. prop: "status",
  285. data: statusData,
  286. },
  287. ]);
  288. const config = computed(() => {
  289. return [
  290. {
  291. attrs: {
  292. label: "订单类型",
  293. prop: "type",
  294. },
  295. render(type) {
  296. return proxy.dictDataEcho(type, salesType.value);
  297. },
  298. },
  299. {
  300. attrs: {
  301. label: "订单编号",
  302. prop: "code",
  303. slot: "code",
  304. },
  305. },
  306. {
  307. attrs: {
  308. label: "客户名称",
  309. prop: "customerName",
  310. },
  311. },
  312. {
  313. attrs: {
  314. label: "订单金额",
  315. prop: "amountMoney",
  316. },
  317. render(money) {
  318. return proxy.moneyFormat(money, 4);
  319. },
  320. },
  321. {
  322. attrs: {
  323. label: "收件人",
  324. prop: "contacts",
  325. },
  326. },
  327. {
  328. attrs: {
  329. label: "联系电话",
  330. prop: "phone",
  331. },
  332. },
  333. {
  334. attrs: {
  335. label: "收件城市",
  336. prop: "address",
  337. slot: "address",
  338. },
  339. },
  340. {
  341. attrs: {
  342. label: "下单时间",
  343. prop: "createTime",
  344. },
  345. },
  346. {
  347. attrs: {
  348. label: "订单状态",
  349. prop: "status",
  350. slot: "status",
  351. },
  352. },
  353. {
  354. attrs: {
  355. label: "操作",
  356. width: "200",
  357. align: "right",
  358. },
  359. // 渲染 el-button,一般用在最后一列。
  360. renderHTML(row) {
  361. return [
  362. row.status == 1
  363. ? {
  364. attrs: {
  365. label: "结束",
  366. type: "primary",
  367. text: true,
  368. },
  369. el: "button",
  370. click() {
  371. getDtl(row, 2);
  372. },
  373. }
  374. : {},
  375. row.status == 1
  376. ? {
  377. attrs: {
  378. label: "取消",
  379. type: "primary",
  380. text: true,
  381. },
  382. el: "button",
  383. click() {
  384. getDtl(row, 3);
  385. },
  386. }
  387. : {},
  388. ];
  389. },
  390. },
  391. ];
  392. });
  393. let formData = reactive({
  394. data: {},
  395. treeData: [],
  396. orderData: {},
  397. });
  398. const formOption = reactive({
  399. inline: true,
  400. labelWidth: 100,
  401. itemWidth: 100,
  402. rules: [],
  403. });
  404. const byform = ref(null);
  405. const treeData = ref([]);
  406. const formConfig = reactive([
  407. {
  408. type: "select",
  409. prop: "customerInfoId",
  410. label: "客户名称",
  411. isLoad: {
  412. url: "/customer/page",
  413. req: {
  414. pageNum: 1,
  415. pageSize: 9999,
  416. },
  417. labelKey: "name",
  418. labelVal: "id",
  419. method: "post",
  420. resUrl: "rows",
  421. },
  422. style: {
  423. width: "31.5%",
  424. },
  425. },
  426. {
  427. type: "select",
  428. prop: "type",
  429. label: "订单类型",
  430. itemWidth: 100,
  431. data: [],
  432. style: {
  433. width: "31.5%",
  434. },
  435. },
  436. {
  437. type: "input",
  438. prop: "contacts",
  439. label: "收件人",
  440. itemWidth: 33.33,
  441. placeholder: "姓名",
  442. },
  443. {
  444. type: "input",
  445. prop: "phone",
  446. label: " ",
  447. itemWidth: 66,
  448. placeholder: "联系电话",
  449. style: {
  450. width: "48%",
  451. },
  452. },
  453. {
  454. type: "slot",
  455. slotName: "countryId",
  456. prop: "countryId",
  457. label: "地址",
  458. itemWidth: 33.33,
  459. },
  460. {
  461. type: "slot",
  462. slotName: "provinceId",
  463. label: " ",
  464. itemWidth: 33.33,
  465. },
  466. {
  467. type: "slot",
  468. slotName: "cityId",
  469. prop: "cityId",
  470. label: " ",
  471. itemWidth: 33.33,
  472. },
  473. {
  474. type: "input",
  475. itemType: "textarea",
  476. prop: "detailedAddress",
  477. },
  478. {
  479. type: "title",
  480. title: "订单明细",
  481. },
  482. {
  483. type: "slot",
  484. slotName: "products",
  485. },
  486. {
  487. type: "input",
  488. prop: "amountMoney",
  489. label: "订单金额",
  490. disabled: true,
  491. itemWidth: 20,
  492. },
  493. ]);
  494. const getList = async (req) => {
  495. sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  496. loading.value = true;
  497. proxy.post("/orderInfo/page", sourceList.value.pagination).then((message) => {
  498. sourceList.value.data = message.rows;
  499. sourceList.value.pagination.total = message.total;
  500. setTimeout(() => {
  501. loading.value = false;
  502. }, 200);
  503. });
  504. };
  505. const openModal = () => {
  506. dialogVisible.value = true;
  507. modalType.value = "add";
  508. formData.data = {
  509. orderDetailsList: [],
  510. countryId: "44",
  511. };
  512. getCityData(formData.data.countryId, "20");
  513. };
  514. const submitForm = () => {
  515. byform.value.handleSubmit((valid) => {
  516. const list = formData.data.orderDetailsList;
  517. if (!list.length > 0)
  518. return ElMessage({
  519. message: `请添加订单明细!`,
  520. type: "info",
  521. });
  522. for (let i = 0; i < list.length; i++) {
  523. const e = list[i];
  524. if (e.quantity == 0) {
  525. return ElMessage({
  526. message: `数量不能为0!`,
  527. type: "info",
  528. });
  529. }
  530. }
  531. submitLoading.value = true;
  532. proxy.post("/orderInfo/" + modalType.value, formData.data).then(
  533. (res) => {
  534. ElMessage({
  535. message: modalType.value == "add" ? "添加成功" : "编辑成功",
  536. type: "success",
  537. });
  538. dialogVisible.value = false;
  539. submitLoading.value = false;
  540. getList();
  541. },
  542. (err) => (submitLoading.value = false)
  543. );
  544. });
  545. };
  546. const getDtl = (row, status) => {
  547. const statusNmae = status == 2 ? "结束" : "取消";
  548. // 弹窗提示是否删除
  549. ElMessageBox.confirm(`您确定执行${statusNmae}操作吗?`, "提示", {
  550. confirmButtonText: "确定",
  551. cancelButtonText: "取消",
  552. type: "warning",
  553. }).then(() => {
  554. // 删除
  555. proxy
  556. .post("/orderInfo/edit", {
  557. id: row.id,
  558. status,
  559. })
  560. .then((res) => {
  561. ElMessage({
  562. message: "操作成功",
  563. type: "success",
  564. });
  565. getList();
  566. });
  567. });
  568. };
  569. const warehouseList = ref([]);
  570. const salesType = ref([]);
  571. const getDict = () => {
  572. proxy.getDict(["order_sales_type"]).then((res) => {
  573. salesType.value = res["order_sales_type"];
  574. formConfig[1].data = salesType.value.map((x) => ({
  575. label: x.dictValue,
  576. value: x.dictKey,
  577. }));
  578. selectConfig[0].data = salesType.value.map((x) => ({
  579. label: x.dictValue,
  580. value: x.dictKey,
  581. }));
  582. });
  583. };
  584. const countryData = ref([]);
  585. const provinceData = ref([]);
  586. const cityData = ref([]);
  587. const getCityData = (id, type, flag) => {
  588. proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
  589. if (type === "20") {
  590. provinceData.value = res;
  591. if (flag) {
  592. formData.data.provinceId = "";
  593. formData.data.provinceName = "";
  594. formData.data.cityId = "";
  595. formData.data.cityName = "";
  596. }
  597. } else if (type === "30") {
  598. cityData.value = res;
  599. if (flag) {
  600. formData.data.cityId = "";
  601. formData.data.cityName = "";
  602. }
  603. } else {
  604. countryData.value = res;
  605. }
  606. });
  607. };
  608. getCityData("0");
  609. getList();
  610. getDict();
  611. const totalAmount = () => {
  612. let sum = 0;
  613. for (let i = 0; i < formData.data.orderDetailsList.length; i++) {
  614. const e = formData.data.orderDetailsList[i];
  615. e.total = (e.price * 1000000 * e.quantity) / 1000000;
  616. sum += e.total;
  617. }
  618. formData.data.amountMoney = sum;
  619. };
  620. const handleSelect = (row) => {
  621. const flag = formData.data.orderDetailsList.some(
  622. (x) => x.productId === row.id
  623. );
  624. if (flag)
  625. return ElMessage({
  626. message: "该物品已选择",
  627. type: "info",
  628. });
  629. formData.data.orderDetailsList.push({
  630. productName: row.name,
  631. productCode: row.code,
  632. productId: row.id,
  633. total: "",
  634. quantity: null,
  635. price: null,
  636. });
  637. return ElMessage({
  638. message: "选择成功",
  639. type: "success",
  640. });
  641. };
  642. const handleRemove = (index) => {
  643. formData.data.orderDetailsList.splice(index, 1);
  644. totalAmount();
  645. return ElMessage({
  646. message: "删除成功",
  647. type: "success",
  648. });
  649. };
  650. const handleClickCode = (row) => {
  651. formData.orderData = row;
  652. openDetails.value = true;
  653. };
  654. const kdStatusData = ref([
  655. {
  656. label: "在途",
  657. value: "0",
  658. },
  659. {
  660. label: "揽收",
  661. value: "1",
  662. },
  663. {
  664. label: "疑难",
  665. value: "2",
  666. },
  667. {
  668. label: "签收",
  669. value: "3",
  670. },
  671. {
  672. label: "退签",
  673. value: "4",
  674. },
  675. {
  676. label: "派件",
  677. value: "5",
  678. },
  679. {
  680. label: "退回",
  681. value: "6",
  682. },
  683. {
  684. label: "转投",
  685. value: "7",
  686. },
  687. {
  688. label: "清关",
  689. value: "8",
  690. },
  691. {
  692. label: "拒签",
  693. value: "14",
  694. },
  695. {
  696. label: "完成",
  697. value: "15",
  698. },
  699. ]);
  700. const recordDialog = ref(false);
  701. const recordFormOption = reactive({
  702. disabled: false,
  703. inline: true,
  704. labelWidth: 100,
  705. itemWidth: 100,
  706. rules: [],
  707. });
  708. const recordFormConfig = reactive([
  709. {
  710. type: "title",
  711. title: "物流数据",
  712. },
  713. {
  714. type: "slot",
  715. slotName: "products",
  716. },
  717. ]);
  718. const recordFormData = reactive({
  719. data: {
  720. list: [],
  721. },
  722. });
  723. const handleClickStatus = (row) => {
  724. recordDialog.value = true;
  725. proxy.post("/orderInfo/getLogisticsInfo", { id: row.id }).then((res) => {
  726. recordFormData.data.list = res;
  727. });
  728. };
  729. const handleShowKdStatus = (status) => {
  730. const current = kdStatusData.value.find((x) => x.value === status);
  731. if (current && current.label) {
  732. return current.label;
  733. } else {
  734. return "异常";
  735. }
  736. };
  737. const pushKdRoute = (row) => {
  738. proxy.$router.push({
  739. name: "Logistics",
  740. query: {
  741. keyword: row.code,
  742. },
  743. });
  744. };
  745. const getSummaries = (param) => {
  746. const { columns, data } = param; //columns是每列的信息,data是每行的信息
  747. const sums = [];
  748. columns.forEach((column, index) => {
  749. if (index === 0) {
  750. sums[index] = "合计"; //此处是在index=0的这一列显示为“合计”
  751. return;
  752. }
  753. const values = data.map((item) => Number(item[column.property]));
  754. if (column.property === "quantity" || column.property === "total") {
  755. sums[index] = values.reduce((prev, curr) => {
  756. const value = Number(curr);
  757. if (!isNaN(value)) {
  758. return Number(parseFloat(prev + curr).toFixed(4));
  759. } else {
  760. return prev;
  761. }
  762. }, 0);
  763. sums[index];
  764. }
  765. });
  766. return sums;
  767. };
  768. const openExcel = ref(false);
  769. const excelLoading = ref(false);
  770. const downloadTemplate = () => {
  771. fetch("/static/SaleOrderImportTemplate.xlsx")
  772. .then((res) => res.blob())
  773. .then((res) => {
  774. const url = window.URL.createObjectURL(res);
  775. let filename = "销售订单导入模板.xlsx";
  776. const link = document.createElement("a");
  777. link.style.display = "none";
  778. link.href = url;
  779. link.setAttribute("download", filename);
  780. document.body.appendChild(link);
  781. link.click();
  782. });
  783. };
  784. const handleProgress = () => {
  785. excelLoading.value = true;
  786. };
  787. const handleSuccess = (res) => {
  788. if (res.code != 200) {
  789. excelLoading.value = false;
  790. return ElMessage({
  791. message: `${res.msg},请重试!`,
  792. type: "info",
  793. });
  794. } else {
  795. ElMessage({
  796. message: "导入成功!",
  797. type: "success",
  798. });
  799. if (res && res.data && res.data.length > 0) {
  800. formData.data.orderDetailsList = res.data.map((x) => ({
  801. productName: x.productName,
  802. productCode: x.productCustomCode,
  803. productId: x.bussinessId,
  804. total: "",
  805. quantity: x.count,
  806. price: x.price,
  807. remark: x.remark,
  808. }));
  809. totalAmount();
  810. }
  811. openExcel.value = false;
  812. excelLoading.value = false;
  813. }
  814. };
  815. const handleError = (err) => {
  816. ElMessage({
  817. message: `${err},请重试!`,
  818. type: "info",
  819. });
  820. openExcel.value = false;
  821. excelLoading.value = false;
  822. };
  823. </script>
  824. <style lang="scss" scoped>
  825. .tenant {
  826. padding: 20px;
  827. }
  828. </style>