OrderAdd.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. <template>
  2. <view class="detail-view">
  3. <view class="top-view clearfix"></view>
  4. <view class="form-cont">
  5. <view class="customer-view">
  6. <view class="title clearfix" @click="goPage('/pagesT/customer/selCustomer')">
  7. <view class="float_left ellipsis">{{ add_form.customerName }}</view>
  8. <view class="float_right"><u-icon color="#879BBA" name="arrow-right" size="24"></u-icon></view>
  9. </view>
  10. <view class="address-view">
  11. <view class="remark_cont" v-if="add_form.customerName === '选择客户'">+{{ add_form.deliveryType !== 2 ? '选择收货信息' : '选择自提点' }}</view>
  12. <block v-else>
  13. <view @click="openSelect('address_show')" class="remark_particulars" v-if="add_form.deliveryType !== 2">
  14. <block v-if="address_list.length > 0">
  15. <view class="clearfix">
  16. <view class="float_left">联系人:{{ address_list[address_index].name || '--' }}</view>
  17. <view class="float_right" style="color: #4076D6;">{{ address_list[address_index].mobile || '--' }}</view>
  18. </view>
  19. <view class="site">
  20. {{ address_list[address_index].area.provinceName }}{{ address_list[address_index].area.cityName
  21. }}{{ address_list[address_index].area.districtName }}{{ address_list[address_index].area.address }}
  22. </view>
  23. </block>
  24. <block v-else>
  25. <view style="text-align: left;">
  26. <text style="margin-right: 30rpx;">暂无收货信息</text>
  27. <u-icon name="plus" size="24" color="#007AFF"></u-icon>
  28. <text style="color: #007AFF;" @click="goPage(`/pagesT/order/AddShippingAddress?customerId=${add_form.customerId}`)">去新增</text>
  29. </view>
  30. </block>
  31. <view class="arrow-right-icon"><u-icon color="#879BBA" name="arrow-right" size="24"></u-icon></view>
  32. </view>
  33. <view @click="openSelect('express_show')" class="remark_particulars" v-else>
  34. <block v-if="self_express_list.length > 0">
  35. <view class="clearfix">
  36. <view class="float_left">自提点:{{ self_express_list[express_rule_index].name || '--' }}</view>
  37. <view class="float_right" style="color: #4076D6;">{{ self_express_list[express_rule_index].mobile || '--' }}</view>
  38. </view>
  39. <view class="site">{{ self_express_list[express_rule_index].addressName }}</view>
  40. </block>
  41. <block v-else>
  42. <view style="text-align: left;">
  43. <text style="margin-right: 30rpx;">暂无自提点</text>
  44. <u-icon name="plus" size="24" color="#007AFF"></u-icon>
  45. <text style="color: #007AFF;" @click="goPage(`/pagesT/order/AddShippingAddress?customerId=${add_form.customerId}`)">去新增</text>
  46. </view>
  47. </block>
  48. <view class="arrow-right-icon"><u-icon color="#879BBA" name="arrow-right" size="24"></u-icon></view>
  49. </view>
  50. </block>
  51. </view>
  52. </view>
  53. <view class="form-model-view">
  54. <view class="title clearfix">
  55. <view class="float_left ellipsis">商品清单</view>
  56. <view class="float_right">共{{ goods_list.length }}种商品,{{ numTotal }}件</view>
  57. </view>
  58. <view class="btn" v-if="!goods_list.length" @click="selGoods">选择商品</view>
  59. <view class="goods-view" v-if="goods_list.length">
  60. <block v-for="(item, index) in goods_list" :key="index"><image v-if="index <= 4" :src="item.images[0]" mode="aspectFill"></image></block>
  61. <view class="more-goods" @click="openSelect('sel_pop')">查看详情</view>
  62. </view>
  63. <view class="form-item clearfix" style="border-top: 1px solid #ECF0F7;padding-top: 20rpx;">
  64. <view class="label">配送方式</view>
  65. <view class="value">
  66. <u-input :placeholder-style="inputStyle" class="dis-input" placeholder="请选择配送方式" disabled v-model="deliveryType_name" @click="openDelivery" />
  67. <u-icon name="arrow-right" size="24" color="#CAD0D7"></u-icon>
  68. </view>
  69. </view>
  70. <view class="form-item clearfix" v-if="add_form.deliveryType === 3">
  71. <view class="label">物流类型</view>
  72. <view class="value">
  73. <u-input
  74. :placeholder-style="inputStyle"
  75. class="dis-input"
  76. placeholder="请选择物流类型"
  77. disabled
  78. v-model="particularsType_name"
  79. @click="particularsType_show = true"
  80. />
  81. <u-icon name="arrow-right" size="24" color="#CAD0D7"></u-icon>
  82. </view>
  83. </view>
  84. <view class="form-item clearfix">
  85. <view class="label">支付方式</view>
  86. <view class="value">
  87. <u-input :placeholder-style="inputStyle" class="dis-input" placeholder="请选择支付方式" disabled v-model="payType_name" @click="payType_show = true" />
  88. <u-icon name="arrow-right" size="24" color="#CAD0D7"></u-icon>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="form-model-view">
  93. <view class="form-item clearfix importend-item">
  94. <view class="label">商品总额</view>
  95. <view class="value">{{ $utils.formattedNumber(totalMoney) }}</view>
  96. </view>
  97. <view class="form-item clearfix">
  98. <view class="label">订单优惠</view>
  99. <view class="value error-value">
  100. <input
  101. placeholder="请输入订单优惠"
  102. placeholder-class="input-pl"
  103. :disabled="!$accessCheck($Access.OrderAddeditGoodsPrice)"
  104. class="dis-input input-sj"
  105. type="digit"
  106. @focus="totalReduceMoneyFocus"
  107. @blur="totalReduceMoneyBlur"
  108. v-model="add_form.totalReduceMoney"
  109. />
  110. </view>
  111. </view>
  112. <view class="form-item clearfix">
  113. <view class="label">应收</view>
  114. <view class="value">{{ $utils.formattedNumber(payMoney) }}</view>
  115. </view>
  116. <view class="form-item clearfix">
  117. <view class="label">实收</view>
  118. <view class="value error-value">
  119. <input
  120. class="dis-input input-sj"
  121. placeholder="请输入实收金额"
  122. placeholder-class="input-pl"
  123. :disabled="!$accessCheck($Access.OrderAddeditGoodsPrice)"
  124. type="digit"
  125. @focus="receivedMoneyFocus"
  126. @blur="receivedMoneyBlur"
  127. v-model="add_form.receivedMoney"
  128. />
  129. </view>
  130. </view>
  131. <view class="form-item clearfix importend-item">
  132. <view class="label">结算账户</view>
  133. <view class="value">
  134. <u-input
  135. :placeholder-style="inputStyle"
  136. class="dis-input"
  137. @click="goPage('/pagesT/account/selAccount?shopId=' + account_shopId)"
  138. placeholder="请选择结算账户"
  139. disabled
  140. v-model="accountName"
  141. />
  142. <u-icon name="arrow-right" size="24" color="#CAD0D7"></u-icon>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="form-model-view">
  147. <view class="bz-label">订单备注</view>
  148. <view class="bz-value"><u-input type="textarea" v-model="add_form.remark" /></view>
  149. </view>
  150. </view>
  151. <u-select @confirm="particularsTypeChange" v-model="particularsType_show" label-name="label" value-name="value" :list="particularsType_list"></u-select>
  152. <u-select @confirm="deliveryTypeChange" v-model="delivery_show" label-name="title" value-name="deliveryType" :list="deliveryType_list"></u-select>
  153. <u-select @confirm="payTypeChange" v-model="payType_show" label-name="label" value-name="value" :list="payType_list"></u-select>
  154. <u-popup v-model="sel_pop" mode="bottom">
  155. <view class="sel-goods-pop">
  156. <view class="pop-tit clearfix">
  157. <view class="float_left">本次已选商品</view>
  158. <view class="float_right" @click="clearGoods">
  159. <text class="custom-icon custom-icon-shanchu"></text>
  160. <text>清空</text>
  161. </view>
  162. </view>
  163. <scroll-view class="goods-ul" scroll-y>
  164. <view class="goods-li" v-for="(item, index) in goods_list" :key="index">
  165. <view class="goods-name">{{ item.title }}</view>
  166. <view class="goods-code clearfix">
  167. <view class="float_left">{{ item.code }}</view>
  168. <view class="float_right price-input-view">
  169. <text class="label">单价:</text>
  170. <input :disabled="!$accessCheck($Access.OrderAddeditGoodsPrice)" class="price-input" type="digit" v-model="item.salePrice" />
  171. <text class="yuan">元</text>
  172. </view>
  173. </view>
  174. <view class="goods-code clearfix">
  175. <view class="float_left">
  176. {{ item.unitName }};
  177. <text v-for="(sku, skuI) in item.specGroup" :key="skuI">{{ sku.specValueName }};</text>
  178. </view>
  179. <view class="float_right" v-if="item.isEq === 4">
  180. <u-number-box :min="0" :index="index" @change="addBuyNumChange" :value="item.buyNum"></u-number-box>
  181. </view>
  182. <view class="float_right" v-else>
  183. <view class="price-input-view" style="margin-bottom: 10rpx;">
  184. <text class="label">数量:</text>
  185. <input class="price-input" type="digit" v-model="item.buyNum" />
  186. </view>
  187. <view class="price-input-view">
  188. <text class="label" style="left: -120rpx;">其他单位:</text>
  189. <input class="price-input" type="digit" v-model="item.otherNum" />
  190. </view>
  191. </view>
  192. </view>
  193. <text class="custom-icon custom-icon-shanchu" @click="delGoods(index)"></text>
  194. </view>
  195. <view style="padding-top: 100rpx;" v-if="!goods_list.length"><u-empty text="未选择商品" mode="data"></u-empty></view>
  196. </scroll-view>
  197. </view>
  198. </u-popup>
  199. <u-select v-model="address_show" value-name="id" label-name="name" :list="address_list" @confirm="addressChange"></u-select>
  200. <u-select v-model="express_show" value-name="id" label-name="name" :list="self_express_list" @confirm="expressChange"></u-select>
  201. <view class="detail-bottom"><u-button class="handel-btn" @click="submit" :loading="sub_load" :ripple="true" type="primary">提交订单</u-button></view>
  202. </view>
  203. </template>
  204. <script>
  205. export default {
  206. data() {
  207. return {
  208. sub_load: false,
  209. sel_pop: false,
  210. express_show: false,
  211. address_show: false,
  212. goodsData: '',
  213. customerData: '',
  214. AccountData: '',
  215. goods_list: [],
  216. address_list: [],
  217. address_index: 0,
  218. deliveryType_list: [], //配送方式
  219. payType_list: [
  220. {
  221. label: '货到付款',
  222. value: 3
  223. },
  224. {
  225. label: '先款后货',
  226. value: 9
  227. }
  228. ],
  229. particularsType_list: [
  230. {
  231. label: '物流专线',
  232. value: 4
  233. },
  234. {
  235. label: '物流专车',
  236. value: 5
  237. }
  238. ],
  239. self_express_list: [],
  240. deliveryType_name: '',
  241. particularsType_name: '', //物流详情名称
  242. particularsType: '', //物流详情id
  243. payType_name: '货到付款', //支付方式名称
  244. delivery_show: false,
  245. payType_show: false,
  246. account_shopId: '',
  247. payWay: 3, //支付方式
  248. express_rule_index: 0,
  249. accountName: '',
  250. shop_id: '',
  251. order_detail: {},
  252. add_form: {
  253. deliveryType: '',
  254. customerName: '选择客户',
  255. addressId: '',
  256. remark: '',
  257. accountList: '',
  258. currentAccountName: '',
  259. receivedMoney: 0,
  260. lists: [],
  261. totalMoney: 0,
  262. payMoney: 0,
  263. totalReduceMoney: 0,
  264. userCenterId: '',
  265. customerId: '',
  266. selfRuleId: '',
  267. selfRuleData: '',
  268. operatorName: '',
  269. payType: 3 //支付方式id
  270. },
  271. rules: {
  272. customerName: [
  273. {
  274. required: true,
  275. message: '请选择客户',
  276. // 可以单个或者同时写两个触发验证方式
  277. trigger: 'change'
  278. }
  279. ]
  280. },
  281. particularsType_show: false
  282. };
  283. },
  284. watch: {
  285. customerData(val) {
  286. if (val) {
  287. this.add_form.userCenterId = val.userCenterId;
  288. this.add_form.customerId = val.id;
  289. this.add_form.customerName = val.name;
  290. this.account_shopId = val.shopId;
  291. // 获取客户收货地址列表
  292. if (this.add_form.deliveryType !== 2) {
  293. this.getAllShippingAddress();
  294. }
  295. }
  296. },
  297. goodsData(val) {
  298. if (val) {
  299. uni.removeStorageSync('orderGoods');
  300. this.goods_list = val;
  301. }
  302. },
  303. AccountData(val) {
  304. if (val) {
  305. this.accountName = val.name;
  306. this.add_form.accountList = [
  307. {
  308. accountId: val.id,
  309. accountNumber: val.accountNumber,
  310. accountName: val.name,
  311. money: this.add_form.receivedMoney,
  312. discountMoney: 0,
  313. finalMoney: this.add_form.receivedMoney,
  314. payWay: this.payWay,
  315. remark: val.remark
  316. }
  317. ];
  318. }
  319. }
  320. },
  321. computed: {
  322. userName() {
  323. return this.$store.state.userInfo.name;
  324. },
  325. numTotal() {
  326. if (!this.goods_list.length) {
  327. return 0;
  328. } else if (this.goods_list.length === 1) {
  329. return Number(this.goods_list[0].buyNum);
  330. } else {
  331. let sum = 0;
  332. this.goods_list.forEach(item => {
  333. sum = sum + Number(item.buyNum);
  334. });
  335. return sum;
  336. }
  337. },
  338. // 商品总额
  339. totalMoney() {
  340. if (!this.goods_list.length) {
  341. return 0;
  342. } else if (this.goods_list.length === 1) {
  343. return Number(this.goods_list[0].buyNum) * Number(this.goods_list[0].salePrice);
  344. } else {
  345. let sum = 0;
  346. this.goods_list.forEach(item => {
  347. sum = sum + Number(item.buyNum) * Number(item.salePrice);
  348. });
  349. return sum;
  350. }
  351. },
  352. payMoney() {
  353. return this.totalMoney - this.add_form.totalReduceMoney;
  354. }
  355. },
  356. onShow() {
  357. this.getAllShippingAddress();
  358. },
  359. onLoad(options) {
  360. if (options.customer) {
  361. const customer = JSON.parse(options.customer);
  362. this.add_form.userCenterId = customer.userCenterId;
  363. this.add_form.customerId = customer.customerId;
  364. this.add_form.customerName = customer.customerName;
  365. this.account_shopId = customer.shopId;
  366. // 获取客户收货地址列表
  367. this.getAllShippingAddress();
  368. }
  369. if (options.id) {
  370. this.order_id = options.id;
  371. this.add_form.userCenterId = options.userCenterId;
  372. uni.setNavigationBarTitle({
  373. title: '编辑订单'
  374. });
  375. this.getOrderInfoById();
  376. } else {
  377. this.add_form.currentAccountName = this.userName;
  378. }
  379. this.getAllDelivery();
  380. // 获取自提点
  381. this.getAllSelfExpressRule();
  382. },
  383. methods: {
  384. // 详情
  385. getOrderInfoById() {
  386. this.$u.api
  387. .getOrderInfoById(this.add_form.userCenterId, {
  388. orderId: this.order_id
  389. })
  390. .then(({ data }) => {
  391. uni.stopPullDownRefresh();
  392. this.order_detail = data;
  393. this.deliveryType_name = data.deliveryName;
  394. if (data.accountList && data.accountList.length) {
  395. this.accountName = data.accountList[0].accountName;
  396. }
  397. //由于订单是按照店铺拆单的
  398. // 所以在编辑订单时,增加此订单的商品时应该只能选择本店铺下的商品
  399. this.shop_id = data.shopId;
  400. this.account_shopId = data.shopId;
  401. this.add_form = {
  402. deliveryType: data.deliveryType,
  403. customerName: data.customerName,
  404. addressId: '',
  405. remark: data.remark,
  406. accountList: data.accountList,
  407. currentAccountName: data.currentAccountName,
  408. receivedMoney: data.receivedMoney,
  409. totalMoney: data.totalMoney,
  410. payMoney: data.payMoney,
  411. totalReduceMoney: data.totalReduceMoney,
  412. userCenterId: data.userCenterId,
  413. customerId: data.customerId,
  414. selfRuleId: data.selfRuleId,
  415. selfRuleData: data.selfRuleData,
  416. operatorName: data.operatorName,
  417. payType: Number(data.payType)
  418. };
  419. if (this.add_form.payType === 9) {
  420. this.payType_name = '先款后货';
  421. }
  422. if (this.add_form.deliveryType === 4) {
  423. this.add_form.deliveryType = 3;
  424. this.deliveryType_name = '物流';
  425. this.particularsType = 4;
  426. this.particularsType_name = '物流专线';
  427. }
  428. if (this.add_form.deliveryType === 5) {
  429. this.add_form.deliveryType = 3;
  430. this.deliveryType_name = '物流';
  431. this.particularsType = 5;
  432. this.particularsType_name = '物流专车';
  433. }
  434. this.goods_list = data.goodsData.map(item => {
  435. return {
  436. ...item,
  437. salePrice: item.price,
  438. title: item.goodsName,
  439. code: item.goodsCode
  440. };
  441. });
  442. if (data.customerId) {
  443. // 获取客户收货地址列表
  444. this.getAllShippingAddress(this.add_form.deliveryType !== 2 ? data.receiveData.id : '');
  445. }
  446. // if (this.add_form.deliveryType === 2) {
  447. // const selfRuleData = JSON.parse(data.selfRuleData);
  448. // } else {
  449. // const receiveData = data.receiveData;
  450. // }
  451. })
  452. .catch(err => {
  453. uni.stopPullDownRefresh();
  454. });
  455. },
  456. openSelect(key) {
  457. this[key] = true;
  458. },
  459. selGoods() {
  460. if (!this.add_form.customerId) {
  461. this.$u.toast('请选择客户');
  462. return;
  463. }
  464. uni.setStorageSync('orderGoods', JSON.stringify(this.goods_list));
  465. this.goPage('/pagesT/goods/selGoods?userCenterId=' + this.add_form.userCenterId + '&shopId=' + this.shop_id);
  466. },
  467. // 配送方式
  468. getAllDelivery() {
  469. this.$u.api
  470. .getAllDelivery({
  471. page: 1,
  472. pageSize: 100
  473. })
  474. .then(res => {
  475. this.deliveryType_list = res.data;
  476. const defaultType = res.data.find(item => item.defaultStatus === 5);
  477. if (defaultType && !this.add_form.deliveryType) {
  478. this.add_form.deliveryType = defaultType.deliveryType;
  479. this.deliveryType_name = defaultType.title;
  480. }
  481. });
  482. },
  483. openDelivery() {
  484. this.delivery_show = true;
  485. },
  486. getAllShippingAddress(id) {
  487. this.$u.api.getAllShippingAddress(this.add_form.customerId).then(res => {
  488. if (res.data.length) {
  489. this.add_form.addressId = res.data[0].id;
  490. this.address_list = res.data.map(item => {
  491. return {
  492. ...item,
  493. name: item.name || item.mobile
  494. };
  495. });
  496. } else {
  497. this.address_list = [];
  498. }
  499. });
  500. },
  501. // 获取自提点
  502. getAllSelfExpressRule() {
  503. this.$u.api.getAllSelfExpressRule().then(res => {
  504. this.self_express_list = res.data.map(item => {
  505. return {
  506. ...item,
  507. name: item.setData.name,
  508. mobile: item.setData.mobile,
  509. addressName: item.setData.provinceName + '-' + item.setData.cityName + '-' + item.setData.districtName + '-' + item.setData.address
  510. };
  511. });
  512. if (res.data.length) {
  513. this.add_form.selfRuleId = res.data[0].id;
  514. this.add_form.selfRuleData = res.data[0].setData;
  515. }
  516. });
  517. },
  518. // 配送方式
  519. deliveryTypeChange(arr) {
  520. this.add_form.deliveryType = arr[0].value;
  521. this.deliveryType_name = arr[0].label;
  522. if (arr[0].value === 1) {
  523. this.getAllShippingAddress(this.add_form.customerId);
  524. } else if (arr[0].value === 2) {
  525. if (this.self_express_list.length) {
  526. const target = this.self_express_list[0];
  527. this.add_form.selfRuleId = target.id;
  528. this.add_form.selfRuleData = target.setData;
  529. }
  530. }
  531. },
  532. payTypeChange(e) {
  533. this.payType_name = e[0].label;
  534. this.add_form.payType = e[0].value;
  535. },
  536. particularsTypeChange(e) {
  537. this.particularsType_name = e[0].label;
  538. this.particularsType = e[0].value;
  539. },
  540. addressChange(arr) {
  541. this.add_form.addressId = arr[0].value;
  542. this.address_index = this.address_list.findIndex(item => item.id === arr[0].value);
  543. },
  544. expressChange(arr) {
  545. this.add_form.selfRuleId = arr[0].value;
  546. this.add_form.selfRuleData = arr[0].setData;
  547. this.express_rule_index = this.self_express_list.findIndex(item => item.id === arr[0].value);
  548. },
  549. submit() {
  550. if (!this.goods_list.length) {
  551. this.$u.toast('请选择商品');
  552. return;
  553. }
  554. if (this.add_form.receivedMoney > 0 && !this.add_form.accountList.length) {
  555. this.$u.toast('请选择结算账户');
  556. return;
  557. }
  558. let lists = this.goods_list.map(item => {
  559. return {
  560. skuId: item.skuId,
  561. code: item.code,
  562. goodsId: item.id,
  563. buyNum: item.buyNum,
  564. otherNum: item.otherNum,
  565. shopId: item.shopId,
  566. basicGoodsId: item.basicGoodsId || item.goodsBasicId,
  567. goodsName: item.title,
  568. unitName: item.unitName,
  569. specGroup: item.specGroup,
  570. inventory: item.inventory,
  571. salePrice: item.salePrice,
  572. subMoney: item.salePrice * item.buyNum,
  573. shopName: item.shopName,
  574. goodsImages: item.images[0],
  575. brandId: item.brandId,
  576. brandName: item.brandName,
  577. categoryPath: item.categoryPath,
  578. categoryName: item.categoryName,
  579. conversion: item.conversion,
  580. barCode: item.barCode,
  581. storageCode: item.storage,
  582. warehouseId: item.warehouseId,
  583. originPrice: item.originPrice,
  584. specType: item.specType,
  585. supplierId: item.supplierId,
  586. supplierName: item.supplierName,
  587. isEq: item.isEq
  588. };
  589. });
  590. let params = {
  591. ...this.add_form,
  592. totalMoney: this.totalMoney,
  593. payMoney: this.payMoney,
  594. operatorName: this.userName
  595. };
  596. if (this.particularsType) {
  597. params.deliveryType = this.particularsType;
  598. }
  599. // this.$refs.uForm.validate(valid => {
  600. // if (valid) {
  601. if (this.order_id) {
  602. params.goodsData = lists.map(item => {
  603. return {
  604. ...item,
  605. goodsCode: item.code,
  606. images: [item.goodsImages],
  607. price: item.salePrice,
  608. totalMoney: item.subMoney
  609. };
  610. });
  611. this.sub_load = true;
  612. this.$u.api
  613. .newOrderEdit(this.order_id, {
  614. ...this.order_detail,
  615. ...params
  616. })
  617. .then(res => {
  618. this.sub_load = false;
  619. this.$u.toast('修改成功');
  620. setTimeout(() => {
  621. uni.navigateBack();
  622. }, 1500);
  623. })
  624. .catch(res => {
  625. this.sub_load = false;
  626. });
  627. } else {
  628. params.lists = lists;
  629. this.sub_load = true;
  630. this.$u.api
  631. .newAddOrder(params)
  632. .then(res => {
  633. this.sub_load = false;
  634. this.$u.toast('下单成功');
  635. setTimeout(() => {
  636. uni.navigateBack();
  637. }, 1500);
  638. })
  639. .catch(res => {
  640. this.sub_load = false;
  641. });
  642. }
  643. // }
  644. // });
  645. },
  646. delGoods(index) {
  647. this.goods_list.splice(index, 1);
  648. if (!this.goods_list.length) {
  649. this.sel_pop = false;
  650. }
  651. },
  652. addBuyNumChange({ value, index }) {
  653. const target = this.$u.deepClone(this.goods_list);
  654. if (Number(value) === 0) {
  655. target.splice(index, 1);
  656. } else {
  657. target[index].buyNum = value;
  658. }
  659. this.goods_list = target;
  660. },
  661. clearGoods() {
  662. this.goods_list = [];
  663. this.sel_pop = false;
  664. },
  665. barCode() {
  666. if (!this.add_form.customerId) {
  667. this.$u.toast('请选择客户');
  668. return;
  669. }
  670. uni.scanCode({
  671. scanType: ['barCode'],
  672. success: res => {
  673. this.sendBarCode(res.result);
  674. }
  675. });
  676. },
  677. sendBarCode(result) {
  678. this.$u.api
  679. .getGoodsByBarCode({
  680. barCode: result
  681. })
  682. .then(res => {
  683. const detail = res.data.detail;
  684. const index = this.goods_list.findIndex(item => item.skuId === detail.skuId);
  685. if (index !== -1) {
  686. this.$u.toast('该商品已存在');
  687. return;
  688. } else {
  689. this.goods_list.push({
  690. ...detail,
  691. buyNum: 1
  692. });
  693. }
  694. });
  695. },
  696. // 实收输入框获取焦点
  697. receivedMoneyFocus(key) {
  698. if (!this.add_form.receivedMoney || this.add_form.receivedMoney <= 0) {
  699. this.add_form.receivedMoney = '';
  700. }
  701. },
  702. // 实收输入框失去焦点
  703. receivedMoneyBlur() {
  704. if (!this.add_form.receivedMoney || this.add_form.receivedMoney <= 0) {
  705. this.add_form.receivedMoney = 0;
  706. }
  707. },
  708. // 订单优惠输入框获取焦点
  709. totalReduceMoneyFocus(key) {
  710. if (!this.add_form.totalReduceMoney || this.add_form.totalReduceMoney <= 0) {
  711. this.add_form.totalReduceMoney = '';
  712. }
  713. },
  714. // 订单优惠输入框失去焦点
  715. totalReduceMoneyBlur() {
  716. if (!this.add_form.totalReduceMoney || this.add_form.totalReduceMoney <= 0) {
  717. this.add_form.totalReduceMoney = 0;
  718. }
  719. }
  720. },
  721. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  722. onReady() {
  723. // this.$refs.uForm.setRules(this.rules);
  724. }
  725. };
  726. </script>
  727. <style lang="scss" scoped>
  728. .top-view {
  729. background: linear-gradient($uni-color-primary, $uni-color-primary, $uni-color-primary, #f5f5f6 100%);
  730. height: 360rpx;
  731. position: fixed;
  732. left: 0;
  733. top: 0;
  734. width: 100%;
  735. z-index: -1;
  736. }
  737. .form-cont {
  738. transform: translateY(70rpx);
  739. position: relative;
  740. z-index: 1;
  741. padding-bottom: 80rpx;
  742. .form-model-view {
  743. width: 710rpx;
  744. background-color: #ffffff;
  745. margin: 16rpx auto;
  746. border-radius: 8rpx;
  747. padding: 10rpx 32rpx;
  748. .title {
  749. padding: 24rpx 0;
  750. .float_left {
  751. font-size: 28rpx;
  752. font-weight: 600;
  753. color: #2d405e;
  754. }
  755. .float_right {
  756. font-size: 28rpx;
  757. color: #879bba;
  758. }
  759. }
  760. .btn {
  761. width: 646rpx;
  762. height: 106rpx;
  763. background-color: #ecf0f7;
  764. color: #4076d6;
  765. text-align: center;
  766. line-height: 106rpx;
  767. font-size: 26rpx;
  768. border-radius: 12rpx;
  769. margin: 0 auto 24rpx;
  770. }
  771. .goods-view {
  772. text-align: left;
  773. position: relative;
  774. width: 100%;
  775. margin-bottom: 24rpx;
  776. image {
  777. width: 102rpx;
  778. height: 102rpx;
  779. border-radius: 8rpx;
  780. margin: 0 6rpx;
  781. vertical-align: middle;
  782. border: 1px solid #ecf0f7;
  783. }
  784. .more-goods {
  785. width: 102rpx;
  786. height: 102rpx;
  787. border-radius: 8rpx;
  788. margin: 0 6rpx;
  789. display: inline-block;
  790. background-color: #ecf0f7;
  791. line-height: 102rpx;
  792. text-align: center;
  793. vertical-align: middle;
  794. font-size: 22rpx;
  795. color: #4076d6;
  796. }
  797. }
  798. .form-item {
  799. line-height: 80rpx;
  800. .label {
  801. float: left;
  802. color: #879bba;
  803. }
  804. .value {
  805. float: right;
  806. width: 400rpx;
  807. text-align: right;
  808. .input-sj {
  809. border-bottom: 1px solid $uni-color-primary;
  810. }
  811. &.error-value {
  812. color: #f67778;
  813. }
  814. }
  815. &.importend-item {
  816. .label {
  817. color: #2d405e;
  818. font-weight: bold;
  819. }
  820. .value {
  821. font-family: DIN-Medium;
  822. color: #2d405e;
  823. }
  824. }
  825. }
  826. .bz-label {
  827. line-height: 80rpx;
  828. font-weight: bold;
  829. }
  830. }
  831. }
  832. .customer-view {
  833. width: 710rpx;
  834. background-color: #ffffff;
  835. margin: 0 auto 34rpx;
  836. border-radius: 8rpx;
  837. padding: 0 32rpx;
  838. .title {
  839. padding: 32rpx 0 24rpx;
  840. .float_left {
  841. font-size: 32rpx;
  842. font-weight: 600;
  843. width: calc(100% - 120rpx);
  844. color: #2d405e;
  845. }
  846. }
  847. .address-view {
  848. border-top: 1px solid #ecf0f7;
  849. line-height: 48rpx;
  850. height: 142rpx;
  851. font-size: 28rpx;
  852. .remark_cont {
  853. width: 170rpx;
  854. margin: 0 auto;
  855. line-height: 142rpx;
  856. color: #4076d6;
  857. font-size: 26rpx;
  858. }
  859. .remark_particulars {
  860. padding: 24rpx 0;
  861. padding-right: 24rpx;
  862. color: #879bba;
  863. font-size: 26rpx;
  864. position: relative;
  865. .arrow-right-icon {
  866. position: absolute;
  867. right: -10rpx;
  868. top: 50%;
  869. transform: translateY(-50%);
  870. }
  871. }
  872. }
  873. }
  874. .sel-goods-pop {
  875. padding-bottom: 1px;
  876. .pop-tit {
  877. line-height: 70rpx;
  878. background-color: #ecf0f7;
  879. padding: 0 24rpx;
  880. .float_right {
  881. font-size: 24rpx;
  882. color: #666666;
  883. .custom-icon-shanchu {
  884. font-size: 26rpx;
  885. margin-right: 10rpx;
  886. }
  887. }
  888. }
  889. .goods-ul {
  890. min-height: 400rpx;
  891. max-height: 600rpx;
  892. .goods-li {
  893. padding: 24rpx;
  894. position: relative;
  895. border-bottom: 1px solid #f5f5f5;
  896. .goods-name {
  897. width: 660rpx;
  898. }
  899. .goods-code {
  900. padding-top: 10rpx;
  901. font-size: 24rpx;
  902. line-height: 50rpx;
  903. color: #879bba;
  904. .price-input-view {
  905. height: 50rpx;
  906. line-height: 50rpx;
  907. padding: 0 10rpx;
  908. border: 1px solid #ecf0f7;
  909. border-radius: 8rpx;
  910. width: 212rpx;
  911. text-align: center;
  912. color: #333333;
  913. position: relative;
  914. .label {
  915. position: absolute;
  916. left: -80rpx;
  917. top: 50%;
  918. display: block;
  919. transform: translateY(-50%);
  920. }
  921. .price-input {
  922. width: 150rpx;
  923. height: 50rpx;
  924. display: inline-block;
  925. vertical-align: middle;
  926. margin-right: 10rpx;
  927. transform: translateY(-4rpx);
  928. font-size: 24rpx;
  929. }
  930. .yuan {
  931. color: #879bba;
  932. }
  933. }
  934. }
  935. .custom-icon-shanchu {
  936. position: absolute;
  937. right: 24rpx;
  938. top: 24rpx;
  939. width: 40rpx;
  940. height: 40rpx;
  941. color: $uni-color-error;
  942. }
  943. }
  944. }
  945. .btn-view {
  946. width: 680rpx;
  947. height: 70rpx;
  948. line-height: 70rpx;
  949. border-radius: 10rpx;
  950. background-color: $uni-color-primary;
  951. color: #ffffff;
  952. text-align: center;
  953. margin: 20rpx auto;
  954. }
  955. }
  956. </style>