follow.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-05-22 17:37:35
  6. * @Description: file content
  7. * @FilePath: \oms\pages\publicPages\follow.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. <u-form :model="addForm" :rules="rules" ref="addForm" label-width="0">
  23. <u-form-item prop="content" customStyle="padding:40rpx 0 34rpx">
  24. <view class="form-label flex_l">
  25. <view class="label-tag"></view>
  26. 跟进内容
  27. </view>
  28. <u-textarea
  29. v-model="addForm.content"
  30. placeholder="请输入跟进内容"
  31. maxlength="800"
  32. height="190rpx"
  33. count
  34. customStyle="border-radius:16rpx"></u-textarea>
  35. </u-form-item>
  36. <u-form-item prop="date" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showDate = true">
  37. <view class="form-label flex_l">
  38. <view class="label-tag"></view>
  39. 跟进时间
  40. </view>
  41. <u-input
  42. :readonly="true"
  43. placeholder="请选择跟进时间"
  44. v-model="addForm.date"
  45. border="none"
  46. suffixIcon="arrow-down"
  47. suffixIconStyle="color:#CDCDCD"
  48. clearable
  49. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  50. </u-form-item>
  51. <u-form-item prop="mode" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showMode = true">
  52. <view class="form-label flex_l">
  53. <view class="label-tag"></view>
  54. 跟进方式
  55. </view>
  56. <u-input
  57. :readonly="true"
  58. placeholder="请选择跟进方式"
  59. v-model="addForm.mode"
  60. border="none"
  61. suffixIcon="arrow-down"
  62. suffixIconStyle="color:#CDCDCD"
  63. clearable
  64. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  65. </u-form-item>
  66. <u-form-item prop="contactsName" borderBottom customStyle="padding:40rpx 0 30rpx" @click="open">
  67. <view class="form-label flex_l">
  68. <view class="label-tag"></view>
  69. 联系人
  70. </view>
  71. <u-input
  72. :readonly="true"
  73. placeholder="请选择联系人"
  74. v-model="addForm.contactsName"
  75. border="none"
  76. suffixIcon="arrow-down"
  77. suffixIconStyle="color:#CDCDCD"
  78. clearable
  79. customStyle="padding: 0 30rpx 0 12rpx"></u-input>
  80. </u-form-item>
  81. </u-form>
  82. <view class="upload-file-box">
  83. <view class="form-label flex_l">附件</view>
  84. <uni-file-picker file-mediatype="all" v-model="imageValue" mode="grid" @select="select" ref="upload" limit="1">
  85. <view class="upload-btn">
  86. <u-icon name="plus-circle-fill" color="blue" size="28"></u-icon>
  87. </view>
  88. </uni-file-picker>
  89. </view>
  90. <view class="save" @click="handleAdd">保存</view>
  91. <!-- 选择跟进方式 -->
  92. <u-picker
  93. :show="showMode"
  94. :columns="modeColumns"
  95. keyName="label"
  96. @cancel="showMode = false"
  97. @confirm="pickMode"></u-picker>
  98. <!-- 选择下次时间 -->
  99. <u-datetime-picker
  100. v-if="showDate"
  101. :maxDate="maxDate"
  102. :show="showDate"
  103. mode="datetime"
  104. v-model="addForm.date"
  105. @cancel="showDate = false"
  106. @confirm="pickDate"></u-datetime-picker>
  107. </view>
  108. <u-notify ref="uNotify"></u-notify>
  109. <u-toast ref="uToast"></u-toast>
  110. <!-- 客户联系人 -->
  111. <customer-contact ref="concat" @close="closeConcat"></customer-contact>
  112. <!-- 项目联系人 -->
  113. <project-contact ref="projectConcat" @close="closeConcat"></project-contact>
  114. <!-- 经销商代理商联系人 -->
  115. <distr-contact ref="distrConcat" @close="closeConcat" :distrType="targetType"></distr-contact>
  116. </view>
  117. </template>
  118. <script>
  119. // import { mapGetters } from 'vuex'
  120. import to from 'await-to-js'
  121. import followApi from '../../api/follow'
  122. import distrApi from '../../api/base/distr'
  123. import custApi from '../../api/customer'
  124. import prodApi from '../../api/project'
  125. import bidApi from '../../api/bid'
  126. import ProjectContact from '@/components/ProjectContact'
  127. import CustomerContact from '@/components/CustomerContact'
  128. import DistrContact from '@/components/DistrContact'
  129. export default {
  130. name: 'omsIndex',
  131. components: {
  132. CustomerContact,
  133. ProjectContact,
  134. DistrContact,
  135. },
  136. data() {
  137. return {
  138. imageValue: [],
  139. height: '',
  140. paddingTop: '',
  141. showMode: false, //选择行业
  142. showDate: false,
  143. maxDate: new Date() * 1,
  144. modeColumns: [
  145. [
  146. {
  147. label: '电话',
  148. id: '10',
  149. },
  150. {
  151. label: '邮件',
  152. id: '20',
  153. },
  154. {
  155. label: '拜访',
  156. id: '30',
  157. },
  158. ],
  159. ],
  160. addForm: {
  161. files: [],
  162. date: this.parseTime(new Date(), '{y}-{m}-{d}'), //时间
  163. content: '', //客户姓名
  164. mode: '', //跟进方式
  165. modeId: 0,
  166. fileName: '', //附件
  167. contactsName: '', //联系人
  168. contactsId: 0, //联系人ID
  169. },
  170. targetType: 0, //跟进对象类型(10客户,20项目,30合同,40回款,50经销商,50代理商)
  171. rules: {
  172. content: {
  173. type: 'string',
  174. required: true,
  175. message: '请填写跟进内容',
  176. trigger: ['blur'],
  177. },
  178. date: {
  179. type: 'string',
  180. required: true,
  181. message: '请填写跟进时间',
  182. trigger: ['blur'],
  183. },
  184. mode: {
  185. type: 'string',
  186. required: true,
  187. message: '请选择跟进方式',
  188. trigger: ['blur', 'change'],
  189. },
  190. contactsName: {
  191. type: 'string',
  192. required: true,
  193. message: '请选择联系人',
  194. trigger: ['blur', 'change'],
  195. },
  196. },
  197. details: {},
  198. curId: 0,
  199. }
  200. },
  201. computed: {
  202. // ...mapGetters(['details']),
  203. },
  204. onLoad(option) {
  205. this.targetType = option.targetType
  206. this.curId = parseInt(option.id)
  207. },
  208. created() {
  209. const navData = uni.getMenuButtonBoundingClientRect()
  210. this.height = navData.height + 'px'
  211. this.paddingTop = navData.top + 'px'
  212. },
  213. mounted() {
  214. this.initData()
  215. },
  216. methods: {
  217. // 获取客户/项目信息
  218. async initData() {
  219. if (this.targetType == '10') {
  220. //客户
  221. const [err, res] = await to(
  222. custApi.getDetail({
  223. ids: [this.curId],
  224. })
  225. )
  226. if (err) return
  227. if (res && res.code == 200) {
  228. this.details = res.data.list[0]
  229. }
  230. } else if (this.targetType == '20') {
  231. //项目
  232. const [err, res] = await to(
  233. prodApi.getDetail({
  234. id: this.curId,
  235. })
  236. )
  237. if (err) return
  238. if (res && res.code == 200) {
  239. this.details = res.data
  240. }
  241. } else if (this.targetType == '50') {
  242. // 经销商代理商
  243. const [err, res] = await to(distrApi.getEntity({ id: this.curId }))
  244. if (err) return
  245. if (res && res.code == 200) {
  246. this.details = res.data.list
  247. }
  248. } else if (this.targetType == '60') {
  249. // 招标信息
  250. const [err, res] = await to(bidApi.get({ id: this.curId }))
  251. if (err) return
  252. if (res && res.code == 200) {
  253. this.details = res.data
  254. }
  255. }
  256. },
  257. // 打开联系人
  258. open() {
  259. if (this.targetType == '10') {
  260. this.$refs.concat.open(this.details.id)
  261. } else if (this.targetType == '20') {
  262. this.$refs.projectConcat.open(this.details.id, this.details.custId)
  263. } else if (this.targetType == '50') {
  264. this.$refs.distrConcat.open(this.details.id)
  265. } else if (this.targetType == '60') {
  266. this.$refs.concat.open(this.details.custId)
  267. }
  268. },
  269. // 行业选择
  270. pickMode(e) {
  271. this.addForm.modeId = e.value[0].id
  272. this.addForm.mode = e.value[0].label
  273. this.showMode = false
  274. },
  275. async pickDate(e) {
  276. this.showDate = false
  277. const timeFormat = uni.$u.timeFormat
  278. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd hh:MM')
  279. this.addForm.date = timeValue
  280. },
  281. // 关闭选择用户
  282. closeConcat(user) {
  283. if (user) {
  284. if (this.targetType == '50') {
  285. this.addForm.contactsName = user.name
  286. this.addForm.contactsId = user.id
  287. } else {
  288. this.addForm.contactsName = user.label
  289. this.addForm.contactsId = user.id
  290. }
  291. }
  292. },
  293. handleAdd() {
  294. this.$refs.addForm
  295. .validate()
  296. .then(async () => {
  297. let idParams = {}
  298. if (this.targetType == '10') {
  299. idParams = {
  300. custId: this.details.id,
  301. custName: this.details.custName,
  302. targetId: this.details.id,
  303. targetName: this.details.custName,
  304. }
  305. } else if (this.targetType == '20') {
  306. idParams = {
  307. custId: this.details.custId,
  308. custName: this.details.custName,
  309. targetId: this.details.id,
  310. targetName: this.details.nboName,
  311. }
  312. } else if (this.targetType == '50') {
  313. idParams = {
  314. targetId: this.details.id,
  315. targetName: this.details.distName,
  316. }
  317. } else if (this.targetType == '60') {
  318. idParams = {
  319. targetId: this.details.id,
  320. targetName: this.details.title,
  321. }
  322. }
  323. let params = Object.assign(
  324. {
  325. contactsId: this.addForm.contactsId,
  326. contactsName: this.addForm.contactsName,
  327. followContent: this.addForm.content,
  328. followDate: this.addForm.date,
  329. followType: this.addForm.modeId,
  330. targetType: this.targetType,
  331. files: this.addForm.files,
  332. },
  333. idParams
  334. )
  335. const [err, res] = await to(followApi.createFollow(params))
  336. if (err) return
  337. if (res && res.code == 200) {
  338. this.$refs.uToast.show({
  339. type: 'success',
  340. message: '创建成功',
  341. complete: () => {
  342. uni.navigateBack({
  343. //关闭当前页面,返回上一页面或多级页面。
  344. delta: 1,
  345. })
  346. },
  347. })
  348. }
  349. })
  350. .catch((err) => {
  351. this.$refs.uNotify.show({
  352. top: this.height + this.paddingTop + 10,
  353. type: 'warning',
  354. message: err[0].message,
  355. duration: 1000 * 3,
  356. })
  357. })
  358. },
  359. // // 选择上传触发函数
  360. select(e) {
  361. let url = process.uniEnv.VUE_APP_UPLOAD_WEED
  362. uni.request({
  363. url, //仅为示例,并非真实接口地址。
  364. success: (res) => {
  365. this.uploadFiles(e, res.data)
  366. },
  367. })
  368. },
  369. // 上传函数
  370. async uploadFiles(e, res) {
  371. let action = process.uniEnv.VUE_APP_PROTOCOL + res.publicUrl + '/' + res.fid
  372. uni.uploadFile({
  373. url: action,
  374. filePath: e.tempFilePaths[0],
  375. name: 'file',
  376. formData: {
  377. file: e.tempFiles[0].file,
  378. },
  379. success: (res) => {
  380. this.$refs.uToast.show({
  381. type: 'success',
  382. message: '附件上传成功',
  383. })
  384. this.addForm.files = [
  385. {
  386. fileName: e.tempFiles[0].file.name,
  387. fileUrl: action,
  388. },
  389. ]
  390. },
  391. fail: (err) => {},
  392. })
  393. },
  394. goBack() {
  395. uni.navigateBack({
  396. //关闭当前页面,返回上一页面或多级页面。
  397. delta: 1,
  398. })
  399. },
  400. },
  401. }
  402. </script>
  403. <style>
  404. page {
  405. background: #f2f3f5;
  406. }
  407. </style>
  408. <style lang="scss" scoped>
  409. .home {
  410. padding-top: 188rpx;
  411. .nav {
  412. position: absolute;
  413. left: 0;
  414. top: 0;
  415. width: 100%;
  416. height: 284rpx;
  417. background: #3e7ef8;
  418. .title {
  419. position: relative;
  420. text-align: center;
  421. font-size: 32rpx;
  422. font-weight: bold;
  423. color: #ffffff;
  424. .back {
  425. position: absolute;
  426. top: 0;
  427. bottom: 0;
  428. margin: auto;
  429. left: 70rpx;
  430. display: flex;
  431. }
  432. }
  433. }
  434. .main {
  435. position: absolute;
  436. width: 100%;
  437. height: calc(100vh - 188rpx);
  438. background: #ffffff;
  439. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  440. border-radius: 31rpx 31rpx 0 0;
  441. padding: 0 32rpx;
  442. overflow: auto;
  443. padding-bottom: 64rpx;
  444. .form-label {
  445. font-size: 32rpx;
  446. font-weight: bold;
  447. color: #323232;
  448. padding-bottom: 18rpx;
  449. .label-tag {
  450. width: 15rpx;
  451. height: 15rpx;
  452. background: #ff4d4f;
  453. border-radius: 50%;
  454. margin-right: 10rpx;
  455. }
  456. }
  457. .upload-file-box {
  458. padding: 20rpx 0;
  459. position: relative;
  460. .upload-btn {
  461. position: absolute;
  462. right: 0;
  463. top: 26rpx;
  464. }
  465. }
  466. }
  467. .save {
  468. width: 569rpx;
  469. height: 92rpx;
  470. background: #3e7ef8;
  471. border-radius: 31rpx;
  472. margin: 116rpx auto 0;
  473. font-size: 32rpx;
  474. color: #ffffff;
  475. text-align: center;
  476. line-height: 92rpx;
  477. }
  478. }
  479. </style>