create.vue 31 KB

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