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-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" :class="!flag ? 'disabledBtn' : ''">保存</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. flag: true,
  454. step: 1,
  455. height: '',
  456. paddingTop: '',
  457. showNboSource: false, //项目来源选择
  458. showModel: false, //销售模式选择
  459. showLine: false, //产品线选择
  460. showLarge: false, //是否是大项目选择
  461. nboSourceColumns: [], //项目来源
  462. salesModelColumns: [], //销售模式
  463. productLineColumns: [], //产品线
  464. yesOrNoColumns: [], //是否是大项目
  465. showEstTransDate: false, //选择预计成交时间
  466. showPlanDate: false, //计划采购时间
  467. showFollowDate: false, //计划采购时间
  468. addForm: {
  469. nboName: '', //项目名称
  470. custId: '', //关联客户id
  471. custName: '', //关联客户
  472. nboSource: '', //项目来源
  473. nboSourceVal: '', //项目来源文字
  474. contactId: '', //联系人id
  475. contactName: '', //联系人姓名
  476. contactPostion: '', //联系人职位
  477. contactTelephone: '', //联系人电话
  478. saleName: '', //销售工程师
  479. saleId: '', //销售工程师id
  480. salesModel: '', //销售模式(10直销20经销30代理)
  481. salesVal: '', //销售模式文字
  482. distributorId: null, //经销商/代理商ID
  483. distributorName: '', //经销商/代理商名称
  484. productLine: '', //产品线来源
  485. productLineVal: '', //产品线文字
  486. nboBudget: '', //项目预算
  487. isBig: '', //是否是大项目
  488. isBigVal: '', //是否是大项目文字
  489. estTransTime: this.parseTime(new Date(), '{y}-{m}-{d}'), //预计成交时间
  490. planPurchaseTime: this.parseTime(new Date(), '{y}-{m}-{d}'), //计划采购时间
  491. riskProfile: '', //风险情况
  492. difficulty: '', //困难点
  493. competitor: '', //竞争公司
  494. intervention: '', //介入情况
  495. remark: '', //备注
  496. // followTime: this.parseTime(new Date(), '{y}-{m}-{d}'), //跟进时间
  497. // followUserId: '', //跟进用户id
  498. // followUserName: '', //跟进用户id
  499. // followContent: '', //跟进内容
  500. },
  501. rules: {
  502. nboName: [{ required: true, trigger: ['blur', 'change'], message: '请输入项目名称' }],
  503. custName: [{ required: true, trigger: ['blur', 'change'], message: '请选择关联客户' }],
  504. nboSourceVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择项目来源' }],
  505. contactName: [{ required: true, trigger: ['blur', 'change'], message: '请选择主要联系人' }],
  506. // saleName: [{ required: true, trigger: ['blur', 'change'], message: '请选择销售工程师' }],
  507. salesModelVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择销售模式' }],
  508. distributorName: [{ required: true, trigger: ['blur', 'change'], message: '请选择经销商/代理商' }],
  509. isBigVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择是否大项目' }],
  510. productLineVal: [{ required: true, trigger: ['blur', 'change'], message: '请选择产品线' }],
  511. // 跟进
  512. // followTime: [{ required: true, trigger: ['blur', 'change'], message: '请输入跟进时间' }],
  513. // followContent: [{ required: true, trigger: ['blur', 'change'], message: '请输入跟进内容' }],
  514. },
  515. productList: [],
  516. }
  517. },
  518. computed: {
  519. ...mapGetters(['userId', 'nickName']),
  520. },
  521. onLoad(option) {
  522. this.addForm.custId = parseInt(option.id)
  523. },
  524. created() {
  525. const navData = uni.getMenuButtonBoundingClientRect()
  526. this.height = navData.height + 'px'
  527. this.paddingTop = navData.top + 'px'
  528. },
  529. onShow() {
  530. if (this.addForm.custId) {
  531. this.getCustomerDetail()
  532. }
  533. this.getOptions()
  534. },
  535. methods: {
  536. getOptions() {
  537. Promise.all([
  538. this.getDicts('proj_nbo_source'),
  539. this.getDicts('proj_sales_model'),
  540. this.getDicts('sys_product_line'),
  541. this.getDicts('sys_yes_no'),
  542. ]).then(([nboSource, salesModel, productLine, yesOrNo]) => {
  543. this.nboSourceColumns = [nboSource.data.values] || []
  544. this.salesModelColumns = [salesModel.data.values] || []
  545. this.productLineColumns = [productLine.data.values] || []
  546. this.yesOrNoColumns = [yesOrNo.data.values] || []
  547. })
  548. },
  549. async getCustomerDetail() {
  550. const [err, res] = await to(customerApi.getDetail({ ids: [this.addForm.custId] }))
  551. if (err) return
  552. if (res && res.code == 200) {
  553. this.addForm.custName = res.data.list[0].custName
  554. this.addForm.nboName = this.addForm.custName
  555. }
  556. },
  557. // 打开主要联系人
  558. openContactUser() {
  559. if (!this.addForm.custId) {
  560. this.$refs.uNotify.show({
  561. top: this.height + this.paddingTop + 10,
  562. type: 'warning',
  563. message: '请先选择客户',
  564. duration: 1000 * 3,
  565. })
  566. } else {
  567. this.$refs.contact.open(this.addForm.custId)
  568. }
  569. },
  570. // 关闭选择客户
  571. closeCust(user) {
  572. if (user) {
  573. this.addForm.custId = user.id
  574. this.addForm.custName = user.name
  575. }
  576. },
  577. // 经销商
  578. closeDealer(dealer) {
  579. if (dealer) {
  580. this.addForm.distributorId = dealer.id
  581. this.addForm.distributorName = dealer.name
  582. }
  583. },
  584. // 关闭选择客户联系人
  585. closeContact(user) {
  586. if (user) {
  587. this.addForm.contactId = user.id
  588. this.addForm.contactName = user.label
  589. this.addForm.contactPostion = user.postion
  590. this.addForm.contactTelephone = user.telephone
  591. }
  592. },
  593. // 关闭选择销售
  594. closeUser(user) {
  595. if (user) {
  596. this.addForm.saleId = user.id
  597. this.addForm.saleName = user.label
  598. }
  599. },
  600. // 全部用户
  601. closeAllUser(user) {
  602. if (user) {
  603. this.addForm.followUserId = user.id
  604. this.addForm.followUserName = user.label
  605. }
  606. },
  607. closeProduct(product) {
  608. this.productList = [...product]
  609. },
  610. removeProductItem(idx) {
  611. this.productList.splice(idx, 1)
  612. },
  613. // 选择来源
  614. pickSource(e) {
  615. this.addForm.nboSource = e.value[0].key
  616. this.addForm.nboSourceVal = e.value[0].value
  617. this.showNboSource = false
  618. },
  619. // 选择产品线
  620. pickLine(e) {
  621. this.addForm.productLine = e.value[0].key
  622. this.addForm.productLineVal = e.value[0].value
  623. this.showLine = false
  624. },
  625. // 选择销售类型
  626. pickModel(e) {
  627. this.addForm.salesModel = e.value[0].key
  628. this.addForm.salesVal = e.value[0].value
  629. if (e.value[0].key == '10') {
  630. this.distributorId = null
  631. this.distributorName = ''
  632. }
  633. this.showModel = false
  634. },
  635. // 是否大项目
  636. pickLarge(e) {
  637. this.addForm.isBig = e.value[0].key
  638. this.addForm.isBigVal = e.value[0].value
  639. this.showLarge = false
  640. },
  641. // 选择预计成交时间
  642. async pickEstTransDate(e) {
  643. this.showEstTransDate = false
  644. const timeFormat = uni.$u.timeFormat
  645. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  646. this.addForm.estTransTime = timeValue
  647. },
  648. // 计划采购时间
  649. async pickPlanDate(e) {
  650. this.showPlanDate = false
  651. const timeFormat = uni.$u.timeFormat
  652. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  653. this.addForm.planPurchaseTime = timeValue
  654. },
  655. // 跟进时间
  656. async pickFollowDate(e) {
  657. this.showFollowDate = false
  658. const timeFormat = uni.$u.timeFormat
  659. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  660. this.addForm.followTime = timeValue
  661. },
  662. nextStep() {
  663. if (this.step == 1) {
  664. this.$refs.addForm
  665. .validate()
  666. .then(async () => {
  667. this.step++
  668. })
  669. .catch((err) => {
  670. this.$refs.uNotify.show({
  671. top: this.height + this.paddingTop + 10,
  672. type: 'warning',
  673. message: err[0].message,
  674. duration: 1000 * 3,
  675. })
  676. })
  677. } else if (this.step == 2) {
  678. if (this.productList.length == 0) {
  679. this.$refs.uNotify.show({
  680. top: this.height + this.paddingTop + 10,
  681. type: 'warning',
  682. message: '请选择产品',
  683. duration: 1000 * 3,
  684. })
  685. return
  686. }
  687. this.step++
  688. }
  689. },
  690. previousStep() {
  691. if (this.step > 1) {
  692. this.step--
  693. }
  694. },
  695. handleAdd() {
  696. if (!this.flag) return
  697. this.$refs.addForm
  698. .validate()
  699. .then(async () => {
  700. this.flag = false
  701. let params = this.addForm
  702. params.nboBudget = Number(params.nboBudget)
  703. params.saleName = this.nickName
  704. params.saleId = this.userId
  705. let products = this.productList.map((item) => ({
  706. ProdId: item.id,
  707. ProdName: item.prodName,
  708. ProdCode: item.prodCode,
  709. ProdClass: item.prodClass,
  710. ProdNum: Number(item.prodNum),
  711. ProdPrice: Number(item.guidPrice),
  712. }))
  713. params.products = products
  714. const [err, res] = await to(projectApi.create(params))
  715. this.flag = true
  716. if (err) return
  717. if (res && res.code == 200) {
  718. this.$refs.uToast.show({
  719. type: 'success',
  720. message: '创建成功',
  721. complete: () => {
  722. this.goBack()
  723. },
  724. })
  725. }
  726. })
  727. .catch((err) => {
  728. this.$refs.uNotify.show({
  729. top: this.height + this.paddingTop + 10,
  730. type: 'warning',
  731. message: err[0].message,
  732. duration: 1000 * 3,
  733. })
  734. })
  735. },
  736. goBack() {
  737. uni.navigateBack({
  738. //关闭当前页面,返回上一页面或多级页面。
  739. delta: 1,
  740. })
  741. },
  742. },
  743. }
  744. </script>
  745. <style>
  746. page {
  747. background: #f2f3f5;
  748. }
  749. </style>
  750. <style lang="scss" scoped>
  751. .home {
  752. padding-top: 188rpx;
  753. .nav {
  754. position: absolute;
  755. left: 0;
  756. top: 0;
  757. width: 100%;
  758. height: 284rpx;
  759. background: #3c9cff;
  760. .title {
  761. position: relative;
  762. text-align: center;
  763. font-size: 32rpx;
  764. font-weight: bold;
  765. color: #ffffff;
  766. .back {
  767. position: absolute;
  768. top: 0;
  769. bottom: 0;
  770. margin: auto;
  771. left: 70rpx;
  772. display: flex;
  773. }
  774. }
  775. }
  776. .main {
  777. position: absolute;
  778. width: 100%;
  779. height: calc(100vh - 188rpx);
  780. background: #ffffff;
  781. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  782. border-radius: 31rpx 31rpx 0 0;
  783. padding: 0 32rpx;
  784. overflow: auto;
  785. padding-bottom: 64rpx;
  786. .step-tit {
  787. text-align: center;
  788. line-height: 60rpx;
  789. font-size: 26rpx;
  790. color: #000;
  791. }
  792. .form-label {
  793. font-size: 32rpx;
  794. font-weight: bold;
  795. color: #323232;
  796. padding-bottom: 18rpx;
  797. .label-tag {
  798. width: 15rpx;
  799. height: 15rpx;
  800. background: #ff4d4f;
  801. border-radius: 50%;
  802. margin-right: 10rpx;
  803. }
  804. }
  805. .handle-btn {
  806. width: 234rpx;
  807. height: 92rpx;
  808. background: #3c9cff;
  809. border-radius: 31rpx;
  810. margin: 30rpx auto 0;
  811. font-size: 32rpx;
  812. color: #ffffff;
  813. text-align: center;
  814. line-height: 92rpx;
  815. }
  816. }
  817. .step1 {
  818. width: 100%;
  819. height: calc(100% - 124rpx);
  820. overflow: auto;
  821. }
  822. .step2 {
  823. width: 100%;
  824. height: calc(100% - 124rpx);
  825. .product-wrap {
  826. width: 100%;
  827. margin-top: 30rpx;
  828. height: calc(100% - 150rpx);
  829. overflow: auto;
  830. padding: 0 10rpx;
  831. .product-item {
  832. margin: 30rpx 0;
  833. padding: 20rpx;
  834. border-radius: 10px;
  835. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  836. .product-label {
  837. padding: 20rpx 0 20rpx 20rpx;
  838. }
  839. }
  840. }
  841. .margin20 {
  842. font-weight: bold;
  843. margin: 10px 20px;
  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>