salesOrderDetails.vue 26 KB

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