workOrder.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="app-content">
  3. <view class="affirm-page">
  4. <view class="affirm-view overscroll">
  5. <form>
  6. <view class="module-com input-line-wrap" style="position:relative;">
  7. <tui-list-cell class="line-cell" :arrow="true">
  8. <view class="tui-title required">品种</view>
  9. <picker mode="selector" :value="form.kindId" :range="kindListData" range-key="name" @change="changeKindFn" class="tui-input" >
  10. <input v-model="form.kindId" name="kindId" type="text" hidden />
  11. <view v-if="form.kindId" style="height:45upx;" >{{ kindSelectedData.name }}</view>
  12. <view class="tui-placeholder" style="height:45upx;" v-else>请选择</view>
  13. </picker>
  14. </tui-list-cell>
  15. <tui-list-cell class="line-cell" :hover="false">
  16. <view class="tui-title required">数量</view>
  17. <input v-model="form.num" placeholder-class="phcolor" class="tui-input" name="num" @focus="form.num=''" placeholder="填写数量" maxlength="50" type="number" />
  18. </tui-list-cell>
  19. <tui-list-cell class="line-cell" :hover="false" :arrow="false" >
  20. <view class="tui-title required">单价</view>
  21. <input type="digit" @focus="goodsPrice=''" :focus="true" style="width:260upx;" v-model="goodsPrice" placeholder-class="tui-placeholder" placeholder="填写金额" />
  22. <text style="color:#3385FF;font-weight:bold;">合计 ¥<text>{{orderTotalPrice}}</text></text>
  23. </tui-list-cell>
  24. <tui-list-cell class="line-cell" :hover="false" :arrow="false" v-if="form.fromType == 3 && form.hasPay == 1">
  25. <view class="tui-title">订金</view>
  26. <input type="digit" @focus="dj=''" style="width:260upx;" v-model="dj" placeholder-class="tui-placeholder" placeholder="选填"/>
  27. <text style="color:red;font-weight:bold;" v-if="Number(debtFinalPrice)>0">尾款 ¥<text>{{debtFinalPrice}}</text></text>
  28. </tui-list-cell>
  29. <tui-list-cell class="line-cell" :hover="false" :arrow="false" v-if="form.fromType == 3">
  30. <view class="tui-title">收款方式</view>
  31. <button @tap="form.hasPay = 1" class="admin-button-com middle" :class="form.hasPay == 1 ? 'blue' : 'default'">线下</button>
  32. <button @tap="form.hasPay = 2" class="admin-button-com middle" :class="form.hasPay == 2 ? 'blue' : 'default'">记欠款</button>
  33. </tui-list-cell>
  34. <tui-list-cell class="line-cell" :arrow="true" v-if="form.hasPay == 1 && form.fromType == 3">
  35. <view class="tui-title">线下渠道</view>
  36. <picker mode="selector" :value="form.payWay" :range="payWayList" range-key="name" @change="payWayChange" class="tui-input" >
  37. <input v-model="form.payWay" name="payWay" type="text" hidden />
  38. <view style="padding:6upx 0 6upx 0;">{{payWayList[payWayindex].name}}</view>
  39. </picker>
  40. </tui-list-cell>
  41. <tui-list-cell class="line-cell" :arrow="false" :hover="false">
  42. <view class="tui-title required" style="margin-bottom:46upx;">每份支数</view>
  43. <input type="number" v-model="form.flowerNum" @focus="form.flowerNum=''" style="width:350upx;margin-bottom:46upx;" name="flowerNum" placeholder-class="tui-placeholder" placeholder="每份使用花材的支数"/>
  44. </tui-list-cell>
  45. <view style="position:absolute;bottom:1upx;left:50upx;">
  46. <block v-for="(numItem, numIndex) in flowerNumList" :key="numIndex">
  47. <button class="admin-button-com mini-btn default" style="padding-top:13upx;padding-bottom:13upx;" @click="setNum(numItem.num)">{{numItem.name}}</button>
  48. </block>
  49. </view>
  50. </view>
  51. <view class="module-com input-line-wrap goods-wrap">
  52. <view class="module-tit">
  53. <span>图片</span>
  54. <span class="app-color-3"></span>
  55. </view>
  56. <view class="module-det">
  57. <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
  58. @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
  59. </htz-image-upload>
  60. </view>
  61. </view>
  62. <app-delivery-module ref="appDelivery" @changeAddress="changeAddress" />
  63. </form>
  64. </view>
  65. <view class="under-bar">
  66. <view class="price-view"></view>
  67. <button class="admin-button-com blue big" @click="confirmToSubmit">提交</button>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import TuiListCell from "@/components/plugin/list-cell";
  74. import productMins from "@/mixins/cgPlantProduct";
  75. import AppDeliveryModule from "@/components/app-delivery";
  76. import { createOrder } from "@/api/order";
  77. import { mapGetters } from "vuex";
  78. import { getUserDistance } from "@/api/express";
  79. import { getAllKind } from "@/api/kind";
  80. //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
  81. import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
  82. export default {
  83. name: "plantConfirm",
  84. components: {
  85. TuiListCell,AppDeliveryModule,htzImageUpload
  86. },
  87. mixins: [productMins],
  88. data () {
  89. return {
  90. headers:{token:''},
  91. selectJobType: "addOrder",
  92. form: {
  93. fromType:'3',
  94. hasPay:1,
  95. payWay:0,
  96. sendCost:'',
  97. kindId:'',
  98. cover:[],
  99. num:1,
  100. flowerNum:''
  101. },
  102. goodsPrice:'',
  103. payWayindex:0,
  104. payWayList:[{name:"线下微信",id:0},{name:"线下支付宝",id:1},{name:"现金",id:4},{name:"银行卡",id:5}],
  105. kindListData:[],
  106. kindSelectedData:{},
  107. currentImgData:[],
  108. dj:'',
  109. numSelectedData:{num:0,name:0},
  110. flowerNumList:[{num:9,name:9},{num:11,name:11},{num:16,name:16},{num:33,name:33},{num:52,name:52},{num:66,name:66},{num:99,name:99}]
  111. };
  112. },
  113. onLoad (option) {
  114. const token = uni.getStorageSync('token')
  115. this.headers.token = token
  116. },
  117. onShow(){
  118. },
  119. onUnload(){
  120. },
  121. computed: {
  122. ...mapGetters(["getLoginInfo"]),
  123. orderTotalPrice(){
  124. let price = 0
  125. if(Number(this.goodsPrice) > 0 && Number(this.form.num) >0 ){
  126. price = Number(this.goodsPrice)*Number(this.form.num)
  127. price = parseFloat(price.toFixed(2))
  128. }
  129. return price
  130. },
  131. debtFinalPrice(){
  132. let price = 0
  133. if(Number(this.dj) > 0 && Number(this.orderTotalPrice)){
  134. price = Number(this.orderTotalPrice) - Number(this.dj)
  135. price = parseFloat(price.toFixed(2))
  136. }
  137. return price
  138. }
  139. },
  140. methods: {
  141. setNum(num){
  142. this.form.flowerNum = num
  143. },
  144. imgUploadSuccess(res) {
  145. var imgReturn = JSON.parse(res.data)
  146. if(imgReturn.code == 1){
  147. this.currentImgData.push(imgReturn.data.smallUrl)
  148. this.form.cover.push(imgReturn.data.shortUrl)
  149. }
  150. },
  151. imgDeleteFn(res){
  152. const index = res.index
  153. this.form.cover.splice(index,1)
  154. },
  155. init() {
  156. this.getKindDataFn()
  157. },
  158. async getKindDataFn() {
  159. await getAllKind({flower:1}).then(res => {
  160. if (this.$util.isEmpty(res.data)){
  161. return false;
  162. }
  163. this.kindListData = res.data.list ? res.data.list : []
  164. if(this.kindListData && this.kindListData[0] && this.kindListData[0].id){
  165. this.form.kindId = this.kindListData[0].id||''
  166. let name = this.kindListData[0].name||''
  167. this.kindSelectedData = {name}
  168. }
  169. });
  170. },
  171. changeKindFn(e) {
  172. this.kindSelectedData = this.kindListData[e.detail.value];
  173. this.form.kindId = this.kindSelectedData.id;
  174. },
  175. payWayChange(e){
  176. let index = e.detail.value
  177. this.payWayindex = index
  178. this.form.payWay = this.payWayList[index].id
  179. },
  180. //计算客户距离和运费
  181. changeAddress() {
  182. return false
  183. let lat = this.$refs.appDelivery.region.latitude
  184. let long = this.$refs.appDelivery.region.longitude
  185. getUserDistance({ lat: lat, lng: long }).then(res => {
  186. this.freightPrice = res.data.fee
  187. this.showDistance = res.data.showDistance
  188. })
  189. },
  190. confirmToSubmit () {
  191. let that = this
  192. if(this.$util.isEmpty(this.goodsPrice) || Number(this.goodsPrice)<=0){
  193. this.$msg("请输入单价")
  194. return false
  195. }
  196. //允许不传图片
  197. if (!this.$util.isEmpty(this.form.cover)) {
  198. if(Array.isArray(this.form.cover)){
  199. this.form.cover = this.form.cover[0]
  200. }
  201. }
  202. if(this.$util.isEmpty(this.form.num) || Number(this.form.num)<0){
  203. this.$msg('请填写数量')
  204. return false
  205. }
  206. if(Number(this.orderTotalPrice) == 0){
  207. this.$msg('请填写单价')
  208. return false
  209. }
  210. if(Number(this.dj)>0){
  211. if(Number(this.dj) >= Number(this.orderTotalPrice)){
  212. this.$msg('订金要小于总金额')
  213. return false
  214. }
  215. }
  216. if(this.$util.isEmpty(this.form.flowerNum) || Number(this.form.flowerNum)<=0){
  217. this.$msg('请选择每份用材数量')
  218. return false
  219. }
  220. if(this.$util.isEmpty(this.$refs.appDelivery.form.bookName)){
  221. this.$msg('请填写订花人姓名')
  222. return false
  223. }
  224. let modifyPrice = Number(this.goodsPrice)*Number(this.form.num)
  225. modifyPrice = modifyPrice.toFixed(2)
  226. //这里前后顺序有影响哦,不要随意调动
  227. that.form = {...that.form,...that.$refs.appDelivery.form}
  228. that.$util.confirmModal({content:'确认提交?'},() => {
  229. uni.showLoading({mask:true})
  230. let name = that.kindSelectedData.name ? that.kindSelectedData.name : ''
  231. createOrder({...that.form,unitGoodsPrice:this.goodsPrice,modifyPrice:modifyPrice,dj:this.dj,name:name,kindName:name}).then((res) => {
  232. uni.hideLoading()
  233. that.pageTo({url: '/admin/order/workOrderResult',type:2,query:{id:res.data.id}})
  234. })
  235. })
  236. }
  237. },
  238. };
  239. </script>
  240. <style lang="scss" scoped>
  241. .module-com {
  242. margin-bottom: 20upx;
  243. background-color: #fff;
  244. color: $fontColor2;
  245. .module-tit {
  246. padding: 20upx 30upx;
  247. font-size: 28upx;
  248. }
  249. .module-det {
  250. padding: 0 30upx;
  251. }
  252. }
  253. .admin-button-com {
  254. margin-right: 20upx;
  255. }
  256. .affirm-page {
  257. position: relative;
  258. height: 100%;
  259. display: flex;
  260. flex-direction: column;
  261. .affirm-view {
  262. flex: 1;
  263. margin-bottom:90upx;
  264. padding: 20upx;
  265. background-color: #f0f2f6;
  266. .commodity-view {
  267. display: flex;
  268. flex-direction: column;
  269. .commodity-list {
  270. padding: 20upx;
  271. .commodity-item {
  272. display: flex;
  273. margin-bottom: 20upx;
  274. .item-icon {
  275. flex-shrink: 0;
  276. width: 140upx;
  277. height: 140upx;
  278. }
  279. .item-info {
  280. display: flex;
  281. flex-direction: column;
  282. justify-content: center;
  283. flex: 1;
  284. margin-left: 20upx;
  285. .info-line {
  286. margin-bottom: 20upx;
  287. display: flex;
  288. justify-content: space-between;
  289. align-items: flex-end;
  290. .item-name {
  291. color: #666;
  292. font-size: 28upx;
  293. }
  294. .item-price {
  295. color: #333;
  296. font-size: 22upx;
  297. .price {
  298. font-size: 32upx;
  299. font-weight: bold;
  300. }
  301. }
  302. .item-type {
  303. color: #999;
  304. font-size: 24upx;
  305. }
  306. .item-count {
  307. color: #666;
  308. font-size: 24upx;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. .summary-bar {
  315. padding: 0 20upx;
  316. height: 90upx;
  317. display: flex;
  318. align-items: center;
  319. justify-content: space-between;
  320. border-top: 1upx solid #eeeeee;
  321. .operate-view {
  322. display: flex;
  323. align-items: center;
  324. color: #3385ff;
  325. font-size: 26upx;
  326. .iconfont {
  327. margin-right: 20upx;
  328. font-size: 40upx;
  329. }
  330. }
  331. .describe-view {
  332. display: flex;
  333. align-items: center;
  334. color: #333;
  335. font-size: 24upx;
  336. .price {
  337. font-weight: bold;
  338. font-size: 36upx;
  339. }
  340. }
  341. }
  342. }
  343. .module-com {
  344. background-color: #fff;
  345. margin-bottom: 20upx;
  346. border-radius: 10upx;
  347. overflow: hidden;
  348. .tab-box{
  349. padding: 10upx 30upx 30upx;
  350. .tab{
  351. width: 49%;
  352. height: 70upx;
  353. color: #a2a2a2;
  354. border: 1upx solid #dcdcdc;
  355. border-radius: 10upx;
  356. font-size: 28upx;
  357. font-weight: 700;
  358. &.active{
  359. color: #ff4d4d;
  360. border: 1upx solid #ff4d4d;
  361. }
  362. }
  363. }
  364. .member-wrap {
  365. .member-det {
  366. font-size: 24upx;
  367. margin-left: 20upx;
  368. }
  369. }
  370. .remark-wrap {
  371. align-items: flex-start;
  372. .remark {
  373. height: 240upx;
  374. }
  375. }
  376. }
  377. }
  378. .under-bar {
  379. display: flex;
  380. z-index:99999;
  381. justify-content: space-between;
  382. align-items: center;
  383. padding: 0 20upx;
  384. position: fixed;
  385. bottom:0;
  386. /* 手机mobile屏幕小于1000px */
  387. @media screen and (max-width: 1100px) {
  388. width: 100%;
  389. }
  390. /* 收银台cashier屏幕大于1000px */
  391. @media screen and (min-width:1100px) {
  392. width: 40%;
  393. }
  394. height: 100upx;
  395. background-color: #fff;
  396. box-shadow: 0upx -1upx 6upx 0upx rgba(4, 0, 0, 0.06);
  397. .price-view {
  398. display: flex;
  399. align-items: center;
  400. font-size: 24upx;
  401. .price-title {
  402. color: #333;
  403. }
  404. .price-number {
  405. margin: 0 20upx;
  406. color: #ff2842;
  407. .large {
  408. font-size: 40upx;
  409. }
  410. }
  411. }
  412. .admin-button-com {
  413. width: 200upx;
  414. }
  415. }
  416. }
  417. </style>