create.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-22 13:56:08
  6. * @Description: file content
  7. * @FilePath: \oms\pages\project\create.vue
  8. -->
  9. <template>
  10. <view class="home">
  11. <view class="nav">
  12. <view :style="{ paddingTop }">
  13. <view class="title" :style="[{ height }, { lineHeight: height }]">
  14. <view class="back" @click="goBack()">
  15. <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
  16. </view>
  17. <text>项目创建</text>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="main">
  22. <view class="step1" v-if="step == 1">
  23. <u-form :model="addForm" :rules="rules" ref="addForm" label-width="0">
  24. <u-form-item prop="custName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="$refs.cust.open()">
  25. <view class="form-label flex_l">
  26. <view class="label-tag"></view>
  27. 选择客户
  28. </view>
  29. <u-input
  30. v-model="addForm.custName"
  31. disabled
  32. disabledColor="#ffffff"
  33. placeholder="请选择关联客户"
  34. border="none"></u-input>
  35. <u-icon slot="right" name="arrow-right"></u-icon>
  36. </u-form-item>
  37. <u-form-item prop="nboName" borderBottom customStyle="padding:40rpx 0 30rpx">
  38. <view class="form-label flex_l">
  39. <view class="label-tag"></view>
  40. 项目名称
  41. </view>
  42. <u-input
  43. placeholder="输入项目名称"
  44. v-model="addForm.nboName"
  45. border="none"
  46. suffixIconStyle="color:#CDCDCD"
  47. clearable
  48. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  49. </u-form-item>
  50. <u-form-item
  51. prop="nboSourceVal"
  52. borderBottom
  53. customStyle="padding:40rpx 0 30rpx"
  54. @click="showNboSource = true">
  55. <view class="form-label flex_l">
  56. <view class="label-tag"></view>
  57. 项目来源
  58. </view>
  59. <u-input
  60. :readonly="true"
  61. placeholder="请选择项目来源"
  62. v-model="addForm.nboSourceVal"
  63. border="none"
  64. suffixIcon="arrow-down"
  65. suffixIconStyle="color:#CDCDCD"
  66. clearable
  67. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  68. </u-form-item>
  69. <u-form-item prop="contactName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="openContactUser()">
  70. <view class="form-label flex_l">
  71. <view class="label-tag"></view>
  72. 主要联系人
  73. </view>
  74. <u-input
  75. :readonly="true"
  76. placeholder="请选择主要联系人"
  77. v-model="addForm.contactName"
  78. border="none"
  79. suffixIcon="arrow-down"
  80. suffixIconStyle="color:#CDCDCD"
  81. clearable
  82. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  83. </u-form-item>
  84. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx">
  85. <view class="form-label flex_l">职位</view>
  86. <u-input
  87. placeholder="请输入职位"
  88. v-model="addForm.contactPostion"
  89. border="none"
  90. suffixIconStyle="color:#CDCDCD"
  91. clearable
  92. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  93. </u-form-item>
  94. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx">
  95. <view class="form-label flex_l">联系电话</view>
  96. <u-input
  97. placeholder="请输入联系电话"
  98. v-model="addForm.contactTelephone"
  99. border="none"
  100. suffixIconStyle="color:#CDCDCD"
  101. clearable
  102. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  103. </u-form-item>
  104. <!-- <u-form-item prop="saleName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="$refs.user.open()">
  105. <view class="form-label flex_l">
  106. <view class="label-tag"></view>
  107. 销售工程师
  108. </view>
  109. <u-input
  110. :readonly="true"
  111. placeholder="请选择销售工程师"
  112. v-model="addForm.saleName"
  113. border="none"
  114. suffixIcon="arrow-down"
  115. suffixIconStyle="color:#CDCDCD"
  116. clearable
  117. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  118. </u-form-item> -->
  119. <u-form-item prop="salesVal" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showModel = true">
  120. <view class="form-label flex_l">
  121. <view class="label-tag"></view>
  122. 销售模式
  123. </view>
  124. <u-input
  125. :readonly="true"
  126. placeholder="请选择销售模式"
  127. v-model="addForm.salesVal"
  128. border="none"
  129. suffixIcon="arrow-down"
  130. suffixIconStyle="color:#CDCDCD"
  131. clearable
  132. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  133. </u-form-item>
  134. <u-form-item
  135. borderBottom
  136. customStyle="padding:40rpx 0 30rpx"
  137. @click="$refs.dealer.open()"
  138. v-if="addForm.salesModel != '10'">
  139. <view class="form-label flex_l">
  140. <view class="label-tag"></view>
  141. 经销商/代理商
  142. </view>
  143. <u-input
  144. :readonly="true"
  145. placeholder="请选择经销商/代理商"
  146. v-model="addForm.distributorName"
  147. border="none"
  148. suffixIcon="arrow-down"
  149. suffixIconStyle="color:#CDCDCD"
  150. clearable
  151. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  152. </u-form-item>
  153. <u-form-item prop="productLineVal" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showLine = true">
  154. <view class="form-label flex_l">
  155. <view class="label-tag"></view>
  156. 产品线
  157. </view>
  158. <u-input
  159. :readonly="true"
  160. placeholder="请选择产品线"
  161. v-model="addForm.productLineVal"
  162. border="none"
  163. suffixIcon="arrow-down"
  164. suffixIconStyle="color:#CDCDCD"
  165. clearable
  166. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  167. </u-form-item>
  168. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showSource = true">
  169. <view class="form-label flex_l">项目预算</view>
  170. <u-input
  171. type="number"
  172. placeholder="输入项目预算"
  173. v-model="addForm.nboBudget"
  174. border="none"
  175. suffixIconStyle="color:#CDCDCD"
  176. clearable
  177. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  178. </u-form-item>
  179. <u-form-item prop="isBigVal" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showLarge = true">
  180. <view class="form-label flex_l">
  181. <view class="label-tag"></view>
  182. 是否大项目
  183. </view>
  184. <u-input
  185. :readonly="true"
  186. placeholder="请选择是否大项目"
  187. v-model="addForm.isBigVal"
  188. border="none"
  189. suffixIcon="arrow-down"
  190. suffixIconStyle="color:#CDCDCD"
  191. clearable
  192. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  193. </u-form-item>
  194. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showEstTransDate = true">
  195. <view class="form-label flex_l">预计成交时间</view>
  196. <u-input
  197. :readonly="true"
  198. placeholder="请选择预计成交时间"
  199. v-model="addForm.estTransTime"
  200. border="none"
  201. suffixIcon="arrow-down"
  202. suffixIconStyle="color:#CDCDCD"
  203. clearable
  204. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  205. </u-form-item>
  206. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showPlanDate = true">
  207. <view class="form-label flex_l">计划采购时间</view>
  208. <u-input
  209. :readonly="true"
  210. placeholder="请选择计划采购时间"
  211. v-model="addForm.planPurchaseTime"
  212. border="none"
  213. suffixIcon="arrow-down"
  214. suffixIconStyle="color:#CDCDCD"
  215. clearable
  216. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  217. </u-form-item>
  218. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showDate = true">
  219. <view class="form-label flex_l">风险情况</view>
  220. <u-input
  221. placeholder="输入风险情况"
  222. v-model="addForm.riskProfile"
  223. border="none"
  224. suffixIconStyle="color:#CDCDCD"
  225. clearable
  226. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  227. </u-form-item>
  228. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showDate = true">
  229. <view class="form-label flex_l">困难点</view>
  230. <u-input
  231. placeholder="输入困难点"
  232. v-model="addForm.difficulty"
  233. border="none"
  234. suffixIconStyle="color:#CDCDCD"
  235. clearable
  236. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  237. </u-form-item>
  238. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showDate = true">
  239. <view class="form-label flex_l">竞争公司</view>
  240. <u-input
  241. placeholder="输入竞争公司"
  242. v-model="addForm.competitor"
  243. border="none"
  244. suffixIconStyle="color:#CDCDCD"
  245. clearable
  246. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  247. </u-form-item>
  248. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx" @click="showDate = true">
  249. <view class="form-label flex_l">介入情况</view>
  250. <u-input
  251. placeholder="输入介入情况"
  252. v-model="addForm.intervention"
  253. border="none"
  254. suffixIconStyle="color:#CDCDCD"
  255. clearable
  256. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  257. </u-form-item>
  258. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx">
  259. <view class="form-label flex_l">
  260. <view class="label-tag"></view>
  261. 备注
  262. </view>
  263. <u-input
  264. placeholder="输入备注"
  265. v-model="addForm.remark"
  266. border="none"
  267. clearable
  268. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  269. </u-form-item>
  270. </u-form>
  271. </view>
  272. <view class="step2" v-else-if="step == 2">
  273. <view class="step-tit">添加产品</view>
  274. <view class="add-btn" @click="$refs.product.open()">+</view>
  275. <view class="product-wrap">
  276. <view class="product-item" v-for="(v, i) in productList" :key="v.id">
  277. <view class="product-label flex_l">
  278. 产品编码:
  279. <view class="product-val">{{ v.prodCode }}</view>
  280. </view>
  281. <view class="product-label flex_l">
  282. 产品名称:
  283. <view class="product-val">{{ v.prodName }}</view>
  284. </view>
  285. <view class="product-label flex_l">
  286. 产品类别:
  287. <view class="product-val">{{ v.prodClass }}</view>
  288. </view>
  289. <view class="product-label flex_l">
  290. 产品单价:
  291. <view class="product-val">
  292. <u-input v-model="productList[i].guidPrice" clearable></u-input>
  293. </view>
  294. </view>
  295. <view class="product-label flex_l">
  296. 产品数量:
  297. <view class="product-val">
  298. <u-input v-model="productList[i].prodNum" clearable></u-input>
  299. </view>
  300. </view>
  301. </view>
  302. </view>
  303. </view>
  304. <!-- <view class="step3" v-else-if="step == 3">
  305. <u-form :model="addForm" :rules="rules" ref="addForm" label-width="0">
  306. <u-form-item
  307. prop="followTime"
  308. borderBottom
  309. customStyle="padding:40rpx 0 30rpx"
  310. @click="showFollowDate = true">
  311. <view class="form-label flex_l">
  312. <view class="label-tag"></view>
  313. 跟进时间
  314. </view>
  315. <u-input
  316. :readonly="true"
  317. placeholder="请选择跟进时间"
  318. v-model="addForm.followTime"
  319. border="none"
  320. suffixIcon="arrow-down"
  321. suffixIconStyle="color:#CDCDCD"
  322. clearable
  323. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  324. </u-form-item>
  325. <u-form-item
  326. prop="followUserName"
  327. borderBottom
  328. customStyle="padding:40rpx 0 30rpx"
  329. @click="$refs.allUser.open()">
  330. <view class="form-label flex_l">
  331. <view class="label-tag"></view>
  332. 负责人员
  333. </view>
  334. <u-input
  335. :readonly="true"
  336. placeholder="请选择负责人员"
  337. v-model="addForm.followUserName"
  338. border="none"
  339. suffixIcon="arrow-down"
  340. suffixIconStyle="color:#CDCDCD"
  341. clearable
  342. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  343. </u-form-item>
  344. <u-form-item prop="followContent" borderBottom customStyle="padding:40rpx 0 30rpx">
  345. <view class="form-label flex_l">
  346. <view class="label-tag"></view>
  347. 跟进内容
  348. </view>
  349. <u-input
  350. placeholder="请输入跟进内容"
  351. v-model="addForm.followContent"
  352. border="none"
  353. clearable
  354. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  355. </u-form-item>
  356. </u-form>
  357. </view> -->
  358. <view class="center">
  359. <view class="handle-btn" v-if="step > 1" @click="previousStep">上一步</view>
  360. <view class="handle-btn" v-if="step < 2" @click="nextStep">下一步</view>
  361. <view class="handle-btn" v-if="step == 2" @click="handleAdd">保存</view>
  362. </view>
  363. </view>
  364. <!-- 选择下次时间 -->
  365. <u-datetime-picker
  366. v-if="showEstTransDate"
  367. :show="showEstTransDate"
  368. mode="date"
  369. v-model="addForm.estTransTime"
  370. @cancel="showEstTransDate = false"
  371. @confirm="pickEstTransDate"></u-datetime-picker>
  372. <!-- 计划采购时间 -->
  373. <u-datetime-picker
  374. v-if="showPlanDate"
  375. :show="showPlanDate"
  376. mode="date"
  377. v-model="addForm.planPurchaseTime"
  378. @cancel="showPlanDate = false"
  379. @confirm="pickPlanDate"></u-datetime-picker>
  380. <!-- 跟进时间 -->
  381. <u-datetime-picker
  382. v-if="showFollowDate"
  383. :show="showFollowDate"
  384. mode="date"
  385. v-model="addForm.followTime"
  386. @cancel="showFollowDate = false"
  387. @confirm="pickFollowDate"></u-datetime-picker>
  388. <!-- 选择客户 -->
  389. <select-customer ref="cust" @close="closeCust()"></select-customer>
  390. <!-- 选择客户联系人 -->
  391. <customer-contact ref="contact" @close="closeContact()"></customer-contact>
  392. <!-- 选择销售 -->
  393. <select-user ref="user" :query-params="{ roles: ['Sales', 'SalesManager'] }" @close="closeUser()"></select-user>
  394. <!-- 选择经销商 -->
  395. <select-dealer ref="dealer" @close="closeDealer()"></select-dealer>
  396. <!-- 选择用户 -->
  397. <select-user ref="allUser" @close="closeAllUser()"></select-user>
  398. <!-- 选择产品 -->
  399. <select-product ref="product" @close="closeProduct()"></select-product>
  400. <!-- 项目来源 -->
  401. <u-picker
  402. :show="showNboSource"
  403. :columns="nboSourceColumns"
  404. keyName="value"
  405. @cancel="showNboSource = false"
  406. @confirm="pickSource"></u-picker>
  407. <!-- 产品线 -->
  408. <u-picker
  409. :show="showLine"
  410. :columns="productLineColumns"
  411. keyName="value"
  412. @cancel="showLine = false"
  413. @confirm="pickLine"></u-picker>
  414. <!-- 销售模式 -->
  415. <u-picker
  416. :show="showModel"
  417. :columns="salesModelColumns"
  418. keyName="value"
  419. @cancel="showModel = false"
  420. @confirm="pickModel"></u-picker>
  421. <!-- 大项目 -->
  422. <u-picker
  423. :show="showLarge"
  424. :columns="yesOrNoColumns"
  425. keyName="value"
  426. @cancel="showLarge = false"
  427. @confirm="pickLarge"></u-picker>
  428. <u-notify ref="uNotify"></u-notify>
  429. <u-toast ref="uToast"></u-toast>
  430. </view>
  431. </template>
  432. <script>
  433. import { mapGetters } from 'vuex'
  434. import projectApi from 'api/project'
  435. import customerApi from '../../api/customer'
  436. import to from 'await-to-js'
  437. import SelectCustomer from 'components/SelectCustomer'
  438. import CustomerContact from 'components/CustomerContact'
  439. import SelectUser from 'components/SelectUser'
  440. import SelectDealer from 'components/SelectDealer'
  441. import SelectProduct from 'components/SelectProduct'
  442. export default {
  443. name: 'omsIndex',
  444. components: { SelectCustomer, CustomerContact, SelectUser, SelectDealer, SelectProduct },
  445. data() {
  446. const validateDistributor = (rule, value, callback) => {
  447. if ('' === value && this.form.salesModel !== '10')
  448. callback(
  449. new Error(
  450. this.$refs.uNotify.show({
  451. top: this.height + this.paddingTop + 10,
  452. type: 'warning',
  453. message: '请选择经销商/代理商',
  454. duration: 1000 * 3,
  455. })
  456. )
  457. )
  458. else callback()
  459. }
  460. return {
  461. step: 1,
  462. height: '',
  463. paddingTop: '',
  464. showNboSource: false, //项目来源选择
  465. showModel: false, //销售模式选择
  466. showLine: false, //产品线选择
  467. showLarge: false, //是否是大项目选择
  468. nboSourceColumns: [], //项目来源
  469. salesModelColumns: [], //销售模式
  470. productLineColumns: [], //产品线
  471. yesOrNoColumns: [], //是否是大项目
  472. showEstTransDate: false, //选择预计成交时间
  473. showPlanDate: false, //计划采购时间
  474. showFollowDate: false, //计划采购时间
  475. addForm: {
  476. nboName: '', //项目名称
  477. custId: '', //关联客户id
  478. custName: '', //关联客户
  479. nboSource: '', //项目来源
  480. nboSourceVal: '', //项目来源文字
  481. contactId: '', //联系人id
  482. contactName: '', //联系人姓名
  483. contactPostion: '', //联系人职位
  484. contactTelephone: '', //联系人电话
  485. saleName: '', //销售工程师
  486. saleId: '', //销售工程师id
  487. salesModel: '', //销售模式(10直销20经销30代理)
  488. salesVal: '', //销售模式文字
  489. distributorId: '', //经销商/代理商ID
  490. distributorName: '', //经销商/代理商名称
  491. productLine: '', //产品线来源
  492. productLineVal: '', //产品线文字
  493. nboBudget: '', //项目预算
  494. isBig: '', //是否是大项目
  495. isBigVal: '', //是否是大项目文字
  496. estTransTime: this.parseTime(new Date(), '{y}-{m}-{d}'), //预计成交时间
  497. planPurchaseTime: this.parseTime(new Date(), '{y}-{m}-{d}'), //计划采购时间
  498. riskProfile: '', //风险情况
  499. difficulty: '', //困难点
  500. competitor: '', //竞争公司
  501. intervention: '', //介入情况
  502. remark: '', //备注
  503. // followTime: this.parseTime(new Date(), '{y}-{m}-{d}'), //跟进时间
  504. // followUserId: '', //跟进用户id
  505. // followUserName: '', //跟进用户id
  506. // followContent: '', //跟进内容
  507. },
  508. rules: {
  509. nboName: [{ required: true, trigger: ['blur', 'change'], message: '请输入项目名称' }],
  510. custName: [{ required: true, trigger: ['blur', 'change'], message: '请选择关联客户' }],
  511. nboSourceVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择项目来源' }],
  512. contactName: [{ required: true, trigger: ['blur', 'change'], message: '请选择主要联系人' }],
  513. // saleName: [{ required: true, trigger: ['blur', 'change'], message: '请选择销售工程师' }],
  514. salesModelVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择销售模式' }],
  515. distributorName: [
  516. { validator: validateDistributor, trigger: ['blur', 'change'], message: '请选择经销商/代理商' },
  517. ],
  518. isBigVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择是否大项目' }],
  519. productLineVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择产品线' }],
  520. // 跟进
  521. // followTime: [{ required: true, trigger: ['blur', 'change'], message: '请输入跟进时间' }],
  522. // followContent: [{ required: true, trigger: ['blur', 'change'], message: '请输入跟进内容' }],
  523. },
  524. productList: [],
  525. }
  526. },
  527. computed: {
  528. ...mapGetters(['userId', 'username']),
  529. },
  530. onLoad(option) {
  531. this.addForm.custId = parseInt(option.id)
  532. },
  533. created() {
  534. const navData = uni.getMenuButtonBoundingClientRect()
  535. this.height = navData.height + 'px'
  536. this.paddingTop = navData.top + 'px'
  537. },
  538. onShow() {
  539. if (this.addForm.custId) {
  540. this.getCustomerDetail()
  541. }
  542. this.getOptions()
  543. },
  544. methods: {
  545. getOptions() {
  546. Promise.all([
  547. this.getDicts('proj_nbo_source'),
  548. this.getDicts('proj_sales_model'),
  549. this.getDicts('sys_product_line'),
  550. this.getDicts('sys_yes_no'),
  551. ]).then(([nboSource, salesModel, productLine, yesOrNo]) => {
  552. this.nboSourceColumns = [nboSource.data.values] || []
  553. this.salesModelColumns = [salesModel.data.values] || []
  554. this.productLineColumns = [productLine.data.values] || []
  555. this.yesOrNoColumns = [yesOrNo.data.values] || []
  556. })
  557. },
  558. async getCustomerDetail() {
  559. const [err, res] = await to(customerApi.getDetail({ ids: [this.addForm.custId] }))
  560. if (err) return
  561. if (res && res.code == 200) {
  562. this.addForm.custName = res.data.list[0].custName
  563. this.addForm.nboName = this.addForm.custName
  564. }
  565. },
  566. // 打开主要联系人
  567. openContactUser() {
  568. if (!this.addForm.custId) {
  569. this.$refs.uNotify.show({
  570. top: this.height + this.paddingTop + 10,
  571. type: 'warning',
  572. message: '请先选择客户',
  573. duration: 1000 * 3,
  574. })
  575. } else {
  576. this.$refs.contact.open(this.addForm.custId)
  577. }
  578. },
  579. // 关闭选择客户
  580. closeCust(user) {
  581. if (user) {
  582. this.addForm.custId = user.id
  583. this.addForm.custName = user.name
  584. }
  585. },
  586. // 经销商
  587. closeDealer(dealer) {
  588. if (dealer) {
  589. this.addForm.distributorId = dealer.id
  590. this.addForm.distributorName = dealer.name
  591. }
  592. },
  593. // 关闭选择客户联系人
  594. closeContact(user) {
  595. if (user) {
  596. this.addForm.contactId = user.id
  597. this.addForm.contactName = user.label
  598. this.addForm.contactPostion = user.postion
  599. this.addForm.contactTelephone = user.telephone
  600. }
  601. },
  602. // 关闭选择销售
  603. closeUser(user) {
  604. if (user) {
  605. this.addForm.saleId = user.id
  606. this.addForm.saleName = user.label
  607. }
  608. },
  609. // 全部用户
  610. closeAllUser(user) {
  611. if (user) {
  612. this.addForm.followUserId = user.id
  613. this.addForm.followUserName = user.label
  614. }
  615. },
  616. closeProduct(product) {
  617. let data = [...this.productList, ...product]
  618. this.productList = data
  619. },
  620. // 选择来源
  621. pickSource(e) {
  622. this.addForm.nboSource = e.value[0].key
  623. this.addForm.nboSourceVal = e.value[0].value
  624. this.showNboSource = false
  625. },
  626. // 选择产品线
  627. pickLine(e) {
  628. this.addForm.productLine = e.value[0].key
  629. this.addForm.productLineVal = e.value[0].value
  630. this.showLine = false
  631. },
  632. // 选择销售类型
  633. pickModel(e) {
  634. this.addForm.salesModel = e.value[0].key
  635. this.addForm.salesVal = e.value[0].value
  636. if (e.value[0].key == '10') {
  637. this.distributorId = ''
  638. this.distributorName = ''
  639. }
  640. this.showModel = false
  641. },
  642. // 是否大项目
  643. pickLarge(e) {
  644. this.addForm.isBig = e.value[0].key
  645. this.addForm.isBigVal = e.value[0].value
  646. this.showLarge = false
  647. },
  648. // 选择预计成交时间
  649. async pickEstTransDate(e) {
  650. this.showEstTransDate = false
  651. const timeFormat = uni.$u.timeFormat
  652. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  653. this.addForm.estTransTime = timeValue
  654. },
  655. // 计划采购时间
  656. async pickPlanDate(e) {
  657. this.showPlanDate = false
  658. const timeFormat = uni.$u.timeFormat
  659. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  660. this.addForm.planPurchaseTime = timeValue
  661. },
  662. // 跟进时间
  663. async pickFollowDate(e) {
  664. this.showFollowDate = false
  665. const timeFormat = uni.$u.timeFormat
  666. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  667. this.addForm.followTime = timeValue
  668. },
  669. nextStep() {
  670. if (this.step == 1) {
  671. this.$refs.addForm
  672. .validate()
  673. .then(async () => {
  674. this.step++
  675. })
  676. .catch((err) => {
  677. this.$refs.uNotify.show({
  678. top: this.height + this.paddingTop + 10,
  679. type: 'warning',
  680. message: err[0].message,
  681. duration: 1000 * 3,
  682. })
  683. })
  684. } else if (this.step == 2) {
  685. if (this.productList.length == 0) {
  686. this.$refs.uNotify.show({
  687. top: this.height + this.paddingTop + 10,
  688. type: 'warning',
  689. message: '请选择产品',
  690. duration: 1000 * 3,
  691. })
  692. return
  693. }
  694. this.step++
  695. }
  696. },
  697. previousStep() {
  698. if (this.step > 1) {
  699. this.step--
  700. }
  701. },
  702. handleAdd() {
  703. this.$refs.addForm
  704. .validate()
  705. .then(async () => {
  706. let params = this.addForm
  707. params.nboBudget = Number(params.nboBudget)
  708. params.saleName = this.username
  709. params.saleId = this.userId
  710. let products = this.productList.map((item) => ({
  711. ProdId: item.id,
  712. ProdName: item.prodName,
  713. ProdCode: item.prodCode,
  714. ProdClass: item.prodClass,
  715. ProdNum: Number(item.prodNum),
  716. ProdPrice: Number(item.guidPrice),
  717. }))
  718. params.products = products
  719. const [err, res] = await to(projectApi.create(params))
  720. if (err) return
  721. if (res && res.code == 200) {
  722. this.$refs.uToast.show({
  723. type: 'success',
  724. message: '创建成功',
  725. complete: () => {
  726. this.goBack()
  727. },
  728. })
  729. }
  730. })
  731. .catch((err) => {
  732. console.log(err)
  733. this.$refs.uNotify.show({
  734. top: this.height + this.paddingTop + 10,
  735. type: 'warning',
  736. message: err[0].message,
  737. duration: 1000 * 3,
  738. })
  739. })
  740. },
  741. goBack() {
  742. uni.navigateBack({
  743. //关闭当前页面,返回上一页面或多级页面。
  744. delta: 1,
  745. })
  746. },
  747. },
  748. }
  749. </script>
  750. <style>
  751. page {
  752. background: #f2f3f5;
  753. }
  754. </style>
  755. <style lang="scss" scoped>
  756. .home {
  757. padding-top: 188rpx;
  758. .nav {
  759. position: absolute;
  760. left: 0;
  761. top: 0;
  762. width: 100%;
  763. height: 284rpx;
  764. background: #3c9cff;
  765. .title {
  766. position: relative;
  767. text-align: center;
  768. font-size: 32rpx;
  769. font-weight: bold;
  770. color: #ffffff;
  771. .back {
  772. position: absolute;
  773. top: 0;
  774. bottom: 0;
  775. margin: auto;
  776. left: 70rpx;
  777. display: flex;
  778. }
  779. }
  780. }
  781. .main {
  782. position: absolute;
  783. width: 100%;
  784. height: calc(100vh - 188rpx);
  785. background: #ffffff;
  786. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  787. border-radius: 31rpx 31rpx 0 0;
  788. padding: 0 32rpx;
  789. overflow: auto;
  790. padding-bottom: 64rpx;
  791. .step-tit {
  792. text-align: center;
  793. line-height: 60rpx;
  794. font-size: 26rpx;
  795. color: #000;
  796. }
  797. .form-label {
  798. font-size: 32rpx;
  799. font-weight: bold;
  800. color: #323232;
  801. padding-bottom: 18rpx;
  802. .label-tag {
  803. width: 15rpx;
  804. height: 15rpx;
  805. background: #ff4d4f;
  806. border-radius: 50%;
  807. margin-right: 10rpx;
  808. }
  809. }
  810. .handle-btn {
  811. width: 234rpx;
  812. height: 92rpx;
  813. background: #3c9cff;
  814. border-radius: 31rpx;
  815. margin: 30rpx auto 0;
  816. font-size: 32rpx;
  817. color: #ffffff;
  818. text-align: center;
  819. line-height: 92rpx;
  820. }
  821. }
  822. .step1 {
  823. width: 100%;
  824. height: calc(100% - 124rpx);
  825. overflow: auto;
  826. }
  827. .step2 {
  828. width: 100%;
  829. height: calc(100% - 124rpx);
  830. .product-wrap {
  831. width: 100%;
  832. margin-top: 30rpx;
  833. height: calc(100% - 150rpx);
  834. overflow: auto;
  835. .product-item {
  836. margin: 30rpx 0;
  837. padding: 20rpx;
  838. border-radius: 10px;
  839. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  840. .product-label {
  841. padding: 20rpx 0 20rpx 20rpx;
  842. }
  843. }
  844. }
  845. .add-btn {
  846. color: #fff;
  847. width: 120rpx;
  848. height: 60rpx;
  849. padding: 0rpx 8rpx;
  850. font-size: 12rpx;
  851. background: #3c9cff;
  852. border-radius: 3px;
  853. text-align: center;
  854. line-height: 58rpx;
  855. font-size: 44rpx;
  856. }
  857. }
  858. }
  859. </style>