create.vue 30 KB

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