batchOrderAdd.vue 32 KB

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