follow.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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 ProjectContact from '@/components/ProjectContact'
  126. import CustomerContact from '@/components/CustomerContact'
  127. import DistrContact from '@/components/DistrContact'
  128. export default {
  129. name: 'omsIndex',
  130. components: {
  131. CustomerContact,
  132. ProjectContact,
  133. DistrContact,
  134. },
  135. data() {
  136. return {
  137. imageValue: [],
  138. height: '',
  139. paddingTop: '',
  140. showMode: false, //选择行业
  141. showDate: false,
  142. maxDate: new Date() * 1,
  143. modeColumns: [
  144. [
  145. {
  146. label: '电话',
  147. id: '10',
  148. },
  149. {
  150. label: '邮件',
  151. id: '20',
  152. },
  153. {
  154. label: '拜访',
  155. id: '30',
  156. },
  157. ],
  158. ],
  159. addForm: {
  160. files: [],
  161. date: this.parseTime(new Date(), '{y}-{m}-{d}'), //时间
  162. content: '', //客户姓名
  163. mode: '', //跟进方式
  164. modeId: 0,
  165. fileName: '', //附件
  166. contactsName: '', //联系人
  167. contactsId: 0, //联系人ID
  168. },
  169. targetType: 0, //跟进对象类型(10客户,20项目,30合同,40回款,50经销商,60代理商)
  170. rules: {
  171. content: {
  172. type: 'string',
  173. required: true,
  174. message: '请填写跟进内容',
  175. trigger: ['blur'],
  176. },
  177. date: {
  178. type: 'string',
  179. required: true,
  180. message: '请填写跟进时间',
  181. trigger: ['blur'],
  182. },
  183. mode: {
  184. type: 'string',
  185. required: true,
  186. message: '请选择跟进方式',
  187. trigger: ['blur', 'change'],
  188. },
  189. contactsName: {
  190. type: 'string',
  191. required: true,
  192. message: '请选择联系人',
  193. trigger: ['blur', 'change'],
  194. },
  195. },
  196. details: {},
  197. curId: 0,
  198. }
  199. },
  200. computed: {
  201. // ...mapGetters(['details']),
  202. },
  203. onLoad(option) {
  204. this.targetType = option.targetType
  205. this.curId = parseInt(option.id)
  206. },
  207. created() {
  208. const navData = uni.getMenuButtonBoundingClientRect()
  209. this.height = navData.height + 'px'
  210. this.paddingTop = navData.top + 'px'
  211. },
  212. mounted() {
  213. this.initData()
  214. },
  215. methods: {
  216. // 获取客户/项目信息
  217. async initData() {
  218. if (this.targetType == '10') {
  219. //客户
  220. const [err, res] = await to(
  221. custApi.getDetail({
  222. ids: [this.curId],
  223. })
  224. )
  225. if (err) return
  226. if (res && res.code == 200) {
  227. this.details = res.data.list[0]
  228. }
  229. } else if (this.targetType == '20') {
  230. //项目
  231. const [err, res] = await to(
  232. prodApi.getDetail({
  233. id: this.curId,
  234. })
  235. )
  236. if (err) return
  237. if (res && res.code == 200) {
  238. this.details = res.data
  239. }
  240. } else if (this.targetType == '50' || this.targetType == '60') {
  241. const [err, res] = await to(distrApi.getEntity({ id: this.curId }))
  242. if (err) return
  243. if (res && res.code == 200) {
  244. this.details = res.data.list
  245. }
  246. }
  247. },
  248. // 打开联系人
  249. open() {
  250. if (this.targetType == '10') {
  251. this.$refs.concat.open(this.details.id)
  252. } else if (this.targetType == '20') {
  253. this.$refs.projectConcat.open(this.details.id, this.details.custId)
  254. } else if (this.targetType == '50' || this.targetType == '60') {
  255. console.log(this.details.id)
  256. this.$refs.distrConcat.open(this.details.id)
  257. }
  258. },
  259. // 行业选择
  260. pickMode(e) {
  261. this.addForm.modeId = e.value[0].id
  262. this.addForm.mode = e.value[0].label
  263. this.showMode = false
  264. },
  265. async pickDate(e) {
  266. this.showDate = false
  267. const timeFormat = uni.$u.timeFormat
  268. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd hh:MM')
  269. this.addForm.date = timeValue
  270. },
  271. // 关闭选择用户
  272. closeConcat(user) {
  273. if (user) {
  274. if (this.targetType == '50' || this.targetType == '60') {
  275. this.addForm.contactsName = user.name
  276. this.addForm.contactsId = user.id
  277. } else {
  278. this.addForm.contactsName = user.label
  279. this.addForm.contactsId = user.id
  280. }
  281. }
  282. },
  283. handleAdd() {
  284. this.$refs.addForm
  285. .validate()
  286. .then(async () => {
  287. let idParams = {}
  288. if (this.targetType == '10') {
  289. idParams = {
  290. custId: this.details.id,
  291. custName: this.details.custName,
  292. targetId: this.details.id,
  293. targetName: this.details.custName,
  294. }
  295. } else if (this.targetType == '20') {
  296. idParams = {
  297. custId: this.details.custId,
  298. custName: this.details.custName,
  299. targetId: this.details.id,
  300. targetName: this.details.nboName,
  301. }
  302. } else if (this.targetType == '50' || this.targetType == '60') {
  303. idParams = {
  304. targetId: this.details.id,
  305. targetName: this.details.distName,
  306. }
  307. }
  308. let params = Object.assign(
  309. {
  310. contactsId: this.addForm.contactsId,
  311. contactsName: this.addForm.contactsName,
  312. followContent: this.addForm.content,
  313. followDate: this.addForm.date,
  314. followType: this.addForm.modeId,
  315. targetType: this.targetType,
  316. files: this.addForm.files,
  317. },
  318. idParams
  319. )
  320. const [err, res] = await to(followApi.createFollow(params))
  321. if (err) return
  322. if (res && res.code == 200) {
  323. this.$refs.uToast.show({
  324. type: 'success',
  325. message: '创建成功',
  326. complete: () => {
  327. uni.navigateBack({
  328. //关闭当前页面,返回上一页面或多级页面。
  329. delta: 1,
  330. })
  331. },
  332. })
  333. }
  334. })
  335. .catch((err) => {
  336. this.$refs.uNotify.show({
  337. top: this.height + this.paddingTop + 10,
  338. type: 'warning',
  339. message: err[0].message,
  340. duration: 1000 * 3,
  341. })
  342. })
  343. },
  344. // // 选择上传触发函数
  345. select(e) {
  346. let url = process.uniEnv.VUE_APP_UPLOAD_WEED
  347. uni.request({
  348. url, //仅为示例,并非真实接口地址。
  349. success: (res) => {
  350. this.uploadFiles(e, res.data)
  351. },
  352. })
  353. },
  354. // 上传函数
  355. async uploadFiles(e, res) {
  356. let action = process.uniEnv.VUE_APP_PROTOCOL + res.publicUrl + '/' + res.fid
  357. uni.uploadFile({
  358. url: action,
  359. filePath: e.tempFilePaths[0],
  360. name: 'file',
  361. formData: {
  362. file: e.tempFiles[0].file,
  363. },
  364. success: (res) => {
  365. this.$refs.uToast.show({
  366. type: 'success',
  367. message: '附件上传成功',
  368. })
  369. this.addForm.files = [
  370. {
  371. fileName: e.tempFiles[0].file.name,
  372. fileUrl: action,
  373. },
  374. ]
  375. },
  376. fail: (err) => {},
  377. })
  378. },
  379. goBack() {
  380. uni.navigateBack({
  381. //关闭当前页面,返回上一页面或多级页面。
  382. delta: 1,
  383. })
  384. },
  385. },
  386. }
  387. </script>
  388. <style>
  389. page {
  390. background: #f2f3f5;
  391. }
  392. </style>
  393. <style lang="scss" scoped>
  394. .home {
  395. padding-top: 188rpx;
  396. .nav {
  397. position: absolute;
  398. left: 0;
  399. top: 0;
  400. width: 100%;
  401. height: 284rpx;
  402. background: #3e7ef8;
  403. .title {
  404. position: relative;
  405. text-align: center;
  406. font-size: 32rpx;
  407. font-weight: bold;
  408. color: #ffffff;
  409. .back {
  410. position: absolute;
  411. top: 0;
  412. bottom: 0;
  413. margin: auto;
  414. left: 70rpx;
  415. display: flex;
  416. }
  417. }
  418. }
  419. .main {
  420. position: absolute;
  421. width: 100%;
  422. height: calc(100vh - 188rpx);
  423. background: #ffffff;
  424. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  425. border-radius: 31rpx 31rpx 0 0;
  426. padding: 0 32rpx;
  427. overflow: auto;
  428. padding-bottom: 64rpx;
  429. .form-label {
  430. font-size: 32rpx;
  431. font-weight: bold;
  432. color: #323232;
  433. padding-bottom: 18rpx;
  434. .label-tag {
  435. width: 15rpx;
  436. height: 15rpx;
  437. background: #ff4d4f;
  438. border-radius: 50%;
  439. margin-right: 10rpx;
  440. }
  441. }
  442. .upload-file-box {
  443. padding: 20rpx 0;
  444. position: relative;
  445. .upload-btn {
  446. position: absolute;
  447. right: 0;
  448. top: 26rpx;
  449. }
  450. }
  451. }
  452. .save {
  453. width: 569rpx;
  454. height: 92rpx;
  455. background: #3e7ef8;
  456. border-radius: 31rpx;
  457. margin: 116rpx auto 0;
  458. font-size: 32rpx;
  459. color: #ffffff;
  460. text-align: center;
  461. line-height: 92rpx;
  462. }
  463. }
  464. </style>