create.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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="productLineVal" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showLine = true">
  38. <view class="form-label flex_l">
  39. <view class="label-tag"></view>
  40. 产品线
  41. </view>
  42. <u-input
  43. :readonly="true"
  44. placeholder="请选择产品线"
  45. v-model="addForm.productLineVal"
  46. border="none"
  47. suffixIcon="arrow-down"
  48. suffixIconStyle="color:#CDCDCD"
  49. clearable
  50. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  51. </u-form-item>
  52. <u-form-item prop="nboName" borderBottom customStyle="padding:40rpx 0 30rpx">
  53. <view class="form-label flex_l">
  54. <view class="label-tag"></view>
  55. 项目名称
  56. </view>
  57. <u-input
  58. placeholder="输入项目名称"
  59. v-model="addForm.nboName"
  60. border="none"
  61. suffixIconStyle="color:#CDCDCD"
  62. clearable
  63. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  64. </u-form-item>
  65. <u-form-item
  66. prop="nboSourceVal"
  67. borderBottom
  68. customStyle="padding:40rpx 0 30rpx"
  69. @click="showNboSource = true">
  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.nboSourceVal"
  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 prop="contactName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="openContactUser()">
  85. <view class="form-label flex_l">
  86. <view class="label-tag"></view>
  87. 主要联系人
  88. </view>
  89. <u-input
  90. :readonly="true"
  91. placeholder="请选择主要联系人"
  92. v-model="addForm.contactName"
  93. border="none"
  94. suffixIcon="arrow-down"
  95. suffixIconStyle="color:#CDCDCD"
  96. clearable
  97. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  98. </u-form-item>
  99. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx">
  100. <view class="form-label flex_l">职位</view>
  101. <u-input
  102. placeholder="请输入职位"
  103. v-model="addForm.contactPostion"
  104. border="none"
  105. suffixIconStyle="color:#CDCDCD"
  106. clearable
  107. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  108. </u-form-item>
  109. <u-form-item borderBottom customStyle="padding:40rpx 0 30rpx">
  110. <view class="form-label flex_l">联系电话</view>
  111. <u-input
  112. placeholder="请输入联系电话"
  113. v-model="addForm.contactTelephone"
  114. border="none"
  115. suffixIconStyle="color:#CDCDCD"
  116. clearable
  117. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  118. </u-form-item>
  119. <!-- <u-form-item prop="saleName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="$refs.user.open()">
  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.saleName"
  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 prop="salesVal" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showModel = true">
  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.salesVal"
  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
  150. borderBottom
  151. customStyle="padding:40rpx 0 30rpx"
  152. @click="$refs.dealer.open()"
  153. v-if="addForm.salesModel > 10">
  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.distributorName"
  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. this.addForm.nboName = user.name + this.addForm.productLineVal
  576. }
  577. },
  578. // 经销商
  579. closeDealer(dealer) {
  580. if (dealer) {
  581. this.addForm.distributorId = dealer.id
  582. this.addForm.distributorName = dealer.name
  583. }
  584. },
  585. // 关闭选择客户联系人
  586. closeContact(user) {
  587. if (user) {
  588. this.addForm.contactId = user.id
  589. this.addForm.contactName = user.label
  590. this.addForm.contactPostion = user.postion
  591. this.addForm.contactTelephone = user.telephone
  592. }
  593. },
  594. // 关闭选择销售
  595. closeUser(user) {
  596. if (user) {
  597. this.addForm.saleId = user.id
  598. this.addForm.saleName = user.label
  599. }
  600. },
  601. // 全部用户
  602. closeAllUser(user) {
  603. if (user) {
  604. this.addForm.followUserId = user.id
  605. this.addForm.followUserName = user.label
  606. }
  607. },
  608. closeProduct(product) {
  609. this.productList = [...product]
  610. },
  611. removeProductItem(idx) {
  612. this.productList.splice(idx, 1)
  613. },
  614. // 选择来源
  615. pickSource(e) {
  616. this.addForm.nboSource = e.value[0].key
  617. this.addForm.nboSourceVal = e.value[0].value
  618. this.showNboSource = false
  619. },
  620. // 选择产品线
  621. pickLine(e) {
  622. this.addForm.productLine = e.value[0].key
  623. this.addForm.productLineVal = e.value[0].value
  624. this.addForm.nboName = this.addForm.custName + this.addForm.productLineVal
  625. this.showLine = false
  626. },
  627. // 选择销售类型
  628. pickModel(e) {
  629. this.addForm.salesModel = e.value[0].key
  630. this.addForm.salesVal = e.value[0].value
  631. if (e.value[0].key == '10') {
  632. this.distributorId = null
  633. this.distributorName = ''
  634. }
  635. this.showModel = false
  636. },
  637. // 是否大项目
  638. pickLarge(e) {
  639. this.addForm.isBig = e.value[0].key
  640. this.addForm.isBigVal = e.value[0].value
  641. this.showLarge = false
  642. },
  643. // 选择预计成交时间
  644. async pickEstTransDate(e) {
  645. this.showEstTransDate = false
  646. const timeFormat = uni.$u.timeFormat
  647. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  648. this.addForm.estTransTime = timeValue
  649. },
  650. // 计划采购时间
  651. async pickPlanDate(e) {
  652. this.showPlanDate = false
  653. const timeFormat = uni.$u.timeFormat
  654. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  655. this.addForm.planPurchaseTime = timeValue
  656. },
  657. // 跟进时间
  658. async pickFollowDate(e) {
  659. this.showFollowDate = false
  660. const timeFormat = uni.$u.timeFormat
  661. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd')
  662. this.addForm.followTime = timeValue
  663. },
  664. nextStep() {
  665. if (this.step == 1) {
  666. this.$refs.addForm
  667. .validate()
  668. .then(async () => {
  669. this.step++
  670. })
  671. .catch((err) => {
  672. this.$refs.uNotify.show({
  673. top: this.height + this.paddingTop + 10,
  674. type: 'warning',
  675. message: err[0].message,
  676. duration: 1000 * 3,
  677. })
  678. })
  679. } else if (this.step == 2) {
  680. if (this.productList.length == 0) {
  681. this.$refs.uNotify.show({
  682. top: this.height + this.paddingTop + 10,
  683. type: 'warning',
  684. message: '请选择产品',
  685. duration: 1000 * 3,
  686. })
  687. return
  688. }
  689. this.step++
  690. }
  691. },
  692. previousStep() {
  693. if (this.step > 1) {
  694. this.step--
  695. }
  696. },
  697. handleAdd() {
  698. if (!this.flag) return
  699. this.$refs.addForm
  700. .validate()
  701. .then(async () => {
  702. this.flag = false
  703. let params = this.addForm
  704. params.nboBudget = Number(params.nboBudget)
  705. params.saleName = this.nickName
  706. params.saleId = this.userId
  707. let products = this.productList.map((item) => ({
  708. ProdId: item.id,
  709. ProdName: item.prodName,
  710. ProdCode: item.prodCode,
  711. ProdClass: item.prodClass,
  712. ProdNum: Number(item.prodNum),
  713. ProdPrice: Number(item.guidPrice),
  714. }))
  715. params.products = products
  716. const [err, res] = await to(projectApi.create(params))
  717. this.flag = true
  718. if (err) return
  719. if (res && res.code == 200) {
  720. this.$refs.uToast.show({
  721. type: 'success',
  722. message: '创建成功',
  723. complete: () => {
  724. this.goBack()
  725. },
  726. })
  727. }
  728. })
  729. .catch((err) => {
  730. this.$refs.uNotify.show({
  731. top: this.height + this.paddingTop + 10,
  732. type: 'warning',
  733. message: err[0].message,
  734. duration: 1000 * 3,
  735. })
  736. })
  737. },
  738. goBack() {
  739. uni.navigateBack({
  740. //关闭当前页面,返回上一页面或多级页面。
  741. delta: 1,
  742. })
  743. },
  744. },
  745. }
  746. </script>
  747. <style>
  748. page {
  749. background: #f2f3f5;
  750. }
  751. </style>
  752. <style lang="scss" scoped>
  753. .home {
  754. padding-top: 188rpx;
  755. .nav {
  756. position: absolute;
  757. left: 0;
  758. top: 0;
  759. width: 100%;
  760. height: 284rpx;
  761. background: #3c9cff;
  762. .title {
  763. position: relative;
  764. text-align: center;
  765. font-size: 32rpx;
  766. font-weight: bold;
  767. color: #ffffff;
  768. .back {
  769. position: absolute;
  770. top: 0;
  771. bottom: 0;
  772. margin: auto;
  773. left: 70rpx;
  774. display: flex;
  775. }
  776. }
  777. }
  778. .main {
  779. position: absolute;
  780. width: 100%;
  781. height: calc(100vh - 188rpx);
  782. background: #ffffff;
  783. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  784. border-radius: 31rpx 31rpx 0 0;
  785. padding: 0 32rpx;
  786. overflow: auto;
  787. padding-bottom: 64rpx;
  788. .step-tit {
  789. text-align: center;
  790. line-height: 60rpx;
  791. font-size: 26rpx;
  792. color: #000;
  793. }
  794. .form-label {
  795. font-size: 32rpx;
  796. font-weight: bold;
  797. color: #323232;
  798. padding-bottom: 18rpx;
  799. .label-tag {
  800. width: 15rpx;
  801. height: 15rpx;
  802. background: #ff4d4f;
  803. border-radius: 50%;
  804. margin-right: 10rpx;
  805. }
  806. }
  807. .handle-btn {
  808. width: 234rpx;
  809. height: 92rpx;
  810. background: #3c9cff;
  811. border-radius: 31rpx;
  812. margin: 30rpx auto 0;
  813. font-size: 32rpx;
  814. color: #ffffff;
  815. text-align: center;
  816. line-height: 92rpx;
  817. }
  818. }
  819. .step1 {
  820. width: 100%;
  821. height: calc(100% - 124rpx);
  822. overflow: auto;
  823. }
  824. .step2 {
  825. width: 100%;
  826. height: calc(100% - 124rpx);
  827. .product-wrap {
  828. width: 100%;
  829. margin-top: 30rpx;
  830. height: calc(100% - 150rpx);
  831. overflow: auto;
  832. padding: 0 10rpx;
  833. .product-item {
  834. margin: 30rpx 0;
  835. padding: 20rpx;
  836. border-radius: 10px;
  837. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  838. .product-label {
  839. padding: 20rpx 0 20rpx 20rpx;
  840. }
  841. }
  842. }
  843. .margin20 {
  844. font-weight: bold;
  845. margin: 10px 20px;
  846. }
  847. .add-btn {
  848. color: #fff;
  849. width: 120rpx;
  850. height: 60rpx;
  851. padding: 0rpx 8rpx;
  852. font-size: 12rpx;
  853. background: #3c9cff;
  854. border-radius: 3px;
  855. text-align: center;
  856. line-height: 58rpx;
  857. font-size: 44rpx;
  858. }
  859. }
  860. }
  861. </style>