salesOrderDetails.vue 25 KB

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