salesOrderDetails.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. <template>
  2. <view style="padding-top: 1rpx;">
  3. <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="form" ref="form"
  4. labelWidth="180rpx"
  5. style="margin-top: 10rpx;padding-bottom: 130rpx;">
  6. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  7. <u-cell-group :border="false">
  8. <u-cell :border="false" center title="基础信息" arrow-direction="down">
  9. <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
  10. </u-cell>
  11. </u-cell-group>
  12. <view style="padding: 0 10rpx;">
  13. <u-form-item leftIcon="account" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  14. label="客户名称" prop="customerName" borderBottom @click="selectCustomer">
  15. <u-input v-model="form.customerName" inputAlign="right" border="none"
  16. placeholder="请选择客户名称" disabled
  17. disabledColor="#ffffff" />
  18. </u-form-item>
  19. <u-form-item leftIcon="account" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  20. label="联系人" prop="contacts" borderBottom @click="filterAll(['contacts','contacts'])">
  21. <u-input v-model="form.contacts" inputAlign="right" border="none" placeholder="请选择"
  22. disabled disabledColor="#ffffff">
  23. </u-input>
  24. </u-form-item>
  25. <u-form-item leftIcon="phone" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  26. label="电话" prop="phone" borderBottom>
  27. <u-input v-model="form.phone" inputAlign="right" border="none" placeholder="请选择"
  28. :disabled="form.generateTask != '未生成'" disabledColor="#ffffff">
  29. </u-input>
  30. </u-form-item>
  31. <u-form-item leftIcon="map" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  32. label="送货地址" prop="recAddress" borderBottom>
  33. <view style="width: 100%;text-align:right;padding-right: 10rpx;"
  34. v-if="form.generateTask != '未生成'" >{{form.recAddress}}</view>
  35. <u--textarea v-else v-model="form.recAddress" autoHeight
  36. inputAlign="right" border="none" placeholder="请选择"
  37. :disabled="form.generateTask != '未生成'" disabledColor="#ffffff" >
  38. <!-- <template slot="suffix">
  39. <u-icon name="map" color="#fd4b09" @tap="getMap"></u-icon>
  40. </template> -->
  41. </u--textarea>
  42. </u-form-item>
  43. <u-form-item leftIcon="account" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  44. label="业务员" prop="salerName" borderBottom
  45. @click="filterAll(['salerName','salerId'])">
  46. <u-input v-model="form.salerName" border="none"
  47. inputAlign="right" placeholder="请选择业务员" disabled
  48. disabledColor="#ffffff" />
  49. </u-form-item>
  50. <u-form-item leftIcon="calendar" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  51. label="日期" prop="businesDate" borderBottom
  52. @click="filterAll(['businesDate','businesDate'])">
  53. <u-input v-model="form.businesDate" inputAlign="right"
  54. border="none" placeholder="请选择日期" disabled
  55. disabledColor="#ffffff" />
  56. </u-form-item>
  57. <u-form-item leftIcon="home" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  58. label="发货仓库" prop="storageName" borderBottom
  59. @click="filterAll(['storageName','storageId'])">
  60. <u-input v-model="form.storageName" border="none"
  61. inputAlign="right" placeholder="请选择发货仓库" disabled
  62. disabledColor="#ffffff" />
  63. </u-form-item>
  64. <u-form-item leftIcon="car" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  65. label="配送方式" prop="cname" borderBottom
  66. @click="filterAll(['shipType','shipType'])">
  67. <u-input v-model="form.shipType" inputAlign="right" border="none"
  68. placeholder="请选择配送方式" disabled
  69. disabledColor="#ffffff" />
  70. </u-form-item>
  71. <u-form-item leftIcon="home" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  72. label="物流公司" prop="cname" borderBottom
  73. @click="filterAll(['logisticsCorpName','logisticsCorpId'])">
  74. <u-input v-model="form.logisticsCorpName" inputAlign="right" border="none"
  75. placeholder="请选择物流公司" disabled
  76. disabledColor="#ffffff" />
  77. </u-form-item>
  78. <u-form-item leftIcon="file-text" :leftIconStyle="{color: '#FD4B09',fontSize:'40rpx'}"
  79. label="物流单号" prop="cname" borderBottom >
  80. <u-input v-model="form.expressNo" inputAlign="right" border="none"
  81. placeholder="请输入物流单号" :disabled="form.generateTask != '未生成'"
  82. disabledColor="#ffffff" />
  83. </u-form-item>
  84. </view>
  85. </view>
  86. <view style="width: 95%;margin: 10rpx auto;">
  87. <view style="display: flex;align-items: center;justify-content: space-between;background: #fff;border-radius: 12rpx; padding: 20rpx;">
  88. <view style="font-size: 30rpx;color: #fd4b09;">产品列表{{form.orderItemsList.length}}</view>
  89. <view v-if="form.generateTask == '未生成'">
  90. <u-button type="primary" text="添加产品" shape="circle" size="small" color="#FD4B09"
  91. @click="chanpintiao()"></u-button>
  92. </view>
  93. </view>
  94. <view style="position: relative;background: #fff;padding: 20rpx;margin-top: 20rpx;border-box;font-size: 32rpx;"
  95. v-for="(item,index) in form.orderItemsList" :key="index" @click="tanchuangxgai(item,index)">
  96. <view v-if="form.generateTask == '未生成'" class="orderItemsDelent"
  97. @click="orderItemsDelent(item.id,index)">删除</view>
  98. <view>
  99. <u-row>
  100. <u-col span="3">
  101. <u--image :showLoading="true"
  102. :src="item.url?item.url:'../../../static/images/404.png'"
  103. width="80px"
  104. height="80px" radius="10">
  105. </u--image>
  106. </u-col>
  107. <u-col span="8">
  108. <!-- style="font-size: 36rpx;width: 420rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" -->
  109. <view
  110. style="font-size: 36rpx;">
  111. {{item.goodsName}}
  112. </view>
  113. <view style="color: #707070;">批次号:{{item.dot}}</view>
  114. <view style="display: flex;justify-content: space-between;">
  115. <view style="color: #707070;">单价:¥{{Number(item.price).toFixed(2)}}</view>
  116. <view style="color: #707070;">数量:{{item.goodsNum?parseInt(item.goodsNum):item.goodsNum}}</view>
  117. </view>
  118. <view style="display: flex;justify-content: space-between;">
  119. <view style="color: #707070;">金额:¥{{item.subTotalMoney}}</view>
  120. <view v-if="form.confirmStatus == 0" style="color: #707070; color: red;"
  121. @click="deleteProduct(index)">
  122. <u-button type="error" size="mini" text="删除"></u-button>
  123. </view>
  124. </view>
  125. </u-col>
  126. </u-row>
  127. </view>
  128. </view>
  129. </view>
  130. </u--form>
  131. <view style="width: 100%;position: fixed;
  132. bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
  133. <view style="width: 100%;display: flex;font-size: 24rpx;">
  134. <view @click="orderRevokeGenerateShipTaskfun" v-if="form.generateTask == '已生成'"
  135. style="width: 100%; padding: 10rpx 0;
  136. background-color: #d2983c;display: grid;justify-items: center;">
  137. <u-icon name="edit-pen" color="#fff"></u-icon>
  138. <view style="color: #fff;">撤销任务</view>
  139. </view>
  140. <view @click="orderGenerateShipTaskfun" v-else
  141. style="width: 100%; padding: 10rpx 0; background-color: #5ac725;display: grid;justify-items: center;">
  142. <u-icon name="edit-pen" color="#fff"></u-icon>
  143. <view style="color: #fff;">生成任务</view>
  144. </view>
  145. <view @click="conserve"
  146. style="width: 100%; background-color: #FD4B09;display: grid;justify-items: center;">
  147. <u-icon name="edit-pen" color="#fff"></u-icon>
  148. <view style="color: #fff;">保存</view>
  149. </view>
  150. </view>
  151. </view>
  152. <!-- 弹窗数据 -->
  153. <u-popup :show="popupShow" @close="popupShow = false"
  154. :closeable="true" mode="center" customStyle="width: 90%;margin: 0 auto;">
  155. <view style="padding: 40rpx 25rpx;box-sizing: border-box;">
  156. <view style="text-align: center;margin: 10rpx 0;">
  157. <view style="font-size: 36rpx;word-break:break-all;">
  158. {{popupForm.cname}}
  159. </view>
  160. </view>
  161. <view style="width: 96%;margin: 0 auto;clear: both;">
  162. <u-cell-group>
  163. <u-cell title="单价">
  164. <view slot="value">
  165. <u--input type='number' placeholder="请输入单价" border="none"
  166. inputAlign="right" v-model="popupForm.price" clearable disabledColor="#ffffff">
  167. </u--input>
  168. </view>
  169. </u-cell>
  170. <u-cell title="数量">
  171. <view slot="value">
  172. <u-number-box v-model="popupForm.goodsNum" :min="0">
  173. </u-number-box>
  174. </view>
  175. </u-cell>
  176. <u-cell title="批次号(DOT)" @click="dotClickfun">
  177. <view slot="value">
  178. <u--input border="none" inputAlign="right" v-model="popupForm.dot"
  179. disabled placeholder="请选择批次号" disabledColor="#ffffff"></u--input>
  180. </view>
  181. </u-cell>
  182. <u-cell title="库存">
  183. <view slot="value">
  184. {{popupForm.inventory?popupForm.inventory:'--'}}
  185. </view>
  186. </u-cell>
  187. <u-cell title="规格型号">
  188. <view slot="value">
  189. {{popupForm.specificationAndModel?popupForm.specificationAndModel:'--'}}
  190. </view>
  191. </u-cell>
  192. </u-cell-group>
  193. </view>
  194. <view style="margin-top: 40rpx;text-align: center;
  195. font-size: 32rpx;">
  196. <view style="display: flex; color: #fff;justify-content: space-around;">
  197. <view style="color: #FD4B09; border: 1rpx solid #FD4B09;
  198. width: 200rpx; height: 80rpx;
  199. line-height: 80rpx; border-radius: 12rpx;"
  200. @click="popupShow = false">取消</view>
  201. <view style="background-color: #FF6F3B; width: 200rpx; height: 80rpx; line-height: 80rpx; border-radius: 12rpx;"
  202. @click="popupConserve()">保存</view>
  203. </view>
  204. </view>
  205. </view>
  206. </u-popup>
  207. <!-- 批次号弹窗 -->
  208. <u-picker :show="dotPickerShow" :columns="dotPickerColumns" keyName="dot"
  209. @confirm="dotPickerConfirm" @cancel="dotPickerShow = false"></u-picker>
  210. <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
  211. @confirm="confirmTiem"></u-datetime-picker>
  212. <u-picker :show="showOpen" :columns="columns" :defaultIndex="defaultIndex" :keyName="keyName" @cancel="showOpen = false"
  213. @confirm="showPicker"></u-picker>
  214. <u-toast ref="uToast"></u-toast>
  215. </view>
  216. </template>
  217. <script>
  218. import {
  219. queryBrand
  220. } from '@/api/views/stock/index.js'
  221. import {
  222. gainUser,
  223. storageDescListAll,
  224. corpsDescDetail,
  225. orderItemsRemove,
  226. stockDescDotList,
  227. corpsAddrCorpIdByAddr,
  228. orderGenerateShipTask,
  229. orderRevokeGenerateShipTask
  230. } from '@/api/views/sale/index.js'
  231. import {
  232. typeSave,
  233. submitApp,
  234. confirm,
  235. revoke,
  236. removeItem,
  237. removeId,
  238. copyOrder,
  239. collectPayment,
  240. saveAtta,
  241. } from '@/api/views/sale/salesOrderDetails.js'
  242. import http from '@/http/api.js'
  243. import {
  244. clientId,
  245. clientSecret
  246. } from '@/common/setting'
  247. import {
  248. dateFormat
  249. } from '@/common/dateFormat'
  250. // #ifdef APP-PLUS
  251. const HanyinPlugin = uni.requireNativePlugin('Hanyin-Plugin'); //汉印
  252. import printConnect from "@/common/print.js"; //引入打印机模板文件
  253. let print;
  254. // #endif
  255. import {
  256. GET_REQUEST_DATA
  257. } from "@/store/gettersType.js";
  258. import {
  259. mapGetters,
  260. mapActions
  261. } from 'vuex';
  262. import {
  263. DX
  264. } from '@/common/dateFormat.js';
  265. export default {
  266. data() {
  267. return {
  268. form: {
  269. orderItemsList: [],
  270. },
  271. datetime: Number(new Date()),
  272. timeOpen: false,
  273. screen: [],
  274. showOpen: false,
  275. choice: false,
  276. columns: [],
  277. connected:false,
  278. amountNumber: {
  279. deliveryAll: 0,
  280. cost: 0,
  281. grossProfit: 0,
  282. delivery: 0,
  283. saleAll: 0,
  284. amount: 0
  285. },
  286. // 会员卡余额
  287. balanceAmount:0,
  288. // 深拷贝的优惠金额数据
  289. JsonthisUsedProfit:0,
  290. keyName:'',
  291. // 业务员数据
  292. salesmanData:[],
  293. // 物流配送方式请求到的数据
  294. selectData:[],
  295. // 物流公司请求的数据
  296. logisticsCorpData:[],
  297. // 仓库数据
  298. warehouseData:[],
  299. // 联系人数据
  300. contactsData:[],
  301. popupShow:false,
  302. popupForm:{},
  303. popupIndex:0,
  304. dotPickerShow:false,
  305. dotPickerColumns:[],
  306. defaultIndex:[0]
  307. }
  308. },
  309. onLoad(data) {
  310. this.queryBrandfun()
  311. this.HYqueryBrandfun()
  312. // 获取详情信息
  313. this.refresh(data.id)
  314. },
  315. computed: {
  316. ...mapGetters([GET_REQUEST_DATA])
  317. },
  318. onShow() {
  319. this.choice = false
  320. let this_ = this
  321. // #ifdef APP-PLUS
  322. HanyinPlugin.IsOpened(res => {
  323. this_.connected = res.state
  324. if(this_.GET_REQUEST_DATA.length == 0){
  325. this_.connected = false
  326. print = new printConnect({},1); //打印机连接
  327. }
  328. });
  329. // #endif
  330. },
  331. onNavigationBarButtonTap(e) {
  332. this.choice = !this.choice
  333. },
  334. methods: {
  335. // 批次号打开弹窗按钮 获取批次号数据
  336. dotClickfun(){
  337. this.dotPickerShow = true
  338. console.log(this.popupForm,284);
  339. stockDescDotList({
  340. storageId: this.form.storageId,
  341. goodsId: this.popupForm.goodsId
  342. }).then(res=>{
  343. this.dotPickerColumns = [res.data]
  344. })
  345. },
  346. // 批次号弹窗的确认
  347. dotPickerConfirm(e){
  348. this.popupForm.dot = e.value[0].dot
  349. this.dotPickerShow = false
  350. },
  351. //修改弹窗点击保存事件
  352. popupConserve() {
  353. if (this.popupForm.whether == 1) {
  354. if (!this.popupForm.dot) {
  355. return uni.showToast({
  356. icon: 'none',
  357. title: '批次号必填',
  358. position: "bottom"
  359. })
  360. }
  361. }
  362. if (!this.popupForm.goodsNum) {
  363. return uni.showToast({
  364. icon: 'none',
  365. title: '数量不能为0',
  366. position: "bottom"
  367. })
  368. }
  369. this.form.orderItemsList[this.popupIndex] = this.popupForm
  370. uni.hideLoading();
  371. this.popupShow = false
  372. },
  373. // 获取仓库数据
  374. storageDescListAllfun(){
  375. storageDescListAll().then(res => {
  376. this.warehouseData = res.data
  377. this.salesmanData.map(item=>{
  378. if(item.id == this.form.storageId) {
  379. this.$set(this.form,'storageName',item.cname)
  380. }
  381. })
  382. })
  383. },
  384. // 获取联系人数据 赋值第一项
  385. corpsAddrCorpIdByAddrfun(type){
  386. corpsAddrCorpIdByAddr({
  387. pid:this.form.customerId
  388. }).then(res=>{
  389. this.contactsData = res.data
  390. if (type == 'KH') {
  391. this.$set(this.form,'contacts',this.contactsData[0].contacts)
  392. this.$set(this.form,'recAddress',this.contactsData[0].address)
  393. this.$set(this.form,'phone',this.contactsData[0].tel)
  394. }
  395. })
  396. },
  397. // 获取业务员信息
  398. gainUserfun(){
  399. gainUser({
  400. roleName:'业务员'
  401. }).then(res => {
  402. this.salesmanData = res.data
  403. this.salesmanData.map(item=>{
  404. if(item.id == this.form.salerId) {
  405. this.$set(this.form,'salerName',item.name)
  406. }
  407. })
  408. })
  409. },
  410. // 获取物流配送方式数据
  411. queryBrandfun(){
  412. queryBrand({code:'deliveryMethod'}).then(res=>{
  413. this.selectData = res.data
  414. })
  415. },
  416. // 获取货运公司数据
  417. HYqueryBrandfun(){
  418. queryBrand({code:'tyre_express_company'}).then(res=>{
  419. this.logisticsCorpData = res.data
  420. })
  421. },
  422. //跳转连接设备
  423. connectingDevices() {
  424. if(this.connected){
  425. this.senBleLabel()
  426. }else{
  427. uni.$u.route('/pages/views/bluetooth/index', {
  428. data: JSON.stringify(this.form)
  429. });
  430. }
  431. },
  432. senBleLabel() {
  433. // if (!print) return;
  434. console.log(this.$Mock.printTemplate.pagConfig)
  435. this.$Mock.printTemplate.pagConfig = 0
  436. let data = []
  437. let i = 0
  438. for (let item of this.form.orderItemsList) {
  439. data.push({
  440. "top": Number(i * 40 + 90),
  441. "left": "0",
  442. "textAlign": "start",
  443. "width": "270",
  444. "fontSize": 9,
  445. "text": item.cname,
  446. "type": "text",
  447. "fontWeight": "400",
  448. "height": "20"
  449. })
  450. data.push({
  451. "top": Number(i * 40 + 110),
  452. "left": "140",
  453. "textAlign": "start",
  454. "width": "40",
  455. "fontSize": 8,
  456. "text": Number(item.storageInQuantity),
  457. "type": "text",
  458. "fontWeight": "400",
  459. "height": "20"
  460. })
  461. data.push({
  462. "top": Number(i * 40 + 110),
  463. "left": "160",
  464. "textAlign": "start",
  465. "width": "50",
  466. "fontSize": 8,
  467. "text": item.price,
  468. "type": "text",
  469. "fontWeight": "400",
  470. "height": "20"
  471. })
  472. data.push({
  473. "top": Number(i * 40 + 110),
  474. "left": "210",
  475. "textAlign": "start",
  476. "width": "60",
  477. "fontSize": 8,
  478. "text": item.amount,
  479. "type": "text",
  480. "fontWeight": "400",
  481. "height": "20"
  482. })
  483. i++
  484. }
  485. data.push({
  486. "top": Number(i * 40 + 90),
  487. "left": "20",
  488. "textAlign": "start",
  489. "width": "270",
  490. "fontSize": 9,
  491. "text": "合计:",
  492. "type": "text",
  493. "fontWeight": "400",
  494. "height": "20"
  495. })
  496. data.push({
  497. "top": Number(i * 40 + 90),
  498. "left": "140",
  499. "textAlign": "start",
  500. "width": "40",
  501. "fontSize": 8,
  502. "text": this.amountNumber.saleAll,
  503. "type": "text",
  504. "fontWeight": "400",
  505. "height": "20"
  506. })
  507. data.push({
  508. "top": Number(i * 40 + 90),
  509. "left": "210",
  510. "textAlign": "start",
  511. "width": "60",
  512. "fontSize": 8,
  513. "text": this.form.debitAmount,
  514. "type": "text",
  515. "fontWeight": "400",
  516. "height": "20"
  517. })
  518. data.push({
  519. "top": Number(i * 40 + 110),
  520. "left": "20",
  521. "textAlign": "start",
  522. "width": "270",
  523. "fontSize": 9,
  524. "text": "产品合计:",
  525. "type": "text",
  526. "fontWeight": "400",
  527. "height": "20"
  528. })
  529. data.push({
  530. "top": Number(i * 40 + 110),
  531. "left": "70",
  532. "textAlign": "start",
  533. "width": "70",
  534. "fontSize": 8,
  535. "text": this.amountNumber.amount,
  536. "type": "text",
  537. "fontWeight": "400",
  538. "height": "20"
  539. })
  540. data.push({
  541. "top": Number(i * 40 + 110),
  542. "left": "140",
  543. "textAlign": "start",
  544. "width": "60",
  545. "fontSize": 8,
  546. "text": "合计金额:",
  547. "type": "text",
  548. "fontWeight": "400",
  549. "height": "20"
  550. })
  551. data.push({
  552. "top": Number(i * 40 + 110),
  553. "left": "190",
  554. "textAlign": "start",
  555. "width": "80",
  556. "fontSize": 8,
  557. "text": DX(this.amountNumber.amount),
  558. "type": "text",
  559. "fontWeight": "400",
  560. "height": "40"
  561. })
  562. data.push({
  563. "top": Number(i * 40 + 130),
  564. "left": "20",
  565. "textAlign": "start",
  566. "width": "270",
  567. "fontSize": 9,
  568. "text": "订货电话:" + this.form.clientAttn,
  569. "type": "text",
  570. "fontWeight": "400",
  571. "height": "20"
  572. })
  573. data.push({
  574. "top": Number(i * 40 + 150),
  575. "left": "20",
  576. "textAlign": "start",
  577. "width": "270",
  578. "fontSize": 9,
  579. "text": "制单人:" + this.form.client,
  580. "type": "text",
  581. "fontWeight": "400",
  582. "height": "20"
  583. })
  584. data.push({
  585. "top": Number(i * 40 + 150),
  586. "left": "140",
  587. "textAlign": "start",
  588. "width": "80",
  589. "fontSize": 8,
  590. "text": "收货人(签字):",
  591. "type": "text",
  592. "fontWeight": "400",
  593. "height": "20"
  594. })
  595. print.startPrint({
  596. SALES_SLIP: this.form.sysNo,
  597. CUSTOMER_NAME: this.form.customerName,
  598. SALES_DATE: this.form.businesDate.slice(0, 10)
  599. }, {
  600. pageHeight: (this.form.orderItemsList.length * 40) / 3
  601. }, data);
  602. },
  603. generatePictures() {
  604. uni.$u.route('/pages/views/bluetooth/salesSlipTable', {
  605. data: JSON.stringify(this.form)
  606. });
  607. },
  608. //遮罩层禁止点击空方法
  609. moveHandle() {},
  610. newCompany() {
  611. uni.$u.route('/pages/views/product/createCompany', {
  612. code: "account",
  613. title: "收款账户"
  614. });
  615. },
  616. getMap() {
  617. let this_ = this
  618. uni.chooseLocation({
  619. success: function(res) {
  620. this_.$set(this_.form, "recAddress", res.address)
  621. }
  622. });
  623. },
  624. copyDocument() {
  625. let form = {
  626. ...this.form,
  627. }
  628. if (form.orderFilesList.length > 0) {
  629. form.orderFilesList.forEach(item => delete item.status)
  630. }
  631. let this_ = this
  632. uni.showModal({
  633. title: '提示',
  634. content: "是否确认复制新增",
  635. success: function(rest) {
  636. if (rest.confirm == true) {
  637. uni.showLoading({
  638. title: '加载中',
  639. mask: true
  640. });
  641. copyOrder(form).then(res => {
  642. uni.hideLoading();
  643. uni.showToast({
  644. icon: "none",
  645. title: '复制新增成功',
  646. mask: true
  647. });
  648. this_.form = res.data
  649. this_.amountNumber = {
  650. deliveryAll: 0, //送货总数量
  651. cost: 0, //成本
  652. grossProfit: 0, //毛利
  653. delivery: 0, //送货
  654. saleAll: 0, //销售数量
  655. amount: 0
  656. }
  657. for (let item of this_.form.orderItemsList) {
  658. this_.amountNumber.saleAll += Number(item.storageInQuantity)
  659. this_.amountNumber.cost += Number(item.storageInQuantity) * Number(
  660. item.purchasePrice)
  661. this_.amountNumber.delivery += Number(item.actualQuantity)
  662. this_.amountNumber.deliveryAll += Number(item.actualQuantity)
  663. this_.amountNumber.amount += Number(item.amount)
  664. this_.amountNumber.grossProfit += Number(item.amount) - (item
  665. .purchasePrice ? Number(item.storageInQuantity) * Number(
  666. item.purchasePrice) : 0)
  667. }
  668. this.form.orderAmount = this.amountNumber.amount
  669. })
  670. }
  671. }
  672. })
  673. },
  674. deleteDoc() {
  675. if (this.form.id) {
  676. let this_ = this
  677. if (this_.form.confirmStatus == 1) {
  678. return uni.showToast({
  679. icon: "none",
  680. title: '禁止删除',
  681. mask: true
  682. });
  683. }
  684. uni.showModal({
  685. title: '提示',
  686. content: "是否确认删除",
  687. success: function(rest) {
  688. if (rest.confirm == true) {
  689. removeId({
  690. id: this_.form.id
  691. }).then(res => {
  692. uni.showToast({
  693. icon: "none",
  694. title: '删除成功',
  695. mask: true
  696. });
  697. setTimeout(function() {
  698. uni.navigateBack()
  699. }, 1000);
  700. })
  701. }
  702. }
  703. })
  704. } else {
  705. uni.showToast({
  706. icon: "none",
  707. title: '未保存',
  708. mask: true
  709. });
  710. }
  711. },
  712. deleteProduct(index) {
  713. let this_ = this
  714. if (this_.form.orderItemsList[index].id) {
  715. uni.showModal({
  716. title: '提示',
  717. content: "是否确认删除",
  718. success: function(rest) {
  719. if (rest.confirm == true) {
  720. uni.showLoading({
  721. title: '加载中',
  722. mask: true
  723. });
  724. removeItem({
  725. itemId: this_.form.orderItemsList[index].id
  726. }).then(res => {
  727. uni.hideLoading();
  728. uni.showToast({
  729. icon: "none",
  730. title: '删除成功',
  731. mask: true
  732. });
  733. this_.form.orderItemsList.splice(index, 1)
  734. }).catch(err => {
  735. uni.hideLoading();
  736. })
  737. }
  738. }
  739. })
  740. } else {
  741. this_.form.orderItemsList.splice(index, 1)
  742. }
  743. },
  744. //时间确认选择
  745. confirmTiem(e) {
  746. this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
  747. this.timeOpen = false
  748. },
  749. // 下拉选择
  750. showPicker(e) {
  751. console.log(this.screen[1]);
  752. if (this.screen[1] == "account") {
  753. this.formTwo.account = e.value[0].dictValue
  754. this.showOpen = false
  755. } else if(this.screen[1] == "salerId") {
  756. this.form.salerName = e.value[0].name
  757. this.form.salerId = e.value[0].id
  758. this.showOpen = false
  759. } else if(this.screen[1] == "storageId") {
  760. this.form.storageName = e.value[0].cname
  761. this.form.storageId = e.value[0].id
  762. this.showOpen = false
  763. }else if(this.screen[1] == "contacts") {
  764. this.form.contacts = e.value[0].contacts
  765. this.form.recAddress = e.value[0].address
  766. this.form.phone = e.value[0].tel
  767. this.showOpen = false
  768. }else if(this.screen[1] == "shipType") {
  769. this.form.shipType = e.value[0].dictValue
  770. this.showOpen = false
  771. }else if(this.screen[1] == "logisticsCorpId") {
  772. this.form.logisticsCorpId = e.value[0].dictKey
  773. this.form.logisticsCorpName = e.value[0].dictValue
  774. this.showOpen = false
  775. }else {}
  776. // this.form[this.screen[1]] = e.value[0].dictValue
  777. // this.showOpen = false
  778. },
  779. //集合筛选条件
  780. filterAll(screen) {
  781. // if (this.form.status != '录入') return
  782. if(this.form.generateTask != '未生成') return
  783. this.screen = screen
  784. switch (screen[1]) {
  785. case "businesDate":
  786. this.timeOpen = true
  787. break;
  788. case "account":
  789. this.$u.api.getWorkDicts('account').then(res => {
  790. this.columns = [res.data]
  791. this.defaultIndex = [0]
  792. this.keyName = 'dictValue'
  793. this.showOpen = true
  794. })
  795. break;
  796. case "settlmentAmount":
  797. uni.$u.route('/pages/views/salesSlip/collectionList', this.form);
  798. break;
  799. // 仓库
  800. case "storageId":
  801. this.columns = [this.warehouseData]
  802. this.defaultIndex = [0]
  803. this.keyName = 'cname'
  804. this.showOpen = true
  805. break;
  806. // 业务员
  807. case "salerId":
  808. this.columns = [this.salesmanData]
  809. this.defaultIndex = [0]
  810. this.keyName = 'name'
  811. this.showOpen = true
  812. break;
  813. // 联系人
  814. case "contacts":
  815. this.columns = [this.contactsData]
  816. this.defaultIndex = [0]
  817. this.keyName = 'contacts'
  818. this.showOpen = true
  819. break;
  820. // 配送方式
  821. case "shipType":
  822. this.columns = [this.selectData]
  823. this.defaultIndex = [0]
  824. this.keyName = 'dictValue'
  825. this.showOpen = true
  826. break;
  827. // 物流公司
  828. case "logisticsCorpId":
  829. this.columns = [this.logisticsCorpData]
  830. this.defaultIndex = [0]
  831. this.keyName = 'dictValue'
  832. this.showOpen = true
  833. break;
  834. }
  835. },
  836. // 弹窗修改
  837. tanchuangxgai(row,index){
  838. if(this.form.generateTask != '未生成') return
  839. this.popupForm = row
  840. this.popupIndex = index
  841. this.popupShow = true
  842. },
  843. // 产品删除
  844. orderItemsDelent(id,index){
  845. uni.showModal({
  846. title: '提示',
  847. content: '是否确认删除',
  848. success: (rest)=> {
  849. console.log(rest);
  850. if (rest.confirm == true) {
  851. if (id) {
  852. orderItemsRemove({ids:id}).then(res=>{
  853. this.form.orderItemsList.splice(index, 1);
  854. this.$refs.uToast.show({
  855. type: 'success',
  856. message: "操作成功",
  857. })
  858. })
  859. }else {
  860. this.form.orderItemsList.splice(index, 1);
  861. this.$refs.uToast.show({
  862. type: 'success',
  863. message: "操作成功",
  864. })
  865. }
  866. }
  867. }
  868. })
  869. },
  870. // 获取详情数据
  871. refresh(id) {
  872. uni.showLoading({
  873. title: '加载中',
  874. mask: true
  875. });
  876. typeSave({
  877. id: id
  878. }).then(res => {
  879. this.form = res.data
  880. this.gainUserfun()
  881. this.storageDescListAllfun()
  882. this.corpsAddrCorpIdByAddrfun()
  883. this.form.memberAmout = 0
  884. this.amountNumber = {
  885. deliveryAll: 0, //送货总数量
  886. cost: 0, //成本
  887. grossProfit: 0, //毛利
  888. delivery: 0, //送货
  889. saleAll: 0, //销售数量
  890. amount: 0
  891. }
  892. for (let item of this.form.orderItemsList) {
  893. this.amountNumber.saleAll += Number(item.storageInQuantity)
  894. this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
  895. this.amountNumber.delivery += Number(item.actualQuantity)
  896. this.amountNumber.deliveryAll += Number(item.actualQuantity)
  897. this.amountNumber.amount += Number(item.amount)
  898. this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
  899. .storageInQuantity) * Number(item.purchasePrice) : 0)
  900. }
  901. this.form.orderAmount = this.amountNumber.amount
  902. setTimeout(function() {
  903. uni.hideLoading();
  904. }, 500);
  905. })
  906. },
  907. //确认收款
  908. confirmReceipt() {
  909. let this_ = this
  910. let form = {
  911. ...this_.form,
  912. }
  913. if (form.orderFilesList.length > 0) {
  914. form.orderFilesList.forEach(item => delete item.status)
  915. }
  916. // if (!form.currentAmount) {
  917. // return uni.showToast({
  918. // icon: "none",
  919. // title: '本次收款金额不能为空',
  920. // mask: true,
  921. // duration: 2000
  922. // });
  923. // }
  924. // 判断本次收款和会员卡收款不能为空
  925. if (!this.form.currentAmount || this.form.currentAmount == 0) {
  926. if (!this.form.memberAmout || this.form.memberAmout == 0) {
  927. return uni.showToast({
  928. icon: "none",
  929. title: '本次收款金额或会员卡金额不能为空或零',
  930. mask: true
  931. });
  932. }
  933. }
  934. if (!form.account) {
  935. return uni.showToast({
  936. icon: "none",
  937. title: '未选择收款账户',
  938. mask: true,
  939. duration: 2000
  940. });
  941. }
  942. form.currentAmount = form.currentAmount?form.currentAmount:0
  943. uni.showModal({
  944. title: '收款:',
  945. content: '现金收款:' + form.currentAmount +'元\n会员卡收款:' + form.memberAmout + '元',
  946. success: function(rest) {
  947. if (rest.confirm == true) {
  948. uni.showLoading({
  949. title: '加载中',
  950. mask: true
  951. });
  952. collectPayment(form).then(res => {
  953. uni.showToast({
  954. icon: "none",
  955. title: '收款成功',
  956. mask: true,
  957. duration: 2000
  958. });
  959. setTimeout(function() {
  960. uni.hideLoading();
  961. this_.refresh(res.data.id)
  962. }, 1000);
  963. })
  964. }
  965. }
  966. })
  967. },
  968. //保存附件
  969. saveAttachment() {
  970. let form = {
  971. pid: this.form.id,
  972. }
  973. if (form.orderFilesList.length > 0) {
  974. form.orderFilesList.forEach(item => delete item.status)
  975. }
  976. uni.showLoading({
  977. title: '加载中',
  978. mask: true
  979. });
  980. saveAtta(form).then(res => {
  981. uni.showToast({
  982. icon: "none",
  983. title: '保存成功',
  984. mask: true
  985. });
  986. let _this = this
  987. setTimeout(function() {
  988. uni.hideLoading();
  989. _this.refresh(res.data.id)
  990. }, 1000);
  991. })
  992. },
  993. // 生成任务
  994. orderGenerateShipTaskfun(){
  995. uni.showModal({
  996. title: '提示',
  997. content: '是否确认生成任务',
  998. success: (rest)=> {
  999. if (rest.confirm == true) {
  1000. uni.showLoading({
  1001. title: '加载中',
  1002. mask: true
  1003. });
  1004. submitApp({
  1005. bsType: "XS",
  1006. ...this.form
  1007. }).then(() => {
  1008. orderGenerateShipTask({
  1009. bsType: "XS",
  1010. ...this.form
  1011. }).then(res=>{
  1012. uni.showToast({
  1013. icon: "none",
  1014. title: '生成任务成功',
  1015. mask: true
  1016. });
  1017. uni.hideLoading();
  1018. this.refresh(res.data.id)
  1019. })
  1020. })
  1021. }
  1022. }
  1023. })
  1024. },
  1025. // 撤销任务
  1026. orderRevokeGenerateShipTaskfun(){
  1027. uni.showModal({
  1028. title: '提示',
  1029. content: '是否确认生成任务',
  1030. success: (rest)=> {
  1031. if (rest.confirm == true) {
  1032. uni.showLoading({
  1033. title: '加载中',
  1034. mask: true
  1035. });
  1036. submitApp({
  1037. bsType: "XS",
  1038. ...this.form
  1039. }).then(() => {
  1040. orderRevokeGenerateShipTask({
  1041. bsType: "XS",
  1042. ...this.form
  1043. }).then(res=>{
  1044. uni.showToast({
  1045. icon: "none",
  1046. title: '撤销任务成功',
  1047. mask: true
  1048. });
  1049. uni.hideLoading();
  1050. this.refresh(res.data.id)
  1051. })
  1052. })
  1053. }
  1054. }
  1055. })
  1056. },
  1057. //保存
  1058. conserve() {
  1059. // if (!this.form.shipType) {
  1060. // return this.$refs.uNotify.show({
  1061. // top: this.revenueTop,
  1062. // type: 'warning',
  1063. // message: '请选择配送方式!'
  1064. // })
  1065. // }
  1066. // if (!this.form.logisticsCorpId) {
  1067. // return this.$refs.uNotify.show({
  1068. // top: this.revenueTop,
  1069. // type: 'warning',
  1070. // message: '请选择物流公司!'
  1071. // })
  1072. // }
  1073. // if (!this.form.expressNo) {
  1074. // return this.$refs.uNotify.show({
  1075. // top: this.revenueTop,
  1076. // type: 'warning',
  1077. // message: '请输入物流单号!'
  1078. // })
  1079. // }
  1080. let form = {
  1081. ...this.form,
  1082. }
  1083. uni.showLoading({
  1084. title: '加载中',
  1085. mask: true
  1086. });
  1087. submitApp(form).then(res => {
  1088. uni.showToast({
  1089. icon: "none",
  1090. title: '保存成功',
  1091. mask: true
  1092. });
  1093. let _this = this
  1094. setTimeout(function() {
  1095. uni.hideLoading();
  1096. _this.refresh(res.data.id)
  1097. }, 1000);
  1098. })
  1099. },
  1100. //客户选择返回触发
  1101. otherFun(customer) {
  1102. this.form.customerName = customer.cname
  1103. this.form.customerId = customer.id
  1104. this.form.salerId = customer.salesmanId
  1105. this.form.salerName = ''
  1106. this.salesmanData.map(item=>{
  1107. if (item.id == this.form.salerId) {
  1108. this.form.salerName = item.name
  1109. }
  1110. })
  1111. this.form.storageName = ''
  1112. this.form.storageId = customer.deliveryWarehouseId
  1113. this.warehouseData.map(item=>{
  1114. if (item.id == this.form.storageId) {
  1115. this.form.storageName = item.cname
  1116. }
  1117. })
  1118. this.corpsAddrCorpIdByAddrfun('KH')
  1119. // corpsDescDetail({id:customer.id}).then(res=>{
  1120. // this.form.contacts = res.data.corpsAddrList[0].contacts
  1121. // this.form.recAddress = res.data.corpsAddrList[0].belongtoarea + res.data.corpsAddrList[0].detailedAddress
  1122. // this.form.phone = res.data.corpsAddrList[0].tel
  1123. // })
  1124. },
  1125. selectProduct() {
  1126. if (this.form.confirmStatus == 0) {
  1127. this.$u.route('/pages/views/salesSlip/selectProduct', this.form);
  1128. }
  1129. },
  1130. // 产品跳转
  1131. chanpintiao(){
  1132. if (!this.form.customerId) return this.$refs.uNotify.show({
  1133. top: this.revenueTop,
  1134. type: 'warning',
  1135. message: '请选择客户!'
  1136. })
  1137. if (this.form.storageId) {
  1138. this.$u.route('/pages/views/salesSlip/selectProduct', {
  1139. form: JSON.stringify(this.form),
  1140. data: JSON.stringify(this.form.orderItemsList),
  1141. corpId:this.form.corpId
  1142. });
  1143. } else {
  1144. this.$refs.uNotify.show({
  1145. top: this.revenueTop,
  1146. type: 'warning',
  1147. message: '请选择发货仓库!'
  1148. })
  1149. }
  1150. },
  1151. //商品选择返回
  1152. getProduct(dataList) {
  1153. for (let item of dataList) {
  1154. this.form.orderItemsList.push({
  1155. goodsId:item.id,
  1156. price:item.price,
  1157. goodsName:item.cname,
  1158. goodsNum:item.goodsNum,
  1159. brandName:item.brandName,
  1160. brandId:item.brandId,
  1161. goodsNo:item.code,
  1162. propertyName: item.specificationAndModel,
  1163. inventory:item.inventory,
  1164. pattern:item.brandItem,
  1165. goodsDescription:item.goodsDescription,
  1166. dot:item.dot,
  1167. whether:item.whether,
  1168. units:item.unit,
  1169. // 小计
  1170. subTotalMoney:item.goodsNum * item.price,
  1171. // 备注
  1172. remarks:item.remarks,
  1173. // 批次号的状态
  1174. dotedittype:false,
  1175. // 价格数量
  1176. goodsNumtype:false,
  1177. // 价格
  1178. pricetype:false,
  1179. })
  1180. }
  1181. console.log(this.form.orderItemsList,963);
  1182. },
  1183. selectCustomer() {
  1184. // if (this.form.status != '录入') return
  1185. if (this.form.generateTask != '未生成') return
  1186. this.$u.route('/pages/views/salesSlip/selectCustomer', {
  1187. corpType: 'KH'
  1188. });
  1189. },
  1190. }
  1191. }
  1192. </script>
  1193. <style lang="scss" scoped>
  1194. ::v-deep .u-cell__body {
  1195. padding: 20rpx 10rpx;
  1196. }
  1197. .choice {
  1198. position: fixed;
  1199. right: 10rpx;
  1200. border-radius: 10rpx;
  1201. padding: 0 10rpx 10rpx 10rpx;
  1202. background-color: #fff;
  1203. // #ifdef H5
  1204. top: calc(var(--status-bar-height) + 44px + 20rpx);
  1205. // #endif
  1206. // #ifdef APP-PLUS
  1207. top: 30rpx,
  1208. // #endif
  1209. }
  1210. .mask {
  1211. width: 100%;
  1212. height: 100%;
  1213. position: fixed;
  1214. top: 0;
  1215. bottom: 0;
  1216. background-color: rgba(1, 1, 1, 0.3);
  1217. }
  1218. .orderItemsDelent {
  1219. position: absolute;
  1220. top: 15rpx;
  1221. right: 15rpx;
  1222. color: #fd4b09;
  1223. }
  1224. </style>