salesOrderDetails.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <template>
  2. <view style="padding-top: 1rpx;">
  3. <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="form" ref="form" labelWidth="150rpx"
  4. style="margin-top: 10rpx;padding-bottom: 130rpx;">
  5. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  6. <u-cell-group :border="false">
  7. <u-cell :border="false" center title="订货信息" arrow-direction="down">
  8. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  9. </u-cell>
  10. </u-cell-group>
  11. <view style="padding: 0 10rpx;">
  12. <u-form-item label="客户名称" prop="cname" borderBottom @click="selectCustomer">
  13. <u-input v-model="form.corpsName" inputAlign="right" border="none" placeholder="请选择" disabled
  14. disabledColor="#ffffff" />
  15. </u-form-item>
  16. <u-form-item label="订货日期" prop="cname" borderBottom
  17. @click="filterAll(['businesDate','businesDate'])">
  18. <u-input v-model="form.businesDate" inputAlign="right" border="none" disabled
  19. disabledColor="#ffffff" />
  20. </u-form-item>
  21. <u-form-item label="送货日期" prop="cname" borderBottom
  22. @click="filterAll(['requiredDeliveryDate','requiredDeliveryDate'])">
  23. <u-input v-model="form.requiredDeliveryDate" placeholder="请选择" inputAlign="right" border="none" disabled
  24. disabledColor="#ffffff" />
  25. </u-form-item>
  26. <u-form-item label="销售单号" prop="cname" borderBottom>
  27. <u-input v-model="form.sysNo" border="none" inputAlign="right" placeholder="请输入" disabled
  28. disabledColor="#ffffff" />
  29. </u-form-item>
  30. <u-form-item label="参考号" prop="cname" borderBottom>
  31. <u-input v-model="form.billNo" border="none" inputAlign="right" placeholder="请输入" :disabled="form.status != 6"
  32. disabledColor="#ffffff" />
  33. </u-form-item>
  34. </view>
  35. </view>
  36. <view
  37. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  38. <u-cell-group :border="false">
  39. <u-cell :border="false" center>
  40. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  41. <view slot="title">
  42. <view style="display: flex;">
  43. <view>产品列表({{form.orderItemsList.length}})</view>
  44. </view>
  45. </view>
  46. </u-cell>
  47. </u-cell-group>
  48. <view style="padding: 0 10rpx;">
  49. <u-cell v-for="(item,index) in form.orderItemsList" :key="index">
  50. <view slot="label">
  51. <u-row>
  52. <u-col span="2.9">
  53. <u--image :showLoading="true"
  54. :src="item.url?item.url:'https://td.echepei.com/file/applets/resources/parts/images/404.png'"
  55. width="80px" height="80px" radius="10">
  56. </u--image>
  57. </u-col>
  58. <u-col span="9.1">
  59. <view
  60. style="font-size: 36rpx;width: 530rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  61. {{item.cname}}
  62. </view>
  63. <view style="display: flex;justify-content: space-between;">
  64. <view style="color: #707070;">数量:{{item.storageInQuantity?parseFloat(item.storageInQuantity):''}}</view>
  65. <view v-if="form.confirmStatus == 0" style="color: #707070; color: red;"
  66. @click="deleteProduct(index)">
  67. <u-button type="error" size="mini" text="删除"></u-button>
  68. </view>
  69. </view>
  70. <view style="display: flex;justify-content: space-between;">
  71. <view style="color: #fd4b09;">批次号:</view>
  72. <u-input v-model="form.orderItemsList[index].lotNo" border="none" inputAlign="right" placeholder="请输入" :disabled="form.status != 6"
  73. disabledColor="#ffffff" />
  74. </view>
  75. </u-col>
  76. </u-row>
  77. </view>
  78. </u-cell>
  79. </view>
  80. </view>
  81. <view
  82. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  83. <u-cell-group :border="false">
  84. <u-cell :border="false" center title="图片信息" arrow-direction="down">
  85. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  86. <view slot="value">
  87. <view v-if="form.status == 2" @click.stop="saveAttachment"
  88. style="padding: 2rpx 20rpx;border:1rpx solid #FD4B09;border-radius: 100rpx;color: #FD4B09;">
  89. 保存
  90. </view>
  91. </view>
  92. </u-cell>
  93. </u-cell-group>
  94. <view style="padding: 0 10rpx;">
  95. <u-upload :fileList="fileList1" :disabled="!(form.status == 2)" :deletable="form.status == 2" @afterRead="afterRead"
  96. @delete="deletePic" name="1" multiple :maxCount="10"></u-upload>
  97. </view>
  98. </view>
  99. </u--form>
  100. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;" v-if="form.status == 2">
  101. <view style="width: 100%;display: flex;font-size: 24rpx;height: 80rpx;">
  102. <view @click="conserve"
  103. style="width: 100%;background-color: #FD4B09;display: grid;justify-items: center;height: 100%;">
  104. <u-icon name="checkmark" color="#fff"></u-icon>
  105. <view style="color: #fff;">确认发货</view>
  106. </view>
  107. <!-- <view
  108. style="width: 20%;display: grid;justify-items: center;padding: 10rpx 0;border-right: 1rpx solid #ccc;"
  109. @click="deleteDoc">
  110. <u-icon name="trash"></u-icon>
  111. <view>删除</view>
  112. </view>
  113. <view @click="copyDocument" style="width: 20%;display: grid;justify-items: center;">
  114. <u-icon name="file-text"></u-icon>
  115. <view>复制新增</view>
  116. </view>
  117. <view @click="conserve" v-if="form.confirmStatus == 0"
  118. style="width: 30%;background-color: #5ac725;display: grid;justify-items: center;">
  119. <u-icon name="edit-pen" color="#fff"></u-icon>
  120. <view style="color: #fff;">保存</view>
  121. </view>
  122. <view v-if="form.confirmStatus == 0" @click="submit(0)"
  123. style="width: 30%;background-color: #fd4b09;display: grid;justify-items: center;">
  124. <u-icon name="checkmark" color="#fff"></u-icon>
  125. <view style="color: #fff;">提交</view>
  126. </view>
  127. <view v-if="form.confirmStatus == 1" @click="submit(1)"
  128. style="width: 20%;background-color: #fd4b09;display: grid;justify-items: center;">
  129. <u-icon name="close" color="#fff"></u-icon>
  130. <view style="color: #fff;">撤销提交</view>
  131. </view> -->
  132. </view>
  133. </view>
  134. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
  135. @confirm="confirmTiem"></u-datetime-picker>
  136. <u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
  137. @confirm="showPicker"></u-picker>
  138. </view>
  139. </template>
  140. <script>
  141. import {
  142. quickBilling
  143. } from '@/api/views/sale/index.js'
  144. import {
  145. typeSave,
  146. removeFile,
  147. submitApp,
  148. remind,
  149. confirm,
  150. revoke,
  151. removeItem,
  152. removeId,
  153. copyOrder,
  154. collectPayment,
  155. saveAtta,
  156. confirmReceipt
  157. } from '@/api/views/sale/salesOrderDetails.js'
  158. import http from '@/http/api.js'
  159. import {
  160. clientId,
  161. clientSecret
  162. } from '@/common/setting'
  163. import {
  164. dateFormat
  165. } from '@/common/dateFormat'
  166. export default {
  167. data() {
  168. return {
  169. form: {
  170. orderItemsList: []
  171. },
  172. datetime: Number(new Date()),
  173. timeOpen: false,
  174. fileList1: [],
  175. screen: [],
  176. showOpen: false,
  177. columns: [],
  178. amountNumber: {
  179. deliveryAll: 0,
  180. cost: 0,
  181. grossProfit: 0,
  182. delivery: 0,
  183. saleAll: 0,
  184. amount: 0
  185. }
  186. }
  187. },
  188. onLoad(data) {
  189. this.refresh(data.id)
  190. },
  191. methods: {
  192. receipt() {
  193. let this_ = this
  194. if (this_.fileList1.length == 0) return uni.showToast({
  195. icon: "none",
  196. title: '请完善图片信息',
  197. mask: true
  198. });
  199. uni.showModal({
  200. title: '提示',
  201. content: "是否确认发货",
  202. success: function(rest) {
  203. if (rest.confirm == true) {
  204. uni.showLoading({
  205. title: '加载中',
  206. mask: true
  207. });
  208. confirmReceipt({
  209. id: this_.form.id,
  210. billStatus: 2
  211. }).then(res => {
  212. uni.showToast({
  213. icon: "none",
  214. title: '发货成功',
  215. mask: true
  216. });
  217. setTimeout(function() {
  218. // uni.hideLoading();
  219. this_.refresh(this_.form.id)
  220. }, 1000);
  221. }).catch(() => {
  222. uni.hideLoading();
  223. })
  224. }
  225. }
  226. })
  227. },
  228. newCompany() {
  229. uni.$u.route('/pages/views/product/createCompany', {
  230. code: "account",
  231. title: "收款账户"
  232. });
  233. },
  234. calculationContract() {
  235. let data = {
  236. purchaseAmount: this.form.purchaseAmount ? Number(this.form.purchaseAmount) : 0,
  237. thisUsedProfit: this.form.thisUsedProfit ? Number(this.form.thisUsedProfit) : 0
  238. }
  239. this.form.orderAmount = data.purchaseAmount - data.thisUsedProfit
  240. },
  241. getMap() {
  242. let this_ = this
  243. uni.chooseLocation({
  244. success: function(res) {
  245. this_.$set(this_.form, "arrivalAddress", res.address)
  246. }
  247. });
  248. },
  249. copyDocument() {
  250. let form = {
  251. ...this.form,
  252. orderFilesList: this.fileList1
  253. }
  254. if (form.orderFilesList.length > 0) {
  255. form.orderFilesList.forEach(item => delete item.status)
  256. }
  257. let this_ = this
  258. uni.showModal({
  259. title: '提示',
  260. content: "是否确认复制新增",
  261. success: function(rest) {
  262. if (rest.confirm == true) {
  263. uni.showLoading({
  264. title: '加载中',
  265. mask: true
  266. });
  267. copyOrder(form).then(res => {
  268. uni.hideLoading();
  269. uni.showToast({
  270. icon: "none",
  271. title: '复制新增成功',
  272. mask: true
  273. });
  274. this_.form = res.data
  275. this_.fileList1 = res.data.orderFilesList
  276. this_.amountNumber = {
  277. deliveryAll: 0, //送货总数量
  278. cost: 0, //成本
  279. grossProfit: 0, //毛利
  280. delivery: 0, //送货
  281. saleAll: 0, //销售数量
  282. amount: 0
  283. }
  284. for (let item of this_.form.orderItemsList) {
  285. this_.amountNumber.saleAll += Number(item.storageInQuantity)
  286. this_.amountNumber.cost += Number(item.storageInQuantity) * Number(
  287. item.purchasePrice)
  288. this_.amountNumber.delivery += Number(item.actualQuantity)
  289. this_.amountNumber.deliveryAll += Number(item.actualQuantity)
  290. this_.amountNumber.amount += Number(item.amount)
  291. this_.amountNumber.grossProfit += Number(item.amount) - (item
  292. .purchasePrice ? Number(item.storageInQuantity) * Number(
  293. item.purchasePrice) : 0)
  294. }
  295. this.form.purchaseAmount = this.amountNumber.amount
  296. })
  297. }
  298. }
  299. })
  300. },
  301. deleteDoc() {
  302. if (this.form.id) {
  303. let this_ = this
  304. if (this_.form.confirmStatus == 1) {
  305. return uni.showToast({
  306. icon: "none",
  307. title: '禁止删除',
  308. mask: true
  309. });
  310. }
  311. uni.showModal({
  312. title: '提示',
  313. content: "是否确认删除",
  314. success: function(rest) {
  315. if (rest.confirm == true) {
  316. removeId({
  317. id: this_.form.id
  318. }).then(res => {
  319. uni.showToast({
  320. icon: "none",
  321. title: '删除成功',
  322. mask: true
  323. });
  324. setTimeout(function() {
  325. uni.navigateBack()
  326. }, 1000);
  327. })
  328. }
  329. }
  330. })
  331. } else {
  332. uni.showToast({
  333. icon: "none",
  334. title: '未保存',
  335. mask: true
  336. });
  337. }
  338. },
  339. deleteProduct(index) {
  340. let this_ = this
  341. if (this_.form.orderItemsList[index].id) {
  342. uni.showModal({
  343. title: '提示',
  344. content: "是否确认删除",
  345. success: function(rest) {
  346. if (rest.confirm == true) {
  347. uni.showLoading({
  348. title: '加载中',
  349. mask: true
  350. });
  351. removeItem({
  352. itemId: this_.form.orderItemsList[index].id
  353. }).then(res => {
  354. uni.hideLoading();
  355. uni.showToast({
  356. icon: "none",
  357. title: '删除成功',
  358. mask: true
  359. });
  360. this_.form.orderItemsList.splice(index, 1)
  361. }).catch(err => {
  362. uni.hideLoading();
  363. })
  364. }
  365. }
  366. })
  367. } else {
  368. this_.form.orderItemsList.splice(index, 1)
  369. }
  370. },
  371. //时间确认选择
  372. confirmTiem(e) {
  373. this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  374. this.timeOpen = false
  375. },
  376. // 下拉选择
  377. showPicker(e) {
  378. this.form[this.screen[1]] = e.value[0].dictValue
  379. this.showOpen = false
  380. },
  381. //集合筛选条件
  382. filterAll(screen) {
  383. if (screen[1] !== "requiredDeliveryDate") return uni.showToast({
  384. icon: "none",
  385. title: '禁止操作',
  386. mask: true
  387. });
  388. if (this.form.status != 6) return uni.showToast({
  389. icon: "none",
  390. title: '禁止操作',
  391. mask: true
  392. });
  393. this.screen = screen
  394. switch (screen[1]) {
  395. case "businesDate":
  396. this.timeOpen = true
  397. break;
  398. case "requiredDeliveryDate":
  399. this.timeOpen = true
  400. break;
  401. case "advanceCollectionDate":
  402. this.timeOpen = true
  403. break;
  404. case "account":
  405. this.$u.api.getWorkDicts('account').then(res => {
  406. this.columns = [res.data]
  407. this.showOpen = true
  408. })
  409. break;
  410. case "settlmentAmount":
  411. uni.$u.route('/pages/views/salesSlip/collectionList', this.form);
  412. break;
  413. }
  414. },
  415. refresh(id) {
  416. uni.showLoading({
  417. title: '加载中',
  418. mask: true
  419. });
  420. typeSave({
  421. id: id
  422. }).then(res => {
  423. this.form = res.data
  424. this.fileList1 = res.data.orderFilesList
  425. this.amountNumber = {
  426. deliveryAll: 0, //送货总数量
  427. cost: 0, //成本
  428. grossProfit: 0, //毛利
  429. delivery: 0, //送货
  430. saleAll: 0, //销售数量
  431. amount: 0
  432. }
  433. for (let item of this.form.orderItemsList) {
  434. this.amountNumber.saleAll += Number(item.storageInQuantity)
  435. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  436. this.amountNumber.delivery += Number(item.actualQuantity)
  437. this.amountNumber.deliveryAll += Number(item.actualQuantity)
  438. this.amountNumber.amount += Number(item.amount)
  439. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  440. .storageInQuantity) * Number(item.purchasePrice) : 0)
  441. }
  442. this.form.purchaseAmount = this.amountNumber.amount
  443. setTimeout(function() {
  444. uni.hideLoading();
  445. }, 500);
  446. })
  447. },
  448. //确认收款
  449. confirmReceipt() {
  450. let this_ = this
  451. let form = {
  452. ...this_.form,
  453. orderFilesList: this_.fileList1
  454. }
  455. if (form.orderFilesList.length > 0) {
  456. form.orderFilesList.forEach(item => delete item.status)
  457. }
  458. if (!form.currentAmount) {
  459. return uni.showToast({
  460. icon: "none",
  461. title: '本次收款金额不能为空',
  462. mask: true,
  463. duration: 2000
  464. });
  465. }
  466. if (!form.account) {
  467. return uni.showToast({
  468. icon: "none",
  469. title: '未选择收款账户',
  470. mask: true,
  471. duration: 2000
  472. });
  473. }
  474. uni.showModal({
  475. title: '是否确认收款',
  476. content: '本次收款金额' + form.currentAmount,
  477. success: function(rest) {
  478. if (rest.confirm == true) {
  479. uni.showLoading({
  480. title: '加载中',
  481. mask: true
  482. });
  483. collectPayment(form).then(res => {
  484. uni.showToast({
  485. icon: "none",
  486. title: '收款成功',
  487. mask: true,
  488. duration: 2000
  489. });
  490. setTimeout(function() {
  491. uni.hideLoading();
  492. this_.refresh(res.data.id)
  493. }, 1000);
  494. })
  495. }
  496. }
  497. })
  498. },
  499. //保存附件
  500. saveAttachment() {
  501. let form = {
  502. pid: this.form.id,
  503. orderFilesList: this.fileList1
  504. }
  505. if (form.orderFilesList.length > 0) {
  506. form.orderFilesList.forEach(item => delete item.status)
  507. }
  508. uni.showLoading({
  509. title: '加载中',
  510. mask: true
  511. });
  512. saveAtta(form).then(res => {
  513. uni.showToast({
  514. icon: "none",
  515. title: '保存成功',
  516. mask: true
  517. });
  518. let _this = this
  519. setTimeout(function() {
  520. uni.hideLoading();
  521. _this.refresh(res.data.id)
  522. }, 1000);
  523. })
  524. },
  525. //保存
  526. conserve() {
  527. let form = {
  528. ...this.form,
  529. billStatus:2,
  530. orderFilesList: this.fileList1
  531. }
  532. if (form.orderFilesList.length > 0) {
  533. form.orderFilesList.forEach(item => delete item.status)
  534. }
  535. uni.showLoading({
  536. title: '发货中',
  537. mask: true
  538. });
  539. quickBilling(form).then(res => {
  540. uni.showToast({
  541. icon: "none",
  542. title: '发货成功',
  543. mask: true
  544. });
  545. let _this = this
  546. setTimeout(function() {
  547. uni.hideLoading();
  548. _this.refresh(res.data.id)
  549. }, 1000);
  550. })
  551. },
  552. //提交
  553. submit(type) {
  554. let form = {
  555. ...this.form,
  556. orderFilesList: this.fileList1
  557. }
  558. let this_ = this
  559. uni.showLoading({
  560. title: '提交中',
  561. mask: true
  562. });
  563. if (type == 0) {
  564. remind(form).then(res => {
  565. uni.hideLoading();
  566. if (res.data) {
  567. uni.showModal({
  568. title: '提示',
  569. content: res.data,
  570. success: function(rest) {
  571. if (rest.confirm == true) {
  572. uni.showLoading({
  573. title: '提交中',
  574. mask: true
  575. });
  576. confirm(form).then(resth => {
  577. uni.showToast({
  578. icon: "none",
  579. title: '提交成功',
  580. mask: true
  581. });
  582. setTimeout(function() {
  583. // uni.hideLoading();
  584. this_.refresh(resth.data.id)
  585. }, 1000);
  586. })
  587. }
  588. }
  589. })
  590. } else {
  591. uni.showLoading({
  592. title: '提交中',
  593. mask: true
  594. });
  595. confirm(form).then(rest => {
  596. uni.showToast({
  597. icon: "none",
  598. title: '提交成功',
  599. mask: true
  600. });
  601. setTimeout(function() {
  602. uni.hideLoading();
  603. this_.refresh(rest.data.id)
  604. }, 1000);
  605. })
  606. }
  607. })
  608. } else if (type == 1) {
  609. revoke(form).then(res => {
  610. uni.showToast({
  611. icon: "none",
  612. title: '撤销成功',
  613. mask: true
  614. });
  615. setTimeout(function() {
  616. uni.hideLoading();
  617. this_.refresh(res.data.id)
  618. }, 1000);
  619. })
  620. }
  621. },
  622. //客户选择返回触发
  623. otherFun(customer) {
  624. this.form.corpsName = customer.cname
  625. this.form.corpId = customer.id
  626. },
  627. selectProduct() {
  628. if (this.form.confirmStatus == 0) {
  629. this.$u.route('/pages/views/salesSlip/selectProduct', this.form);
  630. }
  631. },
  632. //商品选择返回
  633. getProduct(dataList) {
  634. for (let item of dataList) {
  635. this.form.orderItemsList.push({
  636. ...item
  637. })
  638. }
  639. this.amountNumber = {
  640. deliveryAll: 0, //送货总数量
  641. cost: 0, //成本
  642. grossProfit: 0, //毛利
  643. delivery: 0, //送货
  644. saleAll: 0, //销售数量
  645. amount: 0
  646. }
  647. for (let item of this.form.orderItemsList) {
  648. this.amountNumber.saleAll += Number(item.storageInQuantity)
  649. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  650. this.amountNumber.delivery += Number(item.actualQuantity)
  651. this.amountNumber.deliveryAll += item.actualQuantity ? Number(item.actualQuantity) : 0
  652. this.amountNumber.amount += Number(item.amount)
  653. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  654. .storageInQuantity) * Number(item.purchasePrice) : 0)
  655. }
  656. this.form.purchaseAmount = this.amountNumber.amount
  657. },
  658. selectCustomer() {
  659. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  660. corpType: 'KH'
  661. });
  662. },
  663. // 新增图片
  664. async afterRead(event) {
  665. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  666. let lists = [].concat(event.file)
  667. let fileListLen = this[`fileList${event.name}`].length
  668. lists.map((item) => {
  669. this[`fileList${event.name}`].push({
  670. ...item,
  671. status: 'uploading',
  672. message: '上传中'
  673. })
  674. })
  675. for (let i = 0; i < lists.length; i++) {
  676. const result = await this.uploadFilePromise(lists[i].url)
  677. let item = this[`fileList${event.name}`][fileListLen]
  678. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  679. status: 'success',
  680. sort: this.fileList1.length,
  681. fileName: JSON.parse(result).data.originalName,
  682. url: JSON.parse(result).data.link
  683. }))
  684. fileListLen++
  685. }
  686. },
  687. uploadFilePromise(url) {
  688. return new Promise((resolve, reject) => {
  689. let a = uni.uploadFile({
  690. url: http.config.baseURL +
  691. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  692. filePath: url,
  693. name: 'file',
  694. formData: {
  695. user: 'test'
  696. },
  697. header: {
  698. // 客户端认证参数
  699. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  700. clientSecret),
  701. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  702. },
  703. success: (res) => {
  704. setTimeout(() => {
  705. resolve(res.data)
  706. }, 1000)
  707. }
  708. });
  709. })
  710. },
  711. // 删除图片
  712. deletePic(event) {
  713. let this_ = this
  714. uni.showModal({
  715. title: '提示',
  716. content: '是否确认删除',
  717. success: function(rest) {
  718. if (rest.confirm == true) {
  719. if (this_[`fileList${event.name}`][event.index].id) {
  720. removeFile({
  721. ids: this_[`fileList${event.name}`][event.index].id
  722. }).then(res => {
  723. this_[`fileList${event.name}`].splice(event.index, 1)
  724. })
  725. } else {
  726. this_[`fileList${event.name}`].splice(event.index, 1)
  727. }
  728. }
  729. }
  730. })
  731. },
  732. }
  733. }
  734. </script>
  735. <style lang="scss" scoped>
  736. ::v-deep .u-cell__body {
  737. padding: 20rpx 10rpx;
  738. }
  739. </style>