follow.vue 13 KB

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