bigOrderAdd.vue 29 KB

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