follow.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  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经销商,50代理商)
  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') {
  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') {
  255. this.$refs.distrConcat.open(this.details.id)
  256. }
  257. },
  258. // 行业选择
  259. pickMode(e) {
  260. this.addForm.modeId = e.value[0].id
  261. this.addForm.mode = e.value[0].label
  262. this.showMode = false
  263. },
  264. async pickDate(e) {
  265. this.showDate = false
  266. const timeFormat = uni.$u.timeFormat
  267. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd hh:MM')
  268. this.addForm.date = timeValue
  269. },
  270. // 关闭选择用户
  271. closeConcat(user) {
  272. if (user) {
  273. if (this.targetType == '50') {
  274. this.addForm.contactsName = user.name
  275. this.addForm.contactsId = user.id
  276. } else {
  277. this.addForm.contactsName = user.label
  278. this.addForm.contactsId = user.id
  279. }
  280. }
  281. },
  282. handleAdd() {
  283. this.$refs.addForm
  284. .validate()
  285. .then(async () => {
  286. let idParams = {}
  287. if (this.targetType == '10') {
  288. idParams = {
  289. custId: this.details.id,
  290. custName: this.details.custName,
  291. targetId: this.details.id,
  292. targetName: this.details.custName,
  293. }
  294. } else if (this.targetType == '20') {
  295. idParams = {
  296. custId: this.details.custId,
  297. custName: this.details.custName,
  298. targetId: this.details.id,
  299. targetName: this.details.nboName,
  300. }
  301. } else if (this.targetType == '50') {
  302. idParams = {
  303. targetId: this.details.id,
  304. targetName: this.details.distName,
  305. }
  306. }
  307. let params = Object.assign(
  308. {
  309. contactsId: this.addForm.contactsId,
  310. contactsName: this.addForm.contactsName,
  311. followContent: this.addForm.content,
  312. followDate: this.addForm.date,
  313. followType: this.addForm.modeId,
  314. targetType: this.targetType,
  315. files: this.addForm.files,
  316. },
  317. idParams
  318. )
  319. const [err, res] = await to(followApi.createFollow(params))
  320. if (err) return
  321. if (res && res.code == 200) {
  322. this.$refs.uToast.show({
  323. type: 'success',
  324. message: '创建成功',
  325. complete: () => {
  326. uni.navigateBack({
  327. //关闭当前页面,返回上一页面或多级页面。
  328. delta: 1,
  329. })
  330. },
  331. })
  332. }
  333. })
  334. .catch((err) => {
  335. this.$refs.uNotify.show({
  336. top: this.height + this.paddingTop + 10,
  337. type: 'warning',
  338. message: err[0].message,
  339. duration: 1000 * 3,
  340. })
  341. })
  342. },
  343. // // 选择上传触发函数
  344. select(e) {
  345. let url = process.uniEnv.VUE_APP_UPLOAD_WEED
  346. uni.request({
  347. url, //仅为示例,并非真实接口地址。
  348. success: (res) => {
  349. this.uploadFiles(e, res.data)
  350. },
  351. })
  352. },
  353. // 上传函数
  354. async uploadFiles(e, res) {
  355. let action = process.uniEnv.VUE_APP_PROTOCOL + res.publicUrl + '/' + res.fid
  356. uni.uploadFile({
  357. url: action,
  358. filePath: e.tempFilePaths[0],
  359. name: 'file',
  360. formData: {
  361. file: e.tempFiles[0].file,
  362. },
  363. success: (res) => {
  364. this.$refs.uToast.show({
  365. type: 'success',
  366. message: '附件上传成功',
  367. })
  368. this.addForm.files = [
  369. {
  370. fileName: e.tempFiles[0].file.name,
  371. fileUrl: action,
  372. },
  373. ]
  374. },
  375. fail: (err) => {},
  376. })
  377. },
  378. goBack() {
  379. uni.navigateBack({
  380. //关闭当前页面,返回上一页面或多级页面。
  381. delta: 1,
  382. })
  383. },
  384. },
  385. }
  386. </script>
  387. <style>
  388. page {
  389. background: #f2f3f5;
  390. }
  391. </style>
  392. <style lang="scss" scoped>
  393. .home {
  394. padding-top: 188rpx;
  395. .nav {
  396. position: absolute;
  397. left: 0;
  398. top: 0;
  399. width: 100%;
  400. height: 284rpx;
  401. background: #3e7ef8;
  402. .title {
  403. position: relative;
  404. text-align: center;
  405. font-size: 32rpx;
  406. font-weight: bold;
  407. color: #ffffff;
  408. .back {
  409. position: absolute;
  410. top: 0;
  411. bottom: 0;
  412. margin: auto;
  413. left: 70rpx;
  414. display: flex;
  415. }
  416. }
  417. }
  418. .main {
  419. position: absolute;
  420. width: 100%;
  421. height: calc(100vh - 188rpx);
  422. background: #ffffff;
  423. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  424. border-radius: 31rpx 31rpx 0 0;
  425. padding: 0 32rpx;
  426. overflow: auto;
  427. padding-bottom: 64rpx;
  428. .form-label {
  429. font-size: 32rpx;
  430. font-weight: bold;
  431. color: #323232;
  432. padding-bottom: 18rpx;
  433. .label-tag {
  434. width: 15rpx;
  435. height: 15rpx;
  436. background: #ff4d4f;
  437. border-radius: 50%;
  438. margin-right: 10rpx;
  439. }
  440. }
  441. .upload-file-box {
  442. padding: 20rpx 0;
  443. position: relative;
  444. .upload-btn {
  445. position: absolute;
  446. right: 0;
  447. top: 26rpx;
  448. }
  449. }
  450. }
  451. .save {
  452. width: 569rpx;
  453. height: 92rpx;
  454. background: #3e7ef8;
  455. border-radius: 31rpx;
  456. margin: 116rpx auto 0;
  457. font-size: 32rpx;
  458. color: #ffffff;
  459. text-align: center;
  460. line-height: 92rpx;
  461. }
  462. }
  463. </style>