add.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. :title="this.form.id?'修改商机':'新建商机'" @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
  7. <u-cell-group v-show='current==0'>
  8. <u-cell :title="'客户'" arrow-direction="down">
  9. <view slot="title" style="display: flex; align-items: center;">
  10. <text class="required-mark">*</text>
  11. 客户
  12. </view>
  13. <u--input slot="value" placeholder="请选择" border="surround" v-model="form.contactName"
  14. @click.native="selectContactShow"></u--input>
  15. </u-cell>
  16. <u-cell :title="'商机名称'" arrow-direction="down">
  17. <view slot="title" style="display: flex; align-items: center;">
  18. <text class="required-mark">*</text>
  19. 商机名称
  20. </view>
  21. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.name"></u--input>
  22. </u-cell>
  23. <u-cell title="负责人" arrow-direction="down">
  24. <u--input slot="value" :disabled="true" placeholder="请输入" border="surround"
  25. v-model="form.responsibleName"></u--input>
  26. </u-cell>
  27. <u-cell :title="'商机来源'" arrow-direction="down">
  28. <view slot="title" style="display: flex; align-items: center;">
  29. <text class="required-mark">*</text>
  30. 商机来源
  31. </view>
  32. <uni-data-picker v-model="form.sourceCode" slot="value" placeholder="请选择"
  33. :localdata="business_opport_code" @change="sourceCodeOnchange">
  34. </uni-data-picker>
  35. </u-cell>
  36. <u-cell title="赢单率" arrow-direction="down">
  37. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  38. <u--input style="flex:1" type="number" max="100" min="0" placeholder="请输入" border="surround"
  39. v-model="form.winRate">
  40. </u--input>
  41. %
  42. </view>
  43. </u-cell>
  44. <u-cell title="预算" arrow-direction="down">
  45. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  46. <u--input style="flex:1" type="number" placeholder="请输入" border="surround" v-model="form.budget">
  47. </u--input>
  48. 万元
  49. </view>
  50. </u-cell>
  51. <u-cell title="预计结单日期" arrow-direction="down">
  52. <uni-datetime-picker type="date" slot="value" v-model="form.expectedClosingDate">
  53. </uni-datetime-picker>
  54. </u-cell>
  55. <!-- <u-cell title="计价方式" arrow-direction="down">
  56. <radio-group @change="radioChange" v-model="form.pricingWay" slot="value">
  57. <radio value="1" :checked="form.pricingWay==1">按数量计价</radio>
  58. <radio value="2" :checked="form.pricingWay==2">按重量计价</radio>
  59. </radio-group>
  60. </u-cell> -->
  61. <u-cell title="备注" arrow-direction="down">
  62. <u--textarea slot="value" placeholder="请输入" border="surround" v-model="form.remark"></u--textarea>
  63. </u-cell>
  64. </u-cell-group>
  65. <view class="footerButton">
  66. <u-button type="default" text="返回" @click="back"></u-button>
  67. <u-button type="primary" @click="save" text="保存"></u-button>
  68. </view>
  69. <produceList ref="produceListRef" v-show="current==1" :isTemporary="true"></produceList>
  70. <businessList ref="businessListRef" v-show="current==2"></businessList>
  71. <personnelList ref="personnelListRef" :linkList="linkList" v-show="current==3"></personnelList>
  72. <u-toast ref="uToast"></u-toast>
  73. </view>
  74. </template>
  75. <script>
  76. // file:///D:/中赢/aiot-app/pages/warehouse/enterHouse/selectEnterType.vue
  77. import {
  78. getByCode
  79. } from '@/api/pda/common.js'
  80. import {
  81. contactDetail,
  82. } from '@/api/saleManage/contact/index.js'
  83. import {
  84. businessopportunitySave,
  85. getDetail
  86. } from '@/api/saleManage/businessOpportunity/index.js'
  87. import produceList from '../components/produceList.vue'
  88. import businessList from './components/businessList.vue'
  89. import personnelList from './components/personnelList.vue'
  90. export default {
  91. components: {
  92. produceList,
  93. businessList,
  94. personnelList
  95. },
  96. data() {
  97. return {
  98. list: ['基本信息', '产品清单', '竞品', '关键人信息'],
  99. current: 0,
  100. form: {
  101. id: '',
  102. contactName: '',
  103. contactId: '',
  104. budget: null,
  105. expectedClosingDate: '',
  106. sourceCode: '',
  107. sourceName: '',
  108. stageCode: '',
  109. stageName: '',
  110. winRate: null,
  111. name: '',
  112. remark: '',
  113. responsibleName: '',
  114. responsibleId: '',
  115. source: '',
  116. status: 1,
  117. pricingWay: '1',
  118. files: []
  119. },
  120. business_opport_code: [],
  121. linkList: [],
  122. }
  123. },
  124. created() {
  125. this.getByCode()
  126. },
  127. onLoad(data) {
  128. uni.$off('setSelectList')
  129. uni.$on('setSelectList', async (data) => {
  130. if (data && data.length > 0) {
  131. const {
  132. linkList
  133. } = await contactDetail(data[0].id)
  134. this.linkList = linkList
  135. this.$set(this.form, 'contactId', data[0].id);
  136. this.$set(this.form, 'contactName', data[0].name);
  137. }
  138. })
  139. if (data && data.id) {
  140. getDetail(data.id).then(async res => {
  141. this.form = res
  142. const {
  143. linkList
  144. } = await contactDetail(res.contactId)
  145. this.linkList = linkList
  146. this.$nextTick(() => {
  147. this.$refs.produceListRef.init(res.productList)
  148. this.$refs.businessListRef.init(res.competAnalysisList)
  149. this.$refs.personnelListRef.init(res.partyList)
  150. })
  151. })
  152. } else {
  153. const userInfo = uni.getStorageSync('userInfo')
  154. this.$set(this.form, 'responsibleId', userInfo.userId);
  155. this.$set(this.form, 'responsibleName', userInfo.name);
  156. }
  157. },
  158. onUnload() {
  159. uni.$off('setSelectList')
  160. // uni.$off('updatelinkList')
  161. },
  162. methods: {
  163. getByCode() {
  164. const codeS = ['business_opport_code']
  165. codeS.forEach(async (code) => {
  166. const codeValue = await getByCode(code);
  167. this[code] = codeValue.map(item => {
  168. const key = Object.keys(item)[0]
  169. return {
  170. value: key,
  171. text: item[key]
  172. }
  173. })
  174. })
  175. },
  176. selectContactShow() {
  177. uni.navigateTo({
  178. url: '/pages/saleManage/components/selectContact?isAll=' + 2
  179. })
  180. },
  181. sourceCodeOnchange(e) {
  182. const value = e.detail.value
  183. this.form.sourceCode = value.map(item => item.value).toString()
  184. this.form.sourceName = value.map(item => item.text).toString()
  185. },
  186. radioChange(e) {
  187. this.form.pricingWay = e.detail.value
  188. this.$nextTick(() => {
  189. this.$refs.produceListRef.getTotalPrice()
  190. })
  191. },
  192. sectionChange(index) {
  193. this.current = index;
  194. },
  195. async save() {
  196. try {
  197. if (!this.form.contactName) {
  198. this.$refs.uToast.show({
  199. type: "error",
  200. message: "请选择客户",
  201. })
  202. return
  203. }
  204. if (!this.form.name) {
  205. this.$refs.uToast.show({
  206. type: "error",
  207. message: "请输入商机名称",
  208. })
  209. return
  210. }
  211. if (!this.form.sourceCode) {
  212. this.$refs.uToast.show({
  213. type: "error",
  214. message: "请选择商机来源",
  215. })
  216. return
  217. }
  218. if (this.$refs.produceListRef.getValue().length == 0) {
  219. this.$refs.uToast.show({
  220. type: "error",
  221. message: "产品清单不能为空",
  222. })
  223. return;
  224. }
  225. uni.showLoading({
  226. title: '加载中'
  227. })
  228. const data = {
  229. opportunity: this.form,
  230. competAnalysisList: this.$refs.businessListRef.getValue(),
  231. partyList: this.$refs.personnelListRef.getValue(),
  232. productList: this.$refs.produceListRef.getValue()
  233. };
  234. businessopportunitySave(data)
  235. .then((id) => {
  236. uni.hideLoading()
  237. this.back()
  238. })
  239. .catch((e) => {
  240. uni.hideLoading()
  241. });
  242. } catch (error) {
  243. uni.hideLoading()
  244. console.log(error, 'error')
  245. }
  246. },
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .required-mark {
  252. color: #FF3333;
  253. margin-right: 4rpx;
  254. }
  255. /deep/.u-cell__body__content {
  256. flex: none;
  257. margin-right: 16rpx;
  258. }
  259. .mainBox {
  260. padding-bottom: 84rpx;
  261. }
  262. .footerButton {
  263. width: 100%;
  264. height: 84rpx;
  265. display: flex;
  266. position: fixed;
  267. bottom: 0;
  268. z-index: 10;
  269. background-color: #fff;
  270. /deep/.u-button {
  271. height: 100%;
  272. }
  273. >view {
  274. flex: 1;
  275. }
  276. }
  277. /deep/.u-button {
  278. // height: 100%;
  279. }
  280. /deep/.u-subsection__item__text {
  281. font-size: 28rpx !important;
  282. }
  283. /deep/.uni-input-placeholder {
  284. font-size: 28rpx !important;
  285. }
  286. /deep/.selected-item {
  287. font-size: 28rpx !important;
  288. }
  289. /deep/.uni-input-input {
  290. font-size: 28rpx !important;
  291. }
  292. </style>