salesOrderDetails.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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?amountNumber.cost.toFixed(2):'0.00'}}</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?amountNumber.grossProfit.toFixed(2):'0.00'}}</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?parseInt(item.storageInQuantity):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'])"
  155. prop="mailbox" 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"
  161. border="none" placeholder="请输入"
  162. :disabled="form.confirmStatus == 0 || (form.orderAmount - form.settlmentAmount) == 0"
  163. disabledColor="#ffffff" />
  164. </u-form-item>
  165. <u-form-item label="收款账户" prop="mailbox" borderBottom @click="filterAll(['account','account'])">
  166. <u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
  167. disabledColor="#ffffff">
  168. <template slot="suffix" style="text-align: center;">
  169. <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
  170. </template>
  171. </u-input>
  172. </u-form-item>
  173. <u-form-item label="收款单号" prop="mailbox" borderBottom>
  174. <u-input v-model="form.receiptNo" inputAlign="right" border="none" disabled
  175. disabledColor="#ffffff" />
  176. </u-form-item>
  177. </view>
  178. </view>
  179. </view>
  180. <view
  181. style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
  182. <u-cell-group :border="false">
  183. <u-cell :border="false" center title="图片信息" arrow-direction="down">
  184. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  185. <view slot="value">
  186. <view v-if="form.confirmStatus == 1" @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" @delete="deletePic" name="1" multiple
  195. :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 style="background-color: #b3b3b3;display: grid;justify-items: center;height: 100%;">
  233. <u-icon name="checkmark" color="#fff"></u-icon>
  234. <view style="color: #fff;">已全部收款</view>
  235. </view>
  236. </view>
  237. </view>
  238. </view>
  239. <view v-if="choice" class="mask" @touchmove.stop.prevent="moveHandle" @click="choice = !choice">
  240. <view class="choice">
  241. <view style="display: flex;;justify-content: right;margin-right: 5rpx;">
  242. <view
  243. style="width: 40rpx;height: 40rpx;background-color: #fff;border-radius: 10rpx;transform: rotate(45deg);margin-top: -8rpx;z-index: -1;">
  244. </view>
  245. </view>
  246. <view style="margin-top: -25rpx;z-index: 99;background-color: #fff;">
  247. <u-cell-group :border="false">
  248. <u-cell icon="edit-pen" :title="connected?'打印':'未连接'" @click.native.stop="connectingDevices"></u-cell>
  249. <u-cell icon="photo" title="保存图片" :border="false" @click.native.stop="generatePictures">
  250. </u-cell>
  251. </u-cell-group>
  252. </view>
  253. </view>
  254. </view>
  255. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
  256. @confirm="confirmTiem"></u-datetime-picker>
  257. <u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
  258. @confirm="showPicker"></u-picker>
  259. </view>
  260. </template>
  261. <script>
  262. import {
  263. typeSave,
  264. removeFile,
  265. submitApp,
  266. remind,
  267. confirm,
  268. revoke,
  269. removeItem,
  270. removeId,
  271. copyOrder,
  272. collectPayment,
  273. saveAtta
  274. } from '@/api/views/sale/salesOrderDetails.js'
  275. import http from '@/http/api.js'
  276. import {
  277. clientId,
  278. clientSecret
  279. } from '@/common/setting'
  280. import {
  281. dateFormat
  282. } from '@/common/dateFormat'
  283. // #ifdef APP-PLUS
  284. const HanyinPlugin = uni.requireNativePlugin('Hanyin-Plugin'); //汉印
  285. import printConnect from "@/common/print.js"; //引入打印机模板文件
  286. let print;
  287. // #endif
  288. import {
  289. GET_REQUEST_DATA
  290. } from "@/store/gettersType.js";
  291. import {
  292. mapGetters,
  293. mapActions
  294. } from 'vuex';
  295. import {
  296. DX
  297. } from '@/common/dateFormat.js';
  298. export default {
  299. data() {
  300. return {
  301. form: {
  302. orderItemsList: []
  303. },
  304. datetime: Number(new Date()),
  305. timeOpen: false,
  306. fileList1: [],
  307. screen: [],
  308. showOpen: false,
  309. choice: false,
  310. columns: [],
  311. connected:false,
  312. amountNumber: {
  313. deliveryAll: 0,
  314. cost: 0,
  315. grossProfit: 0,
  316. delivery: 0,
  317. saleAll: 0,
  318. amount: 0
  319. }
  320. }
  321. },
  322. onLoad(data) {
  323. this.refresh(data.id)
  324. },
  325. computed: {
  326. ...mapGetters([GET_REQUEST_DATA])
  327. },
  328. onShow() {
  329. this.choice = false
  330. let this_ = this
  331. // #ifdef APP-PLUS
  332. HanyinPlugin.IsOpened(res => {
  333. this_.connected = res.state
  334. if(this_.GET_REQUEST_DATA.length == 0){
  335. this_.connected = false
  336. print = new printConnect({},1); //打印机连接
  337. }
  338. });
  339. // #endif
  340. },
  341. onNavigationBarButtonTap(e) {
  342. this.choice = !this.choice
  343. },
  344. methods: {
  345. //跳转连接设备
  346. connectingDevices() {
  347. if(this.connected){
  348. this.senBleLabel()
  349. }else{
  350. uni.$u.route('/pages/views/bluetooth/index', {
  351. data: JSON.stringify(this.form)
  352. });
  353. }
  354. },
  355. senBleLabel() {
  356. // if (!print) return;
  357. console.log(this.$Mock.printTemplate.pagConfig)
  358. this.$Mock.printTemplate.pagConfig = 0
  359. let data = []
  360. let i = 0
  361. for (let item of this.form.orderItemsList) {
  362. data.push({
  363. "top": Number(i * 40 + 90),
  364. "left": "0",
  365. "textAlign": "start",
  366. "width": "270",
  367. "fontSize": 9,
  368. "text": item.cname,
  369. "type": "text",
  370. "fontWeight": "400",
  371. "height": "20"
  372. })
  373. data.push({
  374. "top": Number(i * 40 + 110),
  375. "left": "140",
  376. "textAlign": "start",
  377. "width": "40",
  378. "fontSize": 8,
  379. "text": Number(item.storageInQuantity),
  380. "type": "text",
  381. "fontWeight": "400",
  382. "height": "20"
  383. })
  384. data.push({
  385. "top": Number(i * 40 + 110),
  386. "left": "160",
  387. "textAlign": "start",
  388. "width": "50",
  389. "fontSize": 8,
  390. "text": item.price,
  391. "type": "text",
  392. "fontWeight": "400",
  393. "height": "20"
  394. })
  395. data.push({
  396. "top": Number(i * 40 + 110),
  397. "left": "210",
  398. "textAlign": "start",
  399. "width": "60",
  400. "fontSize": 8,
  401. "text": item.amount,
  402. "type": "text",
  403. "fontWeight": "400",
  404. "height": "20"
  405. })
  406. i++
  407. }
  408. data.push({
  409. "top": Number(i * 40 + 90),
  410. "left": "20",
  411. "textAlign": "start",
  412. "width": "270",
  413. "fontSize": 9,
  414. "text": "合计:",
  415. "type": "text",
  416. "fontWeight": "400",
  417. "height": "20"
  418. })
  419. data.push({
  420. "top": Number(i * 40 + 90),
  421. "left": "140",
  422. "textAlign": "start",
  423. "width": "40",
  424. "fontSize": 8,
  425. "text": this.amountNumber.saleAll,
  426. "type": "text",
  427. "fontWeight": "400",
  428. "height": "20"
  429. })
  430. data.push({
  431. "top": Number(i * 40 + 90),
  432. "left": "210",
  433. "textAlign": "start",
  434. "width": "60",
  435. "fontSize": 8,
  436. "text": this.form.orderAmount,
  437. "type": "text",
  438. "fontWeight": "400",
  439. "height": "20"
  440. })
  441. data.push({
  442. "top": Number(i * 40 + 110),
  443. "left": "20",
  444. "textAlign": "start",
  445. "width": "270",
  446. "fontSize": 9,
  447. "text": "产品合计:",
  448. "type": "text",
  449. "fontWeight": "400",
  450. "height": "20"
  451. })
  452. data.push({
  453. "top": Number(i * 40 + 110),
  454. "left": "70",
  455. "textAlign": "start",
  456. "width": "70",
  457. "fontSize": 8,
  458. "text": this.amountNumber.amount,
  459. "type": "text",
  460. "fontWeight": "400",
  461. "height": "20"
  462. })
  463. data.push({
  464. "top": Number(i * 40 + 110),
  465. "left": "140",
  466. "textAlign": "start",
  467. "width": "60",
  468. "fontSize": 8,
  469. "text": "合计金额:",
  470. "type": "text",
  471. "fontWeight": "400",
  472. "height": "20"
  473. })
  474. data.push({
  475. "top": Number(i * 40 + 110),
  476. "left": "190",
  477. "textAlign": "start",
  478. "width": "80",
  479. "fontSize": 8,
  480. "text": DX(this.amountNumber.amount),
  481. "type": "text",
  482. "fontWeight": "400",
  483. "height": "40"
  484. })
  485. data.push({
  486. "top": Number(i * 40 + 130),
  487. "left": "20",
  488. "textAlign": "start",
  489. "width": "270",
  490. "fontSize": 9,
  491. "text": "订货电话:" + this.form.clientAttn,
  492. "type": "text",
  493. "fontWeight": "400",
  494. "height": "20"
  495. })
  496. data.push({
  497. "top": Number(i * 40 + 150),
  498. "left": "20",
  499. "textAlign": "start",
  500. "width": "270",
  501. "fontSize": 9,
  502. "text": "制单人:" + this.form.client,
  503. "type": "text",
  504. "fontWeight": "400",
  505. "height": "20"
  506. })
  507. data.push({
  508. "top": Number(i * 40 + 150),
  509. "left": "140",
  510. "textAlign": "start",
  511. "width": "80",
  512. "fontSize": 8,
  513. "text": "收货人(签字):",
  514. "type": "text",
  515. "fontWeight": "400",
  516. "height": "20"
  517. })
  518. print.startPrint({
  519. SALES_SLIP: this.form.sysNo,
  520. CUSTOMER_NAME: this.form.corpsName,
  521. SALES_DATE: this.form.businesDate.slice(0, 10)
  522. }, {
  523. pageHeight: (this.form.orderItemsList.length * 40) / 3
  524. }, data);
  525. },
  526. generatePictures() {
  527. uni.$u.route('/pages/views/bluetooth/salesSlipTable', {
  528. data: JSON.stringify(this.form)
  529. });
  530. },
  531. //遮罩层禁止点击空方法
  532. moveHandle() {},
  533. newCompany() {
  534. uni.$u.route('/pages/views/product/createCompany', {
  535. code: "account",
  536. title: "收款账户"
  537. });
  538. },
  539. calculationContract() {
  540. let data = {
  541. purchaseAmount: this.form.purchaseAmount ? Number(this.form.purchaseAmount) : 0,
  542. thisUsedProfit: this.form.thisUsedProfit ? Number(this.form.thisUsedProfit) : 0
  543. }
  544. this.form.orderAmount = data.purchaseAmount - data.thisUsedProfit
  545. },
  546. getMap() {
  547. let this_ = this
  548. uni.chooseLocation({
  549. success: function(res) {
  550. this_.$set(this_.form, "arrivalAddress", res.address)
  551. }
  552. });
  553. },
  554. copyDocument() {
  555. let form = {
  556. ...this.form,
  557. orderFilesList: this.fileList1
  558. }
  559. if (form.orderFilesList.length > 0) {
  560. form.orderFilesList.forEach(item => delete item.status)
  561. }
  562. let this_ = this
  563. uni.showModal({
  564. title: '提示',
  565. content: "是否确认复制新增",
  566. success: function(rest) {
  567. if (rest.confirm == true) {
  568. uni.showLoading({
  569. title: '加载中',
  570. mask: true
  571. });
  572. copyOrder(form).then(res => {
  573. uni.hideLoading();
  574. uni.showToast({
  575. icon: "none",
  576. title: '复制新增成功',
  577. mask: true
  578. });
  579. this_.form = res.data
  580. this_.fileList1 = res.data.orderFilesList
  581. this_.amountNumber = {
  582. deliveryAll: 0, //送货总数量
  583. cost: 0, //成本
  584. grossProfit: 0, //毛利
  585. delivery: 0, //送货
  586. saleAll: 0, //销售数量
  587. amount: 0
  588. }
  589. for (let item of this_.form.orderItemsList) {
  590. this_.amountNumber.saleAll += Number(item.storageInQuantity)
  591. this_.amountNumber.cost += Number(item.storageInQuantity) * Number(
  592. item.purchasePrice)
  593. this_.amountNumber.delivery += Number(item.actualQuantity)
  594. this_.amountNumber.deliveryAll += Number(item.actualQuantity)
  595. this_.amountNumber.amount += Number(item.amount)
  596. this_.amountNumber.grossProfit += Number(item.amount) - (item
  597. .purchasePrice ? Number(item.storageInQuantity) * Number(
  598. item.purchasePrice) : 0)
  599. }
  600. this.form.purchaseAmount = this.amountNumber.amount
  601. })
  602. }
  603. }
  604. })
  605. },
  606. deleteDoc() {
  607. if (this.form.id) {
  608. let this_ = this
  609. if (this_.form.confirmStatus == 1) {
  610. return uni.showToast({
  611. icon: "none",
  612. title: '禁止删除',
  613. mask: true
  614. });
  615. }
  616. uni.showModal({
  617. title: '提示',
  618. content: "是否确认删除",
  619. success: function(rest) {
  620. if (rest.confirm == true) {
  621. removeId({
  622. id: this_.form.id
  623. }).then(res => {
  624. uni.showToast({
  625. icon: "none",
  626. title: '删除成功',
  627. mask: true
  628. });
  629. setTimeout(function() {
  630. uni.navigateBack()
  631. }, 1000);
  632. })
  633. }
  634. }
  635. })
  636. } else {
  637. uni.showToast({
  638. icon: "none",
  639. title: '未保存',
  640. mask: true
  641. });
  642. }
  643. },
  644. deleteProduct(index) {
  645. let this_ = this
  646. if (this_.form.orderItemsList[index].id) {
  647. uni.showModal({
  648. title: '提示',
  649. content: "是否确认删除",
  650. success: function(rest) {
  651. if (rest.confirm == true) {
  652. uni.showLoading({
  653. title: '加载中',
  654. mask: true
  655. });
  656. removeItem({
  657. itemId: this_.form.orderItemsList[index].id
  658. }).then(res => {
  659. uni.hideLoading();
  660. uni.showToast({
  661. icon: "none",
  662. title: '删除成功',
  663. mask: true
  664. });
  665. this_.form.orderItemsList.splice(index, 1)
  666. }).catch(err => {
  667. uni.hideLoading();
  668. })
  669. }
  670. }
  671. })
  672. } else {
  673. this_.form.orderItemsList.splice(index, 1)
  674. }
  675. },
  676. //时间确认选择
  677. confirmTiem(e) {
  678. this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  679. this.timeOpen = false
  680. },
  681. // 下拉选择
  682. showPicker(e) {
  683. this.form[this.screen[1]] = e.value[0].dictValue
  684. this.showOpen = false
  685. },
  686. //集合筛选条件
  687. filterAll(screen) {
  688. if (screen[1] == "account") {
  689. if (this.form.confirmStatus == 0) {
  690. return uni.showToast({
  691. icon: "none",
  692. title: '禁止操作',
  693. mask: true
  694. });
  695. } else if ((this.form.orderAmount - this.form.settlmentAmount) == 0) {
  696. return uni.showToast({
  697. icon: "none",
  698. title: '禁止操作',
  699. mask: true
  700. });
  701. }
  702. } else {
  703. if (screen[1] !== "settlmentAmount") {
  704. if (this.form.confirmStatus == 1) {
  705. return uni.showToast({
  706. icon: "none",
  707. title: '禁止操作',
  708. mask: true
  709. });
  710. }
  711. }
  712. }
  713. this.screen = screen
  714. switch (screen[1]) {
  715. case "businesDate":
  716. this.timeOpen = true
  717. break;
  718. case "requiredDeliveryDate":
  719. this.timeOpen = true
  720. break;
  721. case "advanceCollectionDate":
  722. this.timeOpen = true
  723. break;
  724. case "account":
  725. this.$u.api.getWorkDicts('account').then(res => {
  726. this.columns = [res.data]
  727. this.showOpen = true
  728. })
  729. break;
  730. case "settlmentAmount":
  731. uni.$u.route('/pages/views/salesSlip/collectionList', this.form);
  732. break;
  733. }
  734. },
  735. refresh(id) {
  736. uni.showLoading({
  737. title: '加载中',
  738. mask: true
  739. });
  740. typeSave({
  741. id: id
  742. }).then(res => {
  743. this.form = res.data
  744. this.fileList1 = res.data.orderFilesList
  745. this.amountNumber = {
  746. deliveryAll: 0, //送货总数量
  747. cost: 0, //成本
  748. grossProfit: 0, //毛利
  749. delivery: 0, //送货
  750. saleAll: 0, //销售数量
  751. amount: 0
  752. }
  753. for (let item of this.form.orderItemsList) {
  754. this.amountNumber.saleAll += Number(item.storageInQuantity)
  755. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  756. this.amountNumber.delivery += Number(item.actualQuantity)
  757. this.amountNumber.deliveryAll += Number(item.actualQuantity)
  758. this.amountNumber.amount += Number(item.amount)
  759. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  760. .storageInQuantity) * Number(item.purchasePrice) : 0)
  761. }
  762. this.form.purchaseAmount = this.amountNumber.amount
  763. setTimeout(function() {
  764. uni.hideLoading();
  765. }, 500);
  766. })
  767. },
  768. //确认收款
  769. confirmReceipt() {
  770. let this_ = this
  771. let form = {
  772. ...this_.form,
  773. orderFilesList: this_.fileList1
  774. }
  775. if (form.orderFilesList.length > 0) {
  776. form.orderFilesList.forEach(item => delete item.status)
  777. }
  778. if (!form.currentAmount) {
  779. return uni.showToast({
  780. icon: "none",
  781. title: '本次收款金额不能为空',
  782. mask: true,
  783. duration: 2000
  784. });
  785. }
  786. if (!form.account) {
  787. return uni.showToast({
  788. icon: "none",
  789. title: '未选择收款账户',
  790. mask: true,
  791. duration: 2000
  792. });
  793. }
  794. uni.showModal({
  795. title: '是否确认收款',
  796. content: '本次收款金额' + form.currentAmount,
  797. success: function(rest) {
  798. if (rest.confirm == true) {
  799. uni.showLoading({
  800. title: '加载中',
  801. mask: true
  802. });
  803. collectPayment(form).then(res => {
  804. uni.showToast({
  805. icon: "none",
  806. title: '收款成功',
  807. mask: true,
  808. duration: 2000
  809. });
  810. setTimeout(function() {
  811. uni.hideLoading();
  812. this_.refresh(res.data.id)
  813. }, 1000);
  814. })
  815. }
  816. }
  817. })
  818. },
  819. //保存附件
  820. saveAttachment() {
  821. let form = {
  822. pid: this.form.id,
  823. orderFilesList: this.fileList1
  824. }
  825. if (form.orderFilesList.length > 0) {
  826. form.orderFilesList.forEach(item => delete item.status)
  827. }
  828. uni.showLoading({
  829. title: '加载中',
  830. mask: true
  831. });
  832. saveAtta(form).then(res => {
  833. uni.showToast({
  834. icon: "none",
  835. title: '保存成功',
  836. mask: true
  837. });
  838. let _this = this
  839. setTimeout(function() {
  840. uni.hideLoading();
  841. _this.refresh(res.data.id)
  842. }, 1000);
  843. })
  844. },
  845. //保存
  846. conserve() {
  847. let form = {
  848. ...this.form,
  849. orderFilesList: this.fileList1
  850. }
  851. if (form.orderFilesList.length > 0) {
  852. form.orderFilesList.forEach(item => delete item.status)
  853. }
  854. uni.showLoading({
  855. title: '加载中',
  856. mask: true
  857. });
  858. submitApp(form).then(res => {
  859. uni.showToast({
  860. icon: "none",
  861. title: '保存成功',
  862. mask: true
  863. });
  864. let _this = this
  865. setTimeout(function() {
  866. uni.hideLoading();
  867. _this.refresh(res.data.id)
  868. }, 1000);
  869. })
  870. },
  871. //提交
  872. submit(type) {
  873. let form = {
  874. ...this.form,
  875. orderFilesList: this.fileList1
  876. }
  877. let this_ = this
  878. uni.showLoading({
  879. title: '提交中',
  880. mask: true
  881. });
  882. if (type == 0) {
  883. remind(form).then(res => {
  884. uni.hideLoading();
  885. if (res.data) {
  886. uni.showModal({
  887. title: '提示',
  888. content: res.data,
  889. success: function(rest) {
  890. if (rest.confirm == true) {
  891. uni.showLoading({
  892. title: '提交中',
  893. mask: true
  894. });
  895. confirm(form).then(resth => {
  896. uni.showToast({
  897. icon: "none",
  898. title: '提交成功',
  899. mask: true
  900. });
  901. setTimeout(function() {
  902. // uni.hideLoading();
  903. this_.refresh(resth.data.id)
  904. }, 1000);
  905. })
  906. }
  907. }
  908. })
  909. } else {
  910. uni.showLoading({
  911. title: '提交中',
  912. mask: true
  913. });
  914. confirm(form).then(rest => {
  915. uni.showToast({
  916. icon: "none",
  917. title: '提交成功',
  918. mask: true
  919. });
  920. setTimeout(function() {
  921. uni.hideLoading();
  922. this_.refresh(rest.data.id)
  923. }, 1000);
  924. })
  925. }
  926. })
  927. } else if (type == 1) {
  928. revoke(form).then(res => {
  929. uni.showToast({
  930. icon: "none",
  931. title: '撤销成功',
  932. mask: true
  933. });
  934. setTimeout(function() {
  935. uni.hideLoading();
  936. this_.refresh(res.data.id)
  937. }, 1000);
  938. })
  939. }
  940. },
  941. //客户选择返回触发
  942. otherFun(customer) {
  943. this.form.corpsName = customer.cname
  944. this.form.corpId = customer.id
  945. },
  946. selectProduct() {
  947. if (this.form.confirmStatus == 0) {
  948. this.$u.route('/pages/views/salesSlip/selectProduct', this.form);
  949. }
  950. },
  951. //商品选择返回
  952. getProduct(dataList) {
  953. for (let item of dataList) {
  954. this.form.orderItemsList.push({
  955. ...item
  956. })
  957. }
  958. this.amountNumber = {
  959. deliveryAll: 0, //送货总数量
  960. cost: 0, //成本
  961. grossProfit: 0, //毛利
  962. delivery: 0, //送货
  963. saleAll: 0, //销售数量
  964. amount: 0
  965. }
  966. for (let item of this.form.orderItemsList) {
  967. this.amountNumber.saleAll += Number(item.storageInQuantity)
  968. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  969. this.amountNumber.delivery += Number(item.actualQuantity)
  970. this.amountNumber.deliveryAll += item.actualQuantity ? Number(item.actualQuantity) : 0
  971. this.amountNumber.amount += Number(item.amount)
  972. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  973. .storageInQuantity) * Number(item.purchasePrice) : 0)
  974. }
  975. this.form.purchaseAmount = this.amountNumber.amount
  976. },
  977. selectCustomer() {
  978. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  979. corpType: 'KH'
  980. });
  981. },
  982. // 新增图片
  983. async afterRead(event) {
  984. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  985. let lists = [].concat(event.file)
  986. let fileListLen = this[`fileList${event.name}`].length
  987. lists.map((item) => {
  988. this[`fileList${event.name}`].push({
  989. ...item,
  990. status: 'uploading',
  991. message: '上传中'
  992. })
  993. })
  994. for (let i = 0; i < lists.length; i++) {
  995. const result = await this.uploadFilePromise(lists[i].url)
  996. let item = this[`fileList${event.name}`][fileListLen]
  997. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  998. status: 'success',
  999. sort: this.fileList1.length,
  1000. fileName: JSON.parse(result).data.originalName,
  1001. url: JSON.parse(result).data.link
  1002. }))
  1003. fileListLen++
  1004. }
  1005. },
  1006. uploadFilePromise(url) {
  1007. return new Promise((resolve, reject) => {
  1008. let a = uni.uploadFile({
  1009. url: http.config.baseURL +
  1010. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  1011. filePath: url,
  1012. name: 'file',
  1013. formData: {
  1014. user: 'test'
  1015. },
  1016. header: {
  1017. // 客户端认证参数
  1018. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  1019. clientSecret),
  1020. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  1021. },
  1022. success: (res) => {
  1023. setTimeout(() => {
  1024. resolve(res.data)
  1025. }, 1000)
  1026. }
  1027. });
  1028. })
  1029. },
  1030. // 删除图片
  1031. deletePic(event) {
  1032. let this_ = this
  1033. uni.showModal({
  1034. title: '提示',
  1035. content: '是否确认删除',
  1036. success: function(rest) {
  1037. if (rest.confirm == true) {
  1038. if (this_[`fileList${event.name}`][event.index].id) {
  1039. removeFile({
  1040. ids: this_[`fileList${event.name}`][event.index].id
  1041. }).then(res => {
  1042. this_[`fileList${event.name}`].splice(event.index, 1)
  1043. })
  1044. } else {
  1045. this_[`fileList${event.name}`].splice(event.index, 1)
  1046. }
  1047. }
  1048. }
  1049. })
  1050. },
  1051. }
  1052. }
  1053. </script>
  1054. <style lang="scss" scoped>
  1055. ::v-deep .u-cell__body {
  1056. padding: 20rpx 10rpx;
  1057. }
  1058. .choice {
  1059. position: fixed;
  1060. right: 10rpx;
  1061. border-radius: 10rpx;
  1062. padding: 0 10rpx 10rpx 10rpx;
  1063. background-color: #fff;
  1064. // #ifdef H5
  1065. top: calc(var(--status-bar-height) + 44px + 20rpx);
  1066. // #endif
  1067. // #ifdef APP-PLUS
  1068. top: 30rpx,
  1069. // #endif
  1070. }
  1071. .mask {
  1072. width: 100%;
  1073. height: 100%;
  1074. position: fixed;
  1075. top: 0;
  1076. bottom: 0;
  1077. background-color: rgba(1, 1, 1, 0.3);
  1078. }
  1079. </style>