add.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. :title="form.id?'修改订单':'新建订单'" @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
  7. <u-cell-group v-show='current==0'>
  8. <u-cell title="项目名称" arrow-direction="down">
  9. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.projectName"
  10. @click.native="selectProjectShow"></u--input>
  11. </u-cell>
  12. <u-cell title="选择合同" arrow-direction="down">
  13. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.contractName"
  14. @click.native="selectContractShow"></u--input>
  15. </u-cell>
  16. <u-cell arrow-direction="down">
  17. <view slot="title">
  18. <text class="required-mark">*</text>
  19. <text>销售类型</text>
  20. </view>
  21. <uni-data-picker v-model="form.saleType" slot="value" placeholder="请选择" :localdata="order_type">
  22. </uni-data-picker>
  23. </u-cell>
  24. <u-cell title="销售部门" arrow-direction="down">
  25. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.salesDeptName"
  26. @click.native="salesDeptShow"></u--input>
  27. </u-cell>
  28. <u-cell title="合同编号" arrow-direction="down">
  29. <u--input slot="value" :disabled="true" placeholder="请输入" border="surround"
  30. v-model="form.contractNumber"></u--input>
  31. </u-cell>
  32. <u-cell arrow-direction="down">
  33. <view slot="title">
  34. <text class="required-mark">*</text>
  35. <text>结算方式</text>
  36. </view>
  37. <uni-data-picker v-model="form.settlementMode" slot="value" placeholder="请选择" :localdata="settlement_mode" @change="settlementModeChange">
  38. </uni-data-picker>
  39. </u-cell>
  40. <u-cell title="订单类型" arrow-direction="down">
  41. <radio-group v-model="form.needProduce" slot="value">
  42. <radio value="1" :checked="form.needProduce==1" @click="form.needProduce=1">生产性订单</radio>
  43. <radio value="0" :checked="form.needProduce==0" @click="form.needProduce=0">库存式订单</radio>
  44. <radio value="2" :checked="form.needProduce==2" @click="form.needProduce=2">无客户生产性订单</radio>
  45. </radio-group>
  46. </u-cell>
  47. <u-cell title="计价方式" arrow-direction="down">
  48. <radio-group @change="radioChange" v-model="form.pricingWay" slot="value">
  49. <radio :disabled="!!form.contractId" value="1" :checked="form.pricingWay==1">按数量计价</radio>
  50. <radio :disabled="!!form.contractId" value="2" :checked="form.pricingWay==2">按重量计价</radio>
  51. </radio-group>
  52. </u-cell>
  53. <u-cell title="自动生成采购计划" arrow-direction="down">
  54. <radio-group v-model="form.generatePurchase" slot="value">
  55. <radio value="1" :checked="form.generatePurchase==1" @click="form.generatePurchase=1">是</radio>
  56. <radio value="0" :checked="form.generatePurchase==0" @click="form.generatePurchase=0">否</radio>
  57. </radio-group>
  58. </u-cell>
  59. <u-cell title="自动生成生产计划" arrow-direction="down">
  60. <radio-group v-model="form.generateProduce" slot="value">
  61. <radio value="1" :checked="form.generateProduce==1" @click="form.generateProduce=1">是</radio>
  62. <radio value="0" :checked="form.generateProduce==0" @click="form.generateProduce=0">否</radio>
  63. </radio-group>
  64. </u-cell>
  65. <u-cell title="自动生成项目立项" arrow-direction="down">
  66. <radio-group v-model="form.generateProject" slot="value">
  67. <radio value="1" :checked="form.generateProject==1" @click="form.generateProject=1">是</radio>
  68. <radio value="0" :checked="form.generateProject==0" @click="form.generateProject=0">否</radio>
  69. </radio-group>
  70. </u-cell>
  71. <u-cell title="收货地址" arrow-direction="down">
  72. <u--textarea border="surround" v-model="form.receiveAddress" placeholder="请输入内容"
  73. slot="value"></u--textarea>
  74. </u-cell>
  75. <u-cell title="备注" arrow-direction="down">
  76. <u--textarea border="surround" v-model="form.remark" placeholder="请输入内容" slot="value"></u--textarea>
  77. </u-cell>
  78. </u-cell-group>
  79. <u-cell-group v-show='current==1&&form.needProduce!=2'>
  80. <u-cell arrow-direction="down">
  81. <view slot="title">
  82. <text class="required-mark">*</text>
  83. <text>客户名称</text>
  84. </view>
  85. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.partaName" @click.native="selectContactShow"></u--input>
  86. </u-cell>
  87. <u-cell title="客户统一社会信用代码" arrow-direction="down">
  88. <u--input slot="value" placeholder="请输入" border="surround"
  89. v-model="form.partaUnifiedSocialCreditCode"></u--input>
  90. </u-cell>
  91. <u-cell arrow-direction="down">
  92. <view slot="title">
  93. <text class="required-mark">*</text>
  94. <text>客户联系人</text>
  95. </view>
  96. <uni-data-picker slot="value" v-model="form.partaLinkId" placeholder="请选择" :localdata="linkList" :map="{text:'linkName',value:'id'}" @change="linkChange">
  97. </uni-data-picker>
  98. </u-cell>
  99. <u-cell arrow-direction="down">
  100. <view slot="title">
  101. <text class="required-mark">*</text>
  102. <text>客户电话</text>
  103. </view>
  104. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partaTel"></u--input>
  105. </u-cell>
  106. <u-cell title="客户传真" arrow-direction="down">
  107. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partaFax"></u--input>
  108. </u-cell>
  109. <u-cell title="客户Email" arrow-direction="down">
  110. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partaEmail"></u--input>
  111. </u-cell>
  112. <u-cell title="客户客户地址" arrow-direction="down">
  113. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partaAddress"></u--input>
  114. </u-cell>
  115. <u-cell arrow-direction="down">
  116. <view slot="title">
  117. <text class="required-mark">*</text>
  118. <text>售出方名称</text>
  119. </view>
  120. <u--input slot="value" placeholder="请输入" v-if="enterprisePage.length <= 1" border="surround" v-model="form.partbName"></u--input>
  121. <uni-data-picker v-model="form.partbName" slot="value" placeholder="请选择" :localdata="enterprisePage" :map="{text:'name',value:'name'}" @change="sourceCodeOnchange">
  122. </uni-data-picker>
  123. </u-cell>
  124. <u-cell title="售出方统一社会信用代码" arrow-direction="down">
  125. <u--input slot="value" placeholder="请输入" border="surround"
  126. v-model="form.partbUnifiedSocialCreditCode"></u--input>
  127. </u-cell>
  128. <u-cell arrow-direction="down">
  129. <view slot="title">
  130. <text class="required-mark">*</text>
  131. <text>售出方联系人</text>
  132. </view>
  133. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.partbLinkName" @click.native="selectUserShow"></u--input>
  134. </u-cell>
  135. <u-cell arrow-direction="down">
  136. <view slot="title">
  137. <text class="required-mark">*</text>
  138. <text>售出方联系电话</text>
  139. </view>
  140. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partbTel"></u--input>
  141. </u-cell>
  142. <u-cell title="售出方传真" arrow-direction="down">
  143. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partbFax"></u--input>
  144. </u-cell>
  145. <u-cell title="售出方Email" arrow-direction="down">
  146. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partbEmail"></u--input>
  147. </u-cell>
  148. <u-cell title="售出方地址" arrow-direction="down">
  149. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.partbAddress"></u--input>
  150. </u-cell>
  151. </u-cell-group>
  152. <view class="footerButton">
  153. <u-button type="default" text="返回" @click="back"></u-button>
  154. <u-button type="primary" @click="save" text="保存"></u-button>
  155. </view>
  156. <view class="" v-show="current==2">
  157. <u-cell-group>
  158. <u-cell title="总金额" arrow-direction="down">
  159. <text slot="value"> {{ form.totalAmount || 0 }}元</text>
  160. </u-cell>
  161. <u-cell title="优惠后总金额" arrow-direction="down">
  162. <u--input type="number" @blur="discountInput" slot="value"
  163. :disabled="!!form.contractId || !form.totalAmount" placeholder="请输入" border="surround"
  164. v-model="form.payAmount">
  165. <template slot="suffix">元</template>
  166. </u--input>
  167. </u-cell>
  168. </u-cell-group>
  169. <produceList ref="produceListRef" :pricingWay="form.pricingWay" :contractId="form.contractId"
  170. :columns="columns"></produceList>
  171. </view>
  172. <u-toast ref="uToast"></u-toast>
  173. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" :localdata="listData" valueKey="id"
  174. textKey="name" childrenKey="children" />
  175. </view>
  176. </template>
  177. <script>
  178. import {
  179. getByCode
  180. } from '@/api/pda/common.js'
  181. import {
  182. getcontactlink,
  183. } from '@/api/saleManage/contact/index.js'
  184. import {
  185. getContract,
  186. saveSaleorder,
  187. getSaleOrderDetail,
  188. } from '@/api/saleManage/saleorder'
  189. import {
  190. listOrganizations,
  191. } from '@/api/myTicket/index.js'
  192. import {
  193. enterprisePage,
  194. } from '@/api/mainData/index.js'
  195. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  196. import produceList from '../components/produceList.vue'
  197. export default {
  198. components: {
  199. produceList,
  200. baTreePicker
  201. },
  202. data() {
  203. return {
  204. list: ['订单信息', '基本信息', '产品清单'],
  205. current: 0,
  206. listData: [],
  207. userList: [],
  208. form: {
  209. id: '',
  210. contractId: '',
  211. orderFiles: [],
  212. contractName: '',
  213. salesDeptName: '',
  214. pricingWay: 1,
  215. payAmount: '',
  216. generatePurchase: 0,
  217. generateProduce: 0,
  218. generateProject: 0,
  219. projectName: '',
  220. projectId: '',
  221. receiveAddress: '',
  222. remark: '',
  223. saleType: '',
  224. saleTypeName: '',
  225. totalAmount: '',
  226. settlementMode: '4',
  227. settlementModeName: '分期付款',
  228. partaUnifiedSocialCreditCode: '',
  229. partbUnifiedSocialCreditCode: '',
  230. partaAddress: '',
  231. partaEmail: '',
  232. partaFax: '',
  233. partaId: '',
  234. partaLinkId: '',
  235. partaLinkName: '',
  236. partaName: '',
  237. partaTel: '',
  238. partbAddress: '',
  239. partbEmail: '',
  240. partbFax: '',
  241. partbId: '',
  242. partbLinkId: '',
  243. partbLinkName: '',
  244. partbName: '',
  245. partbTel: '',
  246. needProduce: 1
  247. },
  248. order_type: [],
  249. settlement_mode: [],
  250. linkList: [],
  251. enterprisePage: [],
  252. columns: [
  253. [{
  254. label: '产品名称:',
  255. prop: 'productName',
  256. type: 'title',
  257. className: 'perce100',
  258. }],
  259. [{
  260. label: '编码:',
  261. prop: 'productCode'
  262. }, {
  263. label: '牌号:',
  264. prop: 'productBrand'
  265. }],
  266. [{
  267. label: '规格:',
  268. prop: 'specification'
  269. }, {
  270. label: '型号:',
  271. prop: 'modelType'
  272. }],
  273. [{
  274. label: '数量:',
  275. prop: 'totalCount',
  276. slot: 'totalCount',
  277. }, {
  278. label: '计量单位:',
  279. prop: 'measuringUnit',
  280. }],
  281. [{
  282. label: '单价:',
  283. prop: 'singlePrice',
  284. slot: 'singlePrice',
  285. }, {
  286. label: '折让单价:',
  287. formatter: (item) => {
  288. return (item.discountSinglePrice ?
  289. Number(item.discountSinglePrice).toFixed(2) :
  290. '') + '元';
  291. }
  292. }],
  293. [{
  294. label: '合计:',
  295. prop: 'totalPrice',
  296. formatter: (item) => {
  297. return (item.totalPrice || '') + '元';
  298. }
  299. }, {
  300. label: '折让合计:',
  301. formatter: (item) => {
  302. return (item.discountTotalPrice ?
  303. Number(item.discountTotalPrice).toFixed(2) :
  304. '') + '元';
  305. }
  306. }],
  307. [{
  308. label: '客户代号:',
  309. prop: 'customerMark',
  310. slot: 'customerMark',
  311. }],
  312. [{
  313. label: '单重:',
  314. prop: 'singleWeight',
  315. slot: 'singleWeight',
  316. }, {
  317. label: '总重:',
  318. prop: 'totalWeight',
  319. }],
  320. [{
  321. label: '客户期望交期:',
  322. prop: 'customerExpectDeliveryDeadline',
  323. slot: 'customerExpectDeliveryDeadline',
  324. className: 'perce100',
  325. }],
  326. [{
  327. label: '质保期:',
  328. prop: 'guaranteePeriod',
  329. slot: 'guaranteePeriod',
  330. }, {
  331. label: '单位:',
  332. prop: 'guaranteePeriodUnitCode',
  333. slot: 'guaranteePeriodUnitCode',
  334. }],
  335. [{
  336. label: '操作:',
  337. prop: 'action',
  338. type: 'action',
  339. className: 'perce100',
  340. }],
  341. ],
  342. projectData: {}
  343. }
  344. },
  345. created() {
  346. this.getByCode()
  347. this.getDept()
  348. //选择合同回调
  349. uni.$off('setContractList')
  350. uni.$on('setContractList', async (data) => {
  351. if (data && data.length > 0) {
  352. this.form = Object.assign({}, this.form, {
  353. contractId: data[0].id,
  354. contractName: data[0].contractName
  355. });
  356. this.getContract(data[0].id);
  357. }
  358. })
  359. //选择客户回调
  360. uni.$off('setSelectList')
  361. uni.$on('setSelectList', async (data) => {
  362. if (data && data.length > 0) {
  363. this.changeParent(data[0])
  364. }
  365. })
  366. //总金额回显
  367. uni.$off('allsum')
  368. uni.$on('allsum', (allsum) => {
  369. this.form.totalAmount = allsum
  370. this.form.payAmount = allsum
  371. })
  372. //选择用户
  373. uni.$off('setUserInfo')
  374. uni.$on('setUserInfo', (data) => {
  375. if (data && data.length > 0) {
  376. this.$set(this.form, 'partbLinkId', data[0].id);
  377. this.$set(this.form, 'partbLinkName', data[0].name);
  378. this.$set(this.form, 'partbTel', data[0].phone);
  379. this.$set(this.form, 'partbEmail', data[0].email);
  380. }
  381. })
  382. //选择项目
  383. uni.$off('setProject')
  384. uni.$on('setProject', async (data) => {
  385. if (data && data.length > 0) {
  386. this.projectData = data[0];
  387. this.form = Object.assign({}, this.form, {
  388. projectName: this.projectData.name,
  389. projectId: this.projectData.id
  390. });
  391. if (this.projectData.contractId) {
  392. this.form = Object.assign({}, this.form, {
  393. contractId: this.projectData.contractId,
  394. contractName: this.projectData.contractName
  395. });
  396. this.getContract(this.projectData.contractId);
  397. } else if (this.projectData.contactId) {
  398. const data = await contactDetail(this.projectData.contactId);
  399. if (data.base?.id) {
  400. this.changeParent(data.base);
  401. }
  402. }
  403. }
  404. })
  405. },
  406. onLoad(data) {
  407. if (data && data.id) {
  408. this.getSaleOrderDetail(data.id)
  409. }
  410. this.enterprisePageFn(data.id)
  411. },
  412. onUnload() {
  413. uni.$off('setContractList')
  414. uni.$off('setSelectList')
  415. uni.$off('allsum')
  416. uni.$off('setUserInfo')
  417. uni.$off('setProject')
  418. },
  419. methods: {
  420. getDept() {
  421. listOrganizations(1).then(data => {
  422. this.listData = data
  423. })
  424. },
  425. //获取订单详情
  426. async getSaleOrderDetail(id) {
  427. const data = await getSaleOrderDetail(id);
  428. if (data) {
  429. this.$nextTick(() => {
  430. this.form = data;
  431. this.$refs.produceListRef.init(data.productList)
  432. this.getLinkInfo(data.partaId);
  433. });
  434. }
  435. },
  436. getByCode() {
  437. const codeS = ['order_type', 'settlement_mode']
  438. codeS.forEach(async (code) => {
  439. const codeValue = await getByCode(code);
  440. this[code] = codeValue.map(item => {
  441. const key = Object.keys(item)[0]
  442. return {
  443. value: key,
  444. text: item[key]
  445. }
  446. })
  447. })
  448. },
  449. enterprisePageFn(id) {
  450. enterprisePage({
  451. pageNum: 1,
  452. size: 100
  453. }).then((res) => {
  454. this.enterprisePage = res.list;
  455. if (!id) {
  456. this.form.partbName = this.enterprisePage[0].name;
  457. this.form.partbUnifiedSocialCreditCode =
  458. this.enterprisePage[0].unifiedSocialCreditCode;
  459. this.form.partbFax = this.enterprisePage[0].fax;
  460. this.form.partbAddress = this.enterprisePage[0].address;
  461. }
  462. });
  463. },
  464. discountInput() {
  465. this.$refs.produceListRef.discountInputByOrder(this.form.payAmount)
  466. },
  467. settlementModeChange(e) {
  468. this.form.settlementModeName = e.detail.value[0].text;
  469. },
  470. //选择部门
  471. salesDeptShow() {
  472. this.$refs.treePicker._show()
  473. },
  474. //部门回调
  475. confirm(data, name) {
  476. this.form.salesDeptName = name || ''
  477. this.form.salesDeptId = data[0] || ''
  478. },
  479. //选择客户
  480. selectContactShow() {
  481. if (this.form.contractId) {
  482. this.$refs.uToast.show({
  483. type: "error",
  484. message: "选择了合同不能更改客户",
  485. })
  486. return
  487. }
  488. uni.navigateTo({
  489. url: '/pages/saleManage/components/selectContact?isAll=' + 2
  490. })
  491. },
  492. //选择客户回调
  493. async changeParent(obj) {
  494. this.form = Object.assign({}, this.form, {
  495. partaId: obj.id,
  496. partaName: obj.name,
  497. partaAddress: obj.addressName + obj.address,
  498. partaLinkId: '',
  499. partaLinkName: '',
  500. partaEmail: '',
  501. partaTel: '',
  502. customerMark: obj.serialNo
  503. });
  504. await this.getLinkInfo(obj.id);
  505. this.$nextTick(() => {
  506. let firstLink =
  507. this.linkList.find((item) => item.ifChief == 1) || {};
  508. this.form = Object.assign({}, this.form, {
  509. partaLinkId: firstLink.id || this.linkList[0]?.id,
  510. partaLinkName: firstLink.linkName || this.linkList[0]?.linkName,
  511. partaTel: firstLink.mobilePhone || this.linkList[0]?.mobilePhone
  512. });
  513. this.setCustomerMark();
  514. });
  515. },
  516. setCustomerMark() {
  517. this.$refs.produceListRef.setCustomerMark(this.form.customerMark)
  518. },
  519. //选择用户
  520. selectUserShow() {
  521. uni.navigateTo({
  522. url: '/pages/saleManage/components/selectUser?isAll=' + 2
  523. })
  524. },
  525. //选择合同
  526. selectContractShow() {
  527. uni.navigateTo({
  528. url: '/pages/saleManage/components/selectContract?isAll=' + 2
  529. })
  530. },
  531. //选择合同
  532. selectProjectShow() {
  533. uni.navigateTo({
  534. url: '/pages/saleManage/components/selectProject?isAll=' + 2
  535. })
  536. },
  537. //选择合同获取合同的详情
  538. async getContract(id) {
  539. const data = await getContract(id);
  540. if (data) {
  541. this.$nextTick(() => {
  542. let {
  543. contractVO
  544. } = data;
  545. // this.form=contractVOform.receiveAddress
  546. let {
  547. partaAddress,
  548. partaEmail,
  549. partaFax,
  550. partaId,
  551. partaLinkId,
  552. partaLinkName,
  553. partaName,
  554. partaTel,
  555. partbAddress,
  556. partbEmail,
  557. partbFax,
  558. partbId,
  559. partbLinkId,
  560. partbLinkName,
  561. partbName,
  562. partbTel,
  563. totalPrice,
  564. discountTotalPrice,
  565. partaUnifiedSocialCreditCode,
  566. partbUnifiedSocialCreditCode,
  567. settlementMode,
  568. settlementModeName,
  569. pricingWay,
  570. contractNo,
  571. contractNumber
  572. } = contractVO;
  573. this.form = Object.assign({}, this.form, {
  574. partaAddress,
  575. partaEmail,
  576. partaFax,
  577. partaId,
  578. partaLinkId,
  579. partaLinkName,
  580. partaName,
  581. partaTel,
  582. partbAddress,
  583. partbEmail,
  584. partbFax,
  585. partbId,
  586. partbLinkId,
  587. partbLinkName,
  588. partbName,
  589. partbTel,
  590. pricingWay,
  591. totalPrice,
  592. discountTotalPrice,
  593. partaUnifiedSocialCreditCode,
  594. partbUnifiedSocialCreditCode,
  595. totalAmount: totalPrice,
  596. payAmount: discountTotalPrice || totalPrice,
  597. receiveAddress: partaAddress,
  598. settlementMode,
  599. settlementModeName,
  600. contractNo,
  601. contractNumber
  602. });
  603. this.getLinkInfo(partaId);
  604. this.$refs.produceListRef.init(data.productList)
  605. });
  606. }
  607. },
  608. //更新联系人数据
  609. async getLinkInfo(contactId) {
  610. const data = await getcontactlink({
  611. contactId
  612. });
  613. if (data && data?.length) {
  614. this.linkList = data;
  615. }
  616. },
  617. sourceCodeOnchange(e) {
  618. const value = e.detail.value
  619. this.form.sourceCode = value.map(item => item.value).toString()
  620. this.form.sourceName = value.map(item => item.text).toString()
  621. },
  622. linkChange(e) {
  623. const value = e.detail.value
  624. if (value.length > 0) {
  625. const data = this.linkList.find(item => item.id == value[0].value)
  626. this.form = Object.assign({}, this.form, {
  627. partaEmail: data?.email,
  628. partaLinkName: data?.linkName || '',
  629. partaTel: data?.mobilePhone || data?.phone || '',
  630. partaLinkId: data?.id
  631. });
  632. }
  633. },
  634. radioChange(e) {
  635. this.form.pricingWay = e.detail.value
  636. this.$nextTick(() => {
  637. this.$refs.produceListRef.getTotalPrice()
  638. })
  639. },
  640. sectionChange(index) {
  641. this.current = index;
  642. },
  643. async save() {
  644. try {
  645. if (!this.form.settlementMode) {
  646. this.$refs.uToast.show({
  647. type: "error",
  648. message: "请选择结算方式",
  649. })
  650. return
  651. }
  652. if (!this.form.saleType) {
  653. this.$refs.uToast.show({
  654. type: "error",
  655. message: "请选择销售类型",
  656. })
  657. return
  658. }
  659. if (!this.form.partaName) {
  660. this.$refs.uToast.show({
  661. type: "error",
  662. message: "请选择客户",
  663. })
  664. return
  665. }
  666. if (!this.form.partaLinkName) {
  667. this.$refs.uToast.show({
  668. type: "error",
  669. message: "请选择客户联系人",
  670. })
  671. return
  672. }
  673. if (!this.form.partaTel) {
  674. this.$refs.uToast.show({
  675. type: "error",
  676. message: "请输入客户联系电话",
  677. })
  678. return
  679. }
  680. if (!this.form.partbName) {
  681. this.$refs.uToast.show({
  682. type: "error",
  683. message: "请输入售出方名称",
  684. })
  685. return
  686. }
  687. if (!this.form.partbLinkName) {
  688. this.$refs.uToast.show({
  689. type: "error",
  690. message: "请输入售出方联系人",
  691. })
  692. return
  693. }
  694. if (!this.form.partbTel) {
  695. this.$refs.uToast.show({
  696. type: "error",
  697. message: "请输入售出方联系电话",
  698. })
  699. return
  700. }
  701. if (this.$refs.produceListRef.getValue().length == 0) {
  702. this.$refs.uToast.show({
  703. type: "error",
  704. message: "产品清单不能为空",
  705. })
  706. return;
  707. }
  708. uni.showLoading({
  709. title: '加载中'
  710. })
  711. const saleTypeName = this.order_type.find(item => item.value == this.form.saleType)?.text
  712. const data = Object.assign({}, this.form, {
  713. productList: this.$refs.produceListRef.getValue(),
  714. saleTypeName
  715. })
  716. saveSaleorder(data)
  717. .then((id) => {
  718. uni.hideLoading()
  719. this.back()
  720. })
  721. .catch((e) => {
  722. uni.hideLoading()
  723. });
  724. } catch (error) {
  725. uni.hideLoading()
  726. console.log(error, 'error')
  727. }
  728. },
  729. }
  730. }
  731. </script>
  732. <style lang="scss" scoped>
  733. /deep/.u-cell__body__content {
  734. flex: none;
  735. margin-right: 16rpx;
  736. }
  737. .mainBox {
  738. padding-bottom: 84rpx;
  739. }
  740. .required-mark {
  741. color: #FF3333;
  742. margin-right: 4rpx;
  743. }
  744. .footerButton {
  745. width: 100%;
  746. height: 84rpx;
  747. display: flex;
  748. position: fixed;
  749. bottom: 0;
  750. z-index: 10;
  751. background-color: #fff;
  752. /deep/.u-button {
  753. height: 100%;
  754. }
  755. >view {
  756. flex: 1;
  757. }
  758. }
  759. /deep/.u-subsection__item__text {
  760. font-size: 28rpx !important;
  761. }
  762. </style>