transOrderAdd.vue 29 KB

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