add.vue 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. <template>
  2. <view class="order">
  3. <view class="example">
  4. <u-form labelPosition="left" :model="orderForm" :rules="rules" ref="form1" labelWidth='120'>
  5. <!-- 下单日期 -->
  6. <u-form-item :label="$t('order.orderDate')" borderBottom prop="setDate">
  7. <!-- <u-input readonly v-model="orderForm.setDate" border="none"
  8. :placeholder="$t('base.common.placeholderS')+$t('order.orderDate')" /> -->
  9. <span>{{orderForm.setDate}}</span>
  10. </u-form-item>
  11. <!-- 有效日期 -->
  12. <u-form-item v-if="orderForm.orderType !== '1'" :label="$t('order.endDate')" borderBottom prop="orderValidDate"
  13. @click="showEndDateCalendar = true">
  14. <!-- <u-input readonly v-model="orderForm.orderValidDate" border="none"
  15. :placeholder="$t('base.common.placeholderS')+$t('order.endDate')" /> -->
  16. <span>{{orderForm.orderValidDate}}</span>
  17. </u-form-item>
  18. <!-- 选择企业 -->
  19. <u-form-item :label="$t('order.enterprise')" borderBottom prop="tenantId"
  20. @click="showPopup('popupTenantId')">
  21. <!-- <u-input readonly v-model="orderForm.tenantName" border="none"
  22. :placeholder="$t('base.common.placeholderS')+$t('order.enterprise')" /> -->
  23. <span>{{orderForm.tenantName}}</span>
  24. </u-form-item>
  25. <!-- 临时/固定 -->
  26. <u-form-item :label="$t('order.orderType')" borderBottom prop="orderType"
  27. @click="showPopup('popupOrderType')">
  28. <!-- <u-input readonly v-model="orderForm.orderTypeName" border="none"
  29. :placeholder="$t('base.common.placeholderS')+$t('order.orderType')" /> -->
  30. <span>{{orderForm.orderTypeName}}</span>
  31. </u-form-item>
  32. <!-- 业务类型 -->
  33. <!-- <u-form-item :label="$t('order.vehicleType')" borderBottom prop="vehicleType"
  34. @click="showPopup('popupVehicleType')">
  35. <u-input readonly v-model="orderForm.vehicleTypeName" border="none"
  36. :placeholder="$t('base.common.placeholderS')+$t('order.vehicleType')" />
  37. </u-form-item> -->
  38. <u-form-item :label="$t('order.vehicleType')" borderBottom prop="vehicleType">
  39. <!-- <u-radio-group v-model="orderForm.vehicleType" @change="onVehicleTypeConfirm" placement="row"
  40. class="p-input">
  41. <u-radio :customStyle="{marginRight: '10px'}" v-for="item in vehicleTypeOption"
  42. :key="item.value" :label="item.text" :name="item.value">
  43. </u-radio>
  44. </u-radio-group> -->
  45. <view class="uni-list">
  46. <radio-group v-model="orderForm.vehicleType" @change="onVehicleTypeConfirm" placement="row">
  47. <label class="uni-list-cell uni-list-cell-pd" v-for="item in vehicleTypeOption" :key="item.value" >
  48. <view>
  49. <radio style="transform:scale(0.8)" :value="item.value" :checked="item.value === orderForm.vehicleType"/>{{item.text}}
  50. </view>
  51. </label>
  52. </radio-group>
  53. </view>
  54. </u-form-item>
  55. <template>
  56. <u-form-item :label="$t('order.companyName')" borderBottom prop="companyId"
  57. @click="showPopup('popupCompanyId')">
  58. <span>{{orderForm.companyName}}</span>
  59. <view v-if="paymentOption && paymentOption.isShow=='1'"
  60. style="color: darkgreen;font-size: 9pt;">
  61. {{paymentOption.usableTotal}}
  62. </view>
  63. <!-- <u-input readonly v-model="orderForm.companyName" border="none"
  64. :placeholder="$t('base.common.placeholderS')+$t('order.companyName')">
  65. <template slot="suffix">
  66. <view v-if="paymentOption && paymentOption=='1'"
  67. style="color: darkgreen;font-size: 9pt;">
  68. {{paymentOption.usableTotal}}
  69. </view>
  70. </template>
  71. </u-input> -->
  72. </u-form-item>
  73. <!-- <view v-if="paymentOption && paymentOption.isShow=='1'"
  74. style="display: flex;flex-direction: row;justify-content:flex-end;">
  75. <view style="color: red;font-size: 9pt;">{{$t('order.allTotal')}}:{{paymentOption.total}}
  76. {{$t('order.waitTotal')}}:{{paymentOption.waitTotal}}
  77. </view>
  78. </view> -->
  79. <view v-if="paymentOption && paymentOption.isShow=='1'"
  80. style="display: flex;flex-direction:justify-content:flex-end;flex-direction: column;
  81. text-align: end;">
  82. <view style="color: red;font-size: 9pt;">
  83. {{$t('order.allTotal')}}:{{paymentOption.total}}
  84. </view>
  85. <view style="color: red;font-size: 9pt;">
  86. {{$t('order.waitTotal')}}:{{paymentOption.waitTotal}}
  87. </view>
  88. <view style="color: red;font-size: 9pt;">
  89. {{$t('order.source')}}:{{paymentOption.companyName}}
  90. </view>
  91. </view>
  92. <!-- <u-form-item :label="$t('order.materialName')" borderBottom prop="materialId"
  93. @click="showPopup('popupmaterialId')"> -->
  94. <u-form-item :label="$t('order.materialName')" borderBottom prop="materialId" @click="selectMater">
  95. <u-input v-model="orderForm.materialName" border="none"
  96. :placeholder="$t('base.common.placeholderS')+' '+$t('order.materialName')" />
  97. </u-form-item>
  98. </template>
  99. <!-- 件数 -->
  100. <u-form-item v-if="orderForm.measureUnit=='104'" :label="$t('order.pieceNumber')" borderBottom
  101. prop="pieceNumber">
  102. <!-- <u-input v-model="orderForm.pieceNumber" border="none" type='digit'
  103. :placeholder="$t('base.common.placeholderI')+$t('order.pieceNumber')">
  104. </u-input> -->
  105. <span>{{orderForm.pieceNumber}}</span>
  106. </u-form-item>
  107. <!-- 订单数量 -->
  108. <u-form-item v-if="orderForm.vehicleType != '102'" :label="$t('order.orderNumber')" borderBottom prop="orderNumber">
  109. <u-input v-model="orderForm.orderNumber" border="none" type='digit'
  110. :placeholder="$t('base.common.placeholderI')+$t('order.orderNumber')" @focus="onOrderNumberFocus">
  111. <template slot="suffix">
  112. <view v-if="paymentOption"
  113. :style="'font-size: 9pt;font-weight: bold;'+(paymentOption.companyClientType=='109'?'color: green;':'color: red;')">
  114. {{paymentOption.companyClientType=='109' && orderForm.kind=='101'?$t('customer_meter.unitB'):$t('customer_meter.unitT')}}
  115. </view>
  116. </template>
  117. </u-input>
  118. </u-form-item>
  119. <u-form-item v-if="orderForm.orderType != '4'" :label="$t('order.vehicle')" borderBottom
  120. prop="vehicle" @click="toSelectVehicle">
  121. <u-input v-model="orderForm.vehicle" border="none" disabled disabledColor="#ffffff"
  122. :placeholder="$t('base.common.placeholderS')+' '+$t('order.vehicle')"></u-input>
  123. <u-icon slot="right" name="arrow-right"></u-icon>
  124. </u-form-item>
  125. <u-form-item v-if="orderForm.orderType != '4'" :label="$t('order.idcard')" borderBottom
  126. prop="vehicle" @click="toSelectVehicle">
  127. <u-input v-model="orderForm.idcard" border="none" disabled disabledColor="#ffffff"
  128. :placeholder="$t('base.common.placeholderS')+' '+$t('order.idcard')"></u-input>
  129. <u-icon slot="right" name="arrow-right"></u-icon>
  130. </u-form-item>
  131. <u-form-item v-if="orderForm.vehicleType != '102'" :label="$t('order.salePoint')" borderBottom prop="salePoint">
  132. <span>{{orderForm.saleBlockName}}</span>
  133. </u-form-item>
  134. <u-form-item v-if="paymentOption && paymentOption.isFlag=='1'" :label="$t('order.orderRelease')" borderBottom prop="releaseUponPayment">
  135. <view class="uni-list">
  136. <radio-group v-model="orderForm.releaseUponPayment" @change="onReleaseUponPaymentConfirm" placement="row">
  137. <label class="uni-list-cell uni-list-cell-pd" v-for="item in releaseUponPaymentOption" :key="item.value" >
  138. <radio style="transform:scale(0.8)" :value="item.value" :checked="item.value === orderForm.releaseUponPayment"/>{{item.text}}
  139. </label>
  140. </radio-group>
  141. </view>
  142. </u-form-item>
  143. <u-form-item v-if="paymentOption && paymentOption.isFlag=='1'" :label="$t('order.isIntima')" borderBottom prop="isIntima">
  144. <view class="uni-list">
  145. <radio-group v-model="orderForm.isIntima" @change="onisIntimaConfirm" placement="row">
  146. <label class="uni-list-cell uni-list-cell-pd" v-for="item in isIntimaOption" :key="item.value" >
  147. <radio style="transform:scale(0.8)" :value="item.value" :checked="item.value === orderForm.isIntima"/>{{item.text}}
  148. </label>
  149. </radio-group>
  150. </view>
  151. </u-form-item>
  152. <u-form-item :label="$t('order.phone')" borderBottom prop="phone">
  153. <u--input v-model="orderForm.phone" border="none" type="number"
  154. :placeholder="$t('base.common.placeholderI')+$t('order.phone')">
  155. </u--input>
  156. </u-form-item>
  157. <!-- <u-form-item :label="$t('order.axle')" borderBottom prop="axle">
  158. <u--input v-model="orderForm.axle" border="none"
  159. :placeholder="$t('base.common.placeholderI')+$t('order.axle')">
  160. </u--input>
  161. </u-form-item> -->
  162. <u-form-item v-if="orderForm.orderType == '1' "
  163. :label="$t('order.transportType')" borderBottom prop="transporterType"
  164. @click="showPopup('popupTransporterTypeId')">
  165. <span>{{orderForm.transporterTypeName}}</span>
  166. <!-- <u-input readonly v-model="orderForm.transporterTypeName" border="none"
  167. :placeholder="$t('base.common.placeholderS')+$t('order.transportType')" /> -->
  168. </u-form-item>
  169. <u-form-item v-if="orderForm.orderType == '1' "
  170. :label="$t('order.transporter')" borderBottom prop="transporterId"
  171. @click="showPopup('popupTransporterId')">
  172. <!-- <u-input readonly v-model="orderForm.transporterName" border="none"
  173. :placeholder="$t('base.common.placeholderS')+$t('order.transporter')" /> -->
  174. <span>{{orderForm.transporterName}}</span>
  175. </u-form-item>
  176. <u-form-item :label="$t('order.bisectorNumber')" borderBottom prop="bisectorNumber">
  177. <u-input v-model="orderForm.bisectorNumber" border="none"
  178. :placeholder="$t('base.common.placeholderI')+$t('order.bisectorNumber')" />
  179. </u-form-item>
  180. <u-form-item v-if="orderForm.vehicleType == '101'" :label="$t('order.projectName')" borderBottom prop="popupProjectId"
  181. @click="showPopup('popupProjectId')">
  182. <span>{{ orderForm.projectName }}</span>
  183. </u-form-item>
  184. <u-form-item :label="$t('order.remarks')" borderBottom prop="remarks">
  185. <u-input v-model="orderForm.remark" border="none"
  186. :placeholder="$t('base.common.placeholderI')+$t('order.remarks')" />
  187. </u-form-item>
  188. </u-form>
  189. <view style="margin: 16px 0;">
  190. <button class="bind-btn" @click="submit('form1')">{{$t('base.common.submit')}}
  191. </button>
  192. </view>
  193. </view>
  194. <u-toast ref="loadingToast"></u-toast>
  195. <CarKeyboard :show.sync="carKeyboardShow" :vehicleNo="orderForm.vehicle" @confirm="onKeyBoardConfirm"
  196. vehicleType="car"></CarKeyboard>
  197. <!-- 下单日期 -->
  198. <u-calendar color="#4680F9" round='25' :show="showSetDateCalendar" @confirm="onSetDateConfirm"
  199. @close="showSetDateCalendar=false"></u-calendar>
  200. <!-- 有效日期 -->
  201. <u-datetime-picker :show="showEndDateCalendar" v-model="defaultEndDate" :defaultDate="defaultEndDate"
  202. mode="datetime" @confirm="onEndDateConfirm" @close="showEndDateCalendar=false" />
  203. <!-- <u-calendar color="#4680F9" :defaultDate="defaultEndDate" :show="showEndDateCalendar"
  204. @confirm="onEndDateConfirm" @close="showEndDateCalendar=false" /> -->
  205. <!-- 临时或固定 -->
  206. <PopupSelect ref="popupOrderType" :option="orderTypeOption.filter((item)=>{return item.isShow==true})" @onConfirm="onOrderTypeConfirm" />
  207. <!-- 业务类型 -->
  208. <!-- <PopupSelect ref="popupVehicleType" :option="vehicleTypeOption" @onConfirm="onVehicleTypeConfirm" /> -->
  209. <!-- 客户 -->
  210. <PopupSelect ref="popupCompanyId" :hasSearch='false' :option="companyOption" @onConfirm="onCompanyConfirm" />
  211. <PopupSelect ref="popupTransporterId" :hasSearch='false' :option="transporterOption"
  212. @onConfirm="onTransporterConfirm" />
  213. <!--项目-->
  214. <PopupSelect ref="popupProjectId" kind="m" :hasSearch='false' :option="projectTypeOption"
  215. @onConfirm="onProjectTypeConfirm" />
  216. <!-- 原料 -->
  217. <PopupSelect ref="popupmaterialId" kind="m" :hasSearch='false' :option="materialOption"
  218. @onConfirm="onProductConfirm" />
  219. <PopupSelect ref="popupTransporterTypeId" kind="m" :hasSearch='false' :option="transporterTypeOption"
  220. @onConfirm="onTransporterTypeConfirm" />
  221. <!-- 企业选项 -->
  222. <PopupSelect ref="popupTenantId" :hasSearch='false' :option="tenantOption" @onConfirm="onTenantConfirm" />
  223. <!-- 销售点 -->
  224. <!-- <PopupSelect ref="salePoint" :hasSearch='false' :option="salePointOption" @onConfirm="onSalePointConfirm" /> -->
  225. </view>
  226. </template>
  227. <script>
  228. import PopupSelect from '../../components/popup-select/index'
  229. import dayjs from 'dayjs'
  230. import CarKeyboard from '../../components/carKeyboard/carKeyboard'
  231. import {
  232. getTenantCacheList,
  233. getOrderType,
  234. } from '../../utils/util.js'
  235. import {
  236. saveOrder,
  237. getOption,
  238. getMaterialsByCompany,
  239. getSalesMaterByCompany,
  240. getSalePointByCompany
  241. } from '../../api/order'
  242. import value from '../../uni_modules/uview-ui/components/u-text/value'
  243. export default {
  244. components: {
  245. CarKeyboard,
  246. PopupSelect
  247. },
  248. data() {
  249. return {
  250. carKeyboardShow: false,
  251. start: dayjs().format('YYYY-MM-DD'),
  252. orderForm: {
  253. kind: "",
  254. setDate: dayjs().format('YYYY-MM-DD'), //订单日期
  255. orderValidDate: dayjs().add(30, 'day').format('YYYY-MM-DD HH:mm:ss'), //有效日期
  256. tenantId: '', //企业
  257. orderType: '1', //订单类型
  258. companyId: '', //客商
  259. materialId: "", //物料
  260. orderNumber: "0", //数量
  261. vehicle: '', //车号
  262. driverId: '', //司机id\
  263. vehicleType: '1',
  264. xfFlag: '',
  265. phone: '',
  266. axle:'',
  267. idcard: "",
  268. driver: '',
  269. orderPiece: '', //件数
  270. tenantName: '',
  271. vehicleTypeName: '', //业务类型
  272. companyName: "", //客商
  273. materialName: "", //物料id
  274. orderTypeName: '临时订单',
  275. sourceId: "", //第三方大订单ID
  276. remark: "",
  277. bisectorNumber:"",
  278. measureUnit: '', //单位
  279. transporterType: "",
  280. transporterTypeName: "",
  281. transporterId: "", //运输单位
  282. transporterName: "",
  283. appUserType:"3",
  284. releaseUponPayment:"0",
  285. isIntima:"0",
  286. saleBlockId:"",
  287. saleBlockName:"",
  288. projectName:"",
  289. projectId:'',
  290. },
  291. rules: {
  292. orderType: [{
  293. required: true,
  294. message: this.$t('base.common.placeholderS') +' '+ this.$t('order.orderType')
  295. }],
  296. vehicleType: [{
  297. required: true,
  298. message: this.$t('base.common.placeholderS') +' '+ this.$t('order.vehicleType')
  299. }],
  300. tenantId: [{
  301. required: true,
  302. message: this.$t('base.common.placeholderS') +' '+ this.$t('order.enterprise')
  303. }],
  304. companyId: [{
  305. required: true,
  306. message: this.$t('base.common.placeholderS') +' '+ this.$t('order.companyName')
  307. }],
  308. materialId: [{
  309. required: true,
  310. message: this.$t('base.common.placeholderS') +' '+ this.$t('order.materialName')
  311. }],
  312. orderNumber: [{
  313. required: true,
  314. message: this.$t('base.common.placeholderI') +' '+ this.$t('order.orderNumber')
  315. }]
  316. },
  317. vehicleTypeOption: [{
  318. text: this.$t('base.common.noData'),
  319. value: null
  320. }, ],
  321. releaseUponPaymentOption:[{
  322. text: this.$t('driver.yes'),
  323. value: '1'
  324. },{
  325. text: this.$t('driver.no'),
  326. value: '0'
  327. },],
  328. isIntimaOption:[{
  329. text: this.$t('driver.have'),
  330. value: '1'
  331. },{
  332. text: this.$t('driver.notHave'),
  333. value: '0'
  334. },],
  335. orderTypeOption: [{
  336. text: this.$t("order.tempOrder"),
  337. isShow: true,
  338. value: '1',
  339. index: 1,
  340. key: "add_temp_order",
  341. },
  342. {
  343. text: this.$t("order.fixedOrder"),
  344. isShow: false,
  345. value: '2',
  346. index: 2,
  347. key: "add_fixed_order",
  348. },
  349. {
  350. text: this.$t("order.shareOrder"),
  351. isShow: false,
  352. value: '4',
  353. index: 3,
  354. key: "add_share_order",
  355. },
  356. ],
  357. paymentOption: {},
  358. //产品选项
  359. materialOption: [{
  360. text: this.$t('base.common.noData'),
  361. value: null,
  362. }], //物料选项
  363. //产品选项
  364. transporterTypeOption: [{
  365. text: this.$t('base.common.noData'),
  366. value: null,
  367. }], //物料选项
  368. //客户选项
  369. companyOption: [{
  370. text: this.$t('base.common.noData'),
  371. compvalueanyId: null
  372. }], //供应商选项
  373. //客户选项
  374. transporterOption: [{
  375. text: this.$t('base.common.noData'),
  376. compvalueanyId: null
  377. }], //供应商选项
  378. // vehicleOption:[{vehicle:this.$t('base.common.noData'),value:null}], //司机选项
  379. tenantOption: [{
  380. text: this.$t('base.common.noData'),
  381. value: null
  382. }], //企业选项
  383. salePointOption: [{
  384. text: this.$t('base.common.noData'),
  385. value: null
  386. }], //销售点
  387. projectTypeOption: [{
  388. text: this.$t('base.common.noData'),
  389. value: null
  390. }], //项目
  391. showSetDateCalendar: false,
  392. showEndDateCalendar: false,
  393. defaultEndDate: dayjs().add(30, 'day').format('YYYY-MM-DD HH:mm:ss'), //默认有效日期
  394. //业务对应的客户信息
  395. vehicleTypeCompanyList: [],
  396. //参数
  397. appParameters: {},
  398. //客户对应的物料信息
  399. companyMaterialList: [],
  400. language:'zh-Hans'
  401. }
  402. },
  403. onLoad(options) {
  404. this.bindTenant()
  405. console.log("允许操作的订单类型、", this.orderTypeOption);
  406. this.language = uni.getStorageSync('CURRENT_LANG')
  407. if(this.orderTypeOption && this.orderTypeOption.length>0){
  408. this.orderForm.orderType = this.orderTypeOption[0].value
  409. this.orderForm.orderTypeName = this.orderTypeOption[0].text
  410. }
  411. },
  412. methods: {
  413. onOrderNumberFocus() {
  414. if (this.orderForm.orderNumber == 0) {
  415. this.orderForm.orderNumber = null
  416. }
  417. },
  418. //选择品种
  419. selectMater() {
  420. uni.navigateTo({
  421. url: `/subpages/order/materSelect?option=${JSON.stringify(this.materialOption)}`
  422. })
  423. },
  424. //去选择司机
  425. toSelectVehicle() {
  426. uni.navigateTo({
  427. url: '/subpages/order/vehicle'
  428. })
  429. },
  430. //车号键盘输出
  431. onKeyBoardConfirm(id) {
  432. this.orderForm.vehicle = id
  433. },
  434. //显示车牌键盘
  435. carKeyboardOut() {
  436. this.carKeyboardShow = true
  437. },
  438. //选择订单类型后加载选项 //获取品种信息 101:销售,102:采购
  439. bindOption() {
  440. this.clear(true);
  441. console.log("订单租户信息、", this.orderForm.tenantId);
  442. if (!this.orderForm.tenantId) {
  443. console.log("订单业务租户信息");
  444. return;
  445. }
  446. var that = this;
  447. console.log("当前租户ID、", that.orderForm.tenantId);
  448. if (that.orderForm.tenantId) {
  449. let data = JSON.parse(JSON.stringify(that.orderForm))
  450. getOption(data).then(res => {
  451. console.log("查询基础数据返回、", res);
  452. if (res.statusCode === 200) {
  453. console.log("用户业务类型、", res.data.data.appVehicleType)
  454. console.log("用户客户信息、", res.data.data.appCompany)
  455. console.log("用户品种信息、", res.data.data.appMaterial)
  456. if(that.language == 'zh-Hans'){
  457. that.vehicleTypeOption = res.data.data.appVehicleType;
  458. }else{
  459. that.vehicleTypeOption = res.data.data.appVehicleType.map(item=>{
  460. return{
  461. text:item.language,
  462. value:item.value
  463. }
  464. });
  465. }
  466. if (that.vehicleTypeOption && that.vehicleTypeOption.length > 0) {
  467. that.orderForm.vehicleType = that.vehicleTypeOption[0].value
  468. that.onVehicleTypeConfirm({detail:{value:that.orderForm.vehicleType}})
  469. that.appParameters = res.data.data.appParameters
  470. that.vehicleTypeCompanyList = res.data.data.appCompany
  471. that.bindCompany();
  472. if(that.language == 'zh-Hans'){
  473. that.transporterTypeOption = res.data.data.appTransportTypeList
  474. that.transporterOption=res.data.data.appTransportList
  475. }else{
  476. that.transporterTypeOption = res.data.data.appTransportTypeList.map(item=>{
  477. return{
  478. text:item.language,
  479. value:item.value
  480. }
  481. });
  482. that.transporterOption = res.data.data.appTransportList.map(item=>{
  483. return{
  484. text:item.language,
  485. value:item.value
  486. }
  487. });
  488. }
  489. if (that.transporterTypeOption && that.transporterTypeOption.length > 0) {
  490. that.orderForm.transporterType = that.transporterTypeOption[0].value
  491. that.orderForm.transporterTypeName = that.transporterTypeOption[0].text
  492. }
  493. }
  494. }
  495. })
  496. }
  497. },
  498. //获取销售区域
  499. bindProject(){
  500. this.orderForm.saleBlockId = ''
  501. this.orderForm.saleBlockName = ''
  502. if (this.orderForm.vehicleType != '102'){
  503. getSalePointByCompany(this.orderForm.companyId).then(res=>{
  504. if (res.statusCode === 200) {
  505. this.orderForm.saleBlockId = res.data.data.id
  506. this.orderForm.saleBlockName = res.data.data.name
  507. }
  508. })
  509. }
  510. },
  511. bindCompany() {
  512. var vehicleType = this.orderForm.vehicleType;
  513. if (vehicleType && this.vehicleTypeCompanyList) {
  514. this.companyOption = [{
  515. text: this.$t('order.notSelected'),
  516. value: null
  517. }] //物料选项
  518. var companyInfos = this.vehicleTypeCompanyList.filter(function(company) {
  519. return company.vehicleType == vehicleType;
  520. });
  521. if (companyInfos && companyInfos.length > 0) {
  522. companyInfos[0].companyList.forEach(item => {
  523. this.companyOption.push({
  524. text: item.companyName,
  525. value: item.companyId
  526. })
  527. })
  528. this.orderForm.companyId = this.companyOption[1].value
  529. this.orderForm.companyName = this.companyOption[1].text
  530. this.bindMaterial();
  531. this.bindProject()
  532. }
  533. console.log("客户信息、", this.companyOption);
  534. }
  535. },
  536. bindMaterial() {
  537. var companyId = this.orderForm.companyId;
  538. this.materialOption = []
  539. this.orderForm.materialId = ''
  540. this.orderForm.materialName = ''
  541. this.paymentOption = {}
  542. if (companyId) {
  543. if(this.orderForm.vehicleType == '101'){
  544. getSalesMaterByCompany(this.orderForm).then(res => {
  545. if (res.data.code == 0) {
  546. this.paymentOption = res.data.hardInfo
  547. if (res.data.companyProductList) {
  548. res.data.companyProductList.forEach(item => {
  549. this.projectTypeOption.push({
  550. text: item.productName,
  551. value: item.id
  552. })
  553. })
  554. }
  555. if (res.data.companyList) {
  556. res.data.companyList.forEach(item => {
  557. this.transporterOption.push({
  558. text: item.name,
  559. value: item.id
  560. })
  561. })
  562. }
  563. // this.materialOption = [{
  564. // text: this.$t('order.notSelected'),
  565. // value: null
  566. // }] //物料选项
  567. var materialInfos = res.data.data;
  568. console.log("1111213213", materialInfos);
  569. if (materialInfos && materialInfos.length > 0) {
  570. materialInfos.forEach(item => {
  571. this.materialOption.push({
  572. text: item.name,
  573. value: item.id,
  574. type: item.materTypeName ? item.materTypeName : '暂无分类',
  575. kind: item.kind,
  576. measureUnit: item.measureUnit
  577. })
  578. })
  579. // if (this.materialOption[1] && this.materialOption.length == 2) {
  580. // this.orderForm.materialId = this.materialOption[1].value
  581. // this.orderForm.materialName = this.materialOption[1].text
  582. // this.orderForm.kind = this.materialOption[1].kind
  583. // this.orderForm.measureUnit = this.materialOption[1].measureUnit
  584. // }
  585. }
  586. console.log("品种信息、", this.materialOption);
  587. }
  588. })
  589. }else{
  590. getMaterialsByCompany(this.orderForm).then(res => {
  591. if (res.data.code == 0) {
  592. this.paymentOption = res.data.hardInfo
  593. if (res.data.companyList) {
  594. res.data.companyList.forEach(item => {
  595. this.transporterOption.push({
  596. text: item.name,
  597. value: item.id
  598. })
  599. })
  600. }
  601. // this.materialOption = [{
  602. // text: this.$t('order.notSelected'),
  603. // value: null
  604. // }] //物料选项
  605. var materialInfos = res.data.data;
  606. console.log("1111213213", materialInfos);
  607. if (materialInfos && materialInfos.length > 0) {
  608. materialInfos.forEach(item => {
  609. this.materialOption.push({
  610. text: item.name,
  611. value: item.id,
  612. type: item.materTypeName ? item.materTypeName : '暂无分类',
  613. kind: item.kind,
  614. measureUnit: item.measureUnit
  615. })
  616. })
  617. // if (this.materialOption[1] && this.materialOption.length == 2) {
  618. // this.orderForm.materialId = this.materialOption[1].value
  619. // this.orderForm.materialName = this.materialOption[1].text
  620. // this.orderForm.kind = this.materialOption[1].kind
  621. // this.orderForm.measureUnit = this.materialOption[1].measureUnit
  622. // }
  623. }
  624. console.log("品种信息、", this.materialOption);
  625. }
  626. })
  627. }
  628. }
  629. },
  630. //
  631. bindTenant() {
  632. this.tenantOption = getTenantCacheList();
  633. if (this.tenantOption.length > 0) {
  634. this.orderForm.tenantId = this.tenantOption[0].value
  635. this.orderForm.tenantName = this.tenantOption[0].text
  636. }
  637. this.bindOption();
  638. },
  639. //提交订单
  640. submit(ref) {
  641. let _this = this
  642. console.log("提交的订单信息、", this.orderForm);
  643. var isCheckVehicle = true
  644. if (this.orderForm.vehicleType == "101" &&
  645. this.appParameters &&
  646. this.orderForm.transporterType &&
  647. this.appParameters.VEHICLE_ALLOW_EMPTY_TRANSPORTER_TYPE &&
  648. this.appParameters.VEHICLE_ALLOW_EMPTY_TRANSPORTER_TYPE.indexOf(this.orderForm.transporterType) > -1) {
  649. isCheckVehicle = false
  650. }
  651. if (this.orderForm.orderType != "4" && !this.orderForm.vehicle && isCheckVehicle == true) {
  652. uni.showToast({
  653. title: this.$t('base.common.placeholderI') + this.$t('order.vehicle'),
  654. icon: 'none',
  655. duration: 2000
  656. })
  657. return;
  658. }
  659. if (this.orderForm.vehicleType !='102' && (!this.orderForm.orderNumber || this.orderForm.orderNumber == '0')) {
  660. uni.showToast({
  661. title: this.$t('base.common.placeholderI') + this.$t('order.orderNumber'),
  662. icon: 'none',
  663. duration: 2000
  664. })
  665. return;
  666. }
  667. this.$refs[ref].validate().then(() => {
  668. let data = JSON.parse(JSON.stringify(_this.orderForm))
  669. console.log("保存订单信息、", data);
  670. this.$refs.loadingToast.show({
  671. type: "loading",
  672. message: this.$t('base.common.loading'),
  673. duration: "1000000"
  674. })
  675. saveOrder(data).then(res => {
  676. this.$refs.loadingToast.hide()
  677. if (res.statusCode === 200) {
  678. uni.showModal({
  679. // title: '提示',
  680. content: this.$t("order.isContinueAddOrder"),
  681. showCancel: true,
  682. cancelText: this.$t("base.button.goBack"),
  683. confirmText: this.$t("base.button.continue"),
  684. success: function(res) {
  685. if (res.confirm) {
  686. _this.orderForm = {
  687. kind: "",
  688. setDate: dayjs().format('YYYY-MM-DD'), //订单日期
  689. orderValidDate: dayjs().add(30, 'day').format('YYYY-MM-DD HH:mm:ss'), //有效日期
  690. tenantId: '', //企业
  691. orderType: '1', //订单类型
  692. companyId: '', //客商
  693. materialId: "", //物料
  694. orderNumber: "0", //数量
  695. vehicle: '', //车号
  696. driverId: '', //司机id\
  697. vehicleType: '1',
  698. xfFlag: '',
  699. phone: '',
  700. axle:'',
  701. idcard: "",
  702. driver: '',
  703. orderPiece: '', //件数
  704. tenantName: '',
  705. vehicleTypeName: '', //业务类型
  706. companyName: "", //客商
  707. materialName: "", //物料id
  708. orderTypeName: '临时订单',
  709. sourceId: "", //第三方大订单ID
  710. remark: "",
  711. bisectorNumber:"",
  712. measureUnit: '', //单位
  713. transporterType: "",
  714. transporterTypeName: "",
  715. transporterId: "", //运输单位
  716. transporterName: "",
  717. appUserType:"3",
  718. releaseUponPayment:"0",
  719. isIntima:"0",
  720. saleBlockId:"",
  721. projectName:'',
  722. saleBlockName:"",
  723. },
  724. _this.bindTenant()
  725. console.log("允许操作的订单类型、", _this.orderTypeOption);
  726. if(_this.orderTypeOption && _this.orderTypeOption.length>0){
  727. _this.orderForm.orderType = _this.orderTypeOption[0].value
  728. _this.orderForm.orderTypeName = _this.orderTypeOption[0].text
  729. }
  730. console.log('用户点击确定');
  731. } else if (res.cancel) {
  732. console.log('用户点击取消');
  733. uni.redirectTo({
  734. url: '/subpages/order/dealerList?index=0'
  735. })
  736. }
  737. }
  738. })
  739. }
  740. })
  741. }).catch(err => {
  742. console.log('err', err);
  743. this.$refs.loadingToast.hide()
  744. })
  745. },
  746. formatOption(data) {
  747. let arr = []
  748. data.forEach(item => {
  749. arr.push({
  750. text: item.name || item.label,
  751. value: item.value || item.id
  752. })
  753. })
  754. if (arr.length) {
  755. arr.unshift({
  756. text: this.$t('order.notSelected'),
  757. value: null
  758. })
  759. } else {
  760. arr.unshift({
  761. text: this.$t('base.common.noData'),
  762. value: null
  763. })
  764. }
  765. return arr
  766. },
  767. //显示选择
  768. showPopup(refs) {
  769. this.$refs[refs].showPicker = true
  770. },
  771. //选择下单日期
  772. onSetDateConfirm(date) {
  773. this.orderForm.setDate = dayjs(date).format('YYYY-MM-DD');
  774. this.showSetDateCalendar = false;
  775. },
  776. //选择下单日期
  777. onEndDateConfirm(date) {
  778. this.orderForm.orderValidDate = dayjs(date.value).format('YYYY-MM-DD HH:mm:ss');
  779. this.showEndDateCalendar = false;
  780. },
  781. //选择订单类型
  782. onOrderTypeConfirm(value) {
  783. this.orderForm.orderType = ''
  784. this.orderForm.orderTypeName = ''
  785. if (value.value) {
  786. this.orderForm.orderType = value.value
  787. this.orderForm.orderTypeName = value.text
  788. }
  789. },
  790. //选择订单类型
  791. onVehicleTypeConfirm(value) {
  792. console.log('value',value);
  793. this.orderForm.vehicleType = value.detail.value
  794. if(this.orderForm.vehicleType == '101'){
  795. this.orderTypeOption[1].isShow = false
  796. this.orderForm.orderType = this.orderTypeOption[0].value
  797. this.orderForm.orderTypeName = this.orderTypeOption[0].text
  798. }else{
  799. this.orderTypeOption = getOrderType(this.orderTypeOption);
  800. }
  801. this.clear(false)
  802. this.bindCompany();
  803. // this.bindMaterial();
  804. },
  805. onReleaseUponPaymentConfirm(value){
  806. this.orderForm.releaseUponPayment = value.detail.value
  807. },
  808. onisIntimaConfirm(value){
  809. this.orderForm.isIntima = value.detail.value
  810. },
  811. //选择客户
  812. onCompanyConfirm(value) {
  813. this.orderForm.companyId = ''
  814. this.orderForm.companyName = ''
  815. if (value.value) {
  816. this.orderForm.companyId = value.value
  817. this.orderForm.companyName = value.text
  818. }
  819. this.bindMaterial();
  820. this.bindProject()
  821. // this.bindCompany();
  822. },
  823. onTransporterConfirm(value) {
  824. this.orderForm.transporterId = ''
  825. this.orderForm.transporterName = ''
  826. if (value.value) {
  827. this.orderForm.transporterId = value.value
  828. this.orderForm.transporterName = value.text
  829. }
  830. },
  831. onProjectTypeConfirm(value) {
  832. this.orderForm.projectName = ''
  833. this.orderForm.projectId = ''
  834. if (value.value) {
  835. this.orderForm.projectId = value.value
  836. this.orderForm.projectName = value.text
  837. }
  838. },
  839. //选择原料
  840. onProductConfirm(value) {
  841. console.log("选择的物料信息、", value);
  842. this.orderForm.materialId = ''
  843. this.orderForm.materialName = ''
  844. if (value.value) {
  845. this.orderForm.materialId = value.value
  846. this.orderForm.materialName = value.text
  847. }
  848. },
  849. //选择运输类型
  850. onTransporterTypeConfirm(value) {
  851. console.log("选择的运输类型信息、", value);
  852. this.orderForm.transporterType = ''
  853. this.orderForm.transporterTypeName = ''
  854. if (value.value) {
  855. this.orderForm.transporterType = value.value
  856. this.orderForm.transporterTypeName = value.text
  857. }
  858. },
  859. //选择销售点类型
  860. onSalePointConfirm(value) {
  861. console.log("选择的销售点信息、", value);
  862. this.orderForm.salePoint = ''
  863. this.orderForm.saleBlockName = ''
  864. if (value.value) {
  865. this.orderForm.salePoint = value.value
  866. this.orderForm.saleBlockName = value.text
  867. }
  868. },
  869. //选择企业
  870. onTenantConfirm(value) {
  871. this.orderForm.tenantId = ''
  872. this.orderForm.tenantName = ''
  873. if (value.value) {
  874. this.orderForm.tenantId = value.value
  875. this.orderForm.tenantName = value.text
  876. }
  877. this.bindOption();
  878. },
  879. clear(isVehicleType) {
  880. if (isVehicleType == true) {
  881. this.vehicleTypeOption = [{
  882. text: this.$t('base.common.noData'),
  883. value: null
  884. }]
  885. this.orderForm.vehicleType = ''
  886. }
  887. this.companyOption = [{
  888. text: this.$t('base.common.noData'),
  889. value: null
  890. }] //客户选项
  891. this.materialOption = [{
  892. text: this.$t('base.common.noData'),
  893. value: null
  894. }] //物料选项
  895. this.orderForm.companyId = ''
  896. this.orderForm.materialId = ''
  897. this.orderForm.companyName = ''
  898. this.orderForm.materialName = ''
  899. this.orderForm.orderNumber = '0';
  900. this.orderForm.driver = '';
  901. this.orderForm.driverId = '';
  902. this.orderForm.vehicle = '';
  903. },
  904. }
  905. }
  906. </script>
  907. <style lang="less" scoped>
  908. .order {
  909. padding: 32rpx;
  910. .picker-title {
  911. display: flex;
  912. padding: 0 32rpx;
  913. line-height: 84rpx;
  914. justify-content: space-between;
  915. .confirm {
  916. color: #4680F9;
  917. }
  918. }
  919. .picker-wrap {
  920. height: 440rpx;
  921. .picker-view {
  922. height: 100%;
  923. .item {
  924. display: flex;
  925. justify-content: space-between;
  926. height: 88rpx;
  927. line-height: 88rpx;
  928. padding: 0 32rpx;
  929. .text {
  930. width: 33%;
  931. }
  932. .text1 {
  933. width: 33%;
  934. text-align: center;
  935. }
  936. .text2 {
  937. width: 33%;
  938. text-align: right;
  939. }
  940. }
  941. .btn-item {
  942. display: flex;
  943. justify-content: center;
  944. height: 88rpx;
  945. line-height: 88rpx;
  946. padding: 0 32rpx;
  947. align-items: center;
  948. .add-vehicle {
  949. line-height: 64rpx;
  950. height: 64rpx;
  951. background: #4680F9;
  952. width: 25%;
  953. font-size: 28rpx;
  954. }
  955. }
  956. }
  957. }
  958. .form-wrap {
  959. height: 444rpx;
  960. padding: 0 32rpx;
  961. }
  962. }
  963. // button {
  964. // // background:linear-gradient(to right,#4680F9 0%,#00e2fa 80%,#00e2fa 100%);
  965. // background: #4680F9;
  966. // line-height: 100rpx;
  967. // color: #fff;
  968. // border: none;
  969. // }
  970. uni-button:after {
  971. border: none;
  972. }
  973. uni-input {
  974. height: 72rpx;
  975. padding: 0 10rpx 0 20rpx;
  976. }
  977. .uni-forms-item__inner {
  978. padding: 20rpx 0;
  979. }
  980. // /deep/ .u-button--primary {
  981. // background-color: #4680F9;
  982. // border-color: #4680F9;
  983. // }
  984. </style>