follow.vue 13 KB

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