follow.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <!--
  2. * @Author: liuzhenlin 461480418@qq.ocm
  3. * @Date: 2023-01-12 11:57:48
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-02-17 16:55:08
  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">
  84. <view class="label-tag"></view>
  85. 附件
  86. </view>
  87. <uni-file-picker
  88. file-mediatype="all"
  89. v-model="imageValue"
  90. mode="grid"
  91. @select="select"
  92. @progress="progress"
  93. @success="success"
  94. @fail="fail"
  95. ref="upload"
  96. limit="1">
  97. <view class="upload-btn">
  98. <u-icon name="plus-circle-fill" color="blue" size="28"></u-icon>
  99. </view>
  100. </uni-file-picker>
  101. </view>
  102. <view class="save" @click="handleAdd">保存</view>
  103. <!-- 选择跟进方式 -->
  104. <u-picker
  105. :show="showMode"
  106. :columns="modeColumns"
  107. keyName="label"
  108. @cancel="showMode = false"
  109. @confirm="pickMode"></u-picker>
  110. <!-- 选择下次时间 -->
  111. <u-datetime-picker
  112. v-if="showDate"
  113. :show="showDate"
  114. mode="datetime"
  115. v-model="addForm.date"
  116. @cancel="showDate = false"
  117. @confirm="pickDate"></u-datetime-picker>
  118. </view>
  119. <u-notify ref="uNotify"></u-notify>
  120. <u-toast ref="uToast"></u-toast>
  121. <!-- 客户联系人 -->
  122. <customer-contact ref="concat" @close="closeConcat"></customer-contact>
  123. <!-- 项目联系人 -->
  124. <project-contact ref="projectConcat" @close="closeConcat"></project-contact>
  125. </view>
  126. </template>
  127. <script>
  128. import { mapGetters } from 'vuex'
  129. import to from 'await-to-js'
  130. import customerApi from '../../api/customer'
  131. import ProjectContact from '../../components/ProjectContact'
  132. import CustomerContact from '../../components/CustomerContact'
  133. export default {
  134. name: 'omsIndex',
  135. components: { CustomerContact, ProjectContact },
  136. data() {
  137. return {
  138. imageValue: [],
  139. height: '',
  140. paddingTop: '',
  141. showMode: false, //选择行业
  142. showDate: false,
  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} {h}:{i}'), //时间
  162. content: '', //客户姓名
  163. mode: '', //跟进方式
  164. modeId: 0,
  165. fileName: '', //附件
  166. contactsName: '', //联系人
  167. contactsId: 0, //联系人ID
  168. },
  169. targetType: 0, //跟进对象类型(10客户,20项目,30合同,40回款)
  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. }
  197. },
  198. computed: {
  199. ...mapGetters(['followPageDetail']),
  200. },
  201. onLoad(option) {
  202. this.targetType = option.targetType
  203. },
  204. created() {
  205. const navData = uni.getMenuButtonBoundingClientRect()
  206. this.height = navData.height + 'px'
  207. this.paddingTop = navData.top + 'px'
  208. },
  209. mounted() {
  210. console.log(this.followPageDetail)
  211. },
  212. methods: {
  213. // 打开客户联系人
  214. open() {
  215. console.log(this.followPageDetail)
  216. if (this.targetType == '10') {
  217. this.$refs.concat.open(this.followPageDetail.id)
  218. } else if (this.targetType == '20') {
  219. this.$refs.projectConcat.open(this.followPageDetail.id, this.followPageDetail.custId)
  220. }
  221. },
  222. // 行业选择
  223. pickMode(e) {
  224. console.log(e)
  225. this.addForm.modeId = e.value[0].id
  226. this.addForm.mode = e.value[0].label
  227. this.showMode = false
  228. },
  229. async pickDate(e) {
  230. this.showDate = false
  231. const timeFormat = uni.$u.timeFormat
  232. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd hh:MM')
  233. this.addForm.date = timeValue
  234. console.log(timeValue)
  235. },
  236. // 关闭选择用户
  237. closeConcat(user) {
  238. if (user) {
  239. console.log(user)
  240. this.addForm.contactsName = user.label
  241. this.addForm.contactsId = user.id
  242. }
  243. },
  244. handleAdd() {
  245. console.log(this.followPageDetail)
  246. this.$refs.addForm
  247. .validate()
  248. .then(async () => {
  249. let idParams = {}
  250. if (this.targetType == '10') {
  251. idParams = {
  252. custId: this.followPageDetail.id,
  253. custName: this.followPageDetail.custName,
  254. targetId: this.followPageDetail.id,
  255. targetName: this.followPageDetail.custName,
  256. }
  257. } else if (this.targetType == '20') {
  258. idParams = {
  259. custId: this.followPageDetail.custId,
  260. custName: this.followPageDetail.custName,
  261. targetId: this.followPageDetail.custId,
  262. targetName: this.followPageDetail.custName,
  263. }
  264. }
  265. let params = Object.assign(
  266. {
  267. contactsId: this.addForm.contactsId,
  268. contactsName: this.addForm.contactsName,
  269. followContent: this.addForm.content,
  270. followDate: this.addForm.date,
  271. followType: this.addForm.modeId,
  272. targetType: this.targetType,
  273. files: this.addForm.files,
  274. },
  275. idParams
  276. )
  277. const [err, res] = await to(customerApi.createFollow(params))
  278. if (err) return
  279. if (res && res.code == 200) {
  280. this.$refs.uToast.show({
  281. type: 'success',
  282. message: '创建成功',
  283. complete: () => {
  284. uni.navigateBack({
  285. //关闭当前页面,返回上一页面或多级页面。
  286. delta: 1,
  287. })
  288. },
  289. })
  290. }
  291. })
  292. .catch((err) => {
  293. console.log(err)
  294. this.$refs.uNotify.show({
  295. top: this.height + this.paddingTop + 10,
  296. type: 'warning',
  297. message: err[0].message,
  298. duration: 1000 * 3,
  299. })
  300. })
  301. },
  302. // // 选择上传触发函数
  303. select(e) {
  304. console.log(e)
  305. let url = process.uniEnv.VUE_APP_UPLOAD_WEED
  306. uni.request({
  307. url, //仅为示例,并非真实接口地址。
  308. success: (res) => {
  309. this.uploadFiles(e, res.data)
  310. },
  311. })
  312. },
  313. // 上传函数
  314. async uploadFiles(e, res) {
  315. let action = 'http://' + res.url + '/' + res.fid
  316. uni.uploadFile({
  317. url: action,
  318. filePath: e.tempFilePaths[0],
  319. name: 'file',
  320. formData: {
  321. file: e.tempFiles[0].file,
  322. },
  323. success: (res) => {
  324. this.addForm.files = [{ fileName: e.tempFiles[0].file.name, fileUrl: action }]
  325. },
  326. fail: () => {
  327. console.log('err')
  328. },
  329. })
  330. },
  331. // 获取上传进度
  332. progress(e) {
  333. console.log('上传进度:', e)
  334. },
  335. // 上传成功
  336. success(e) {
  337. console.log('上传成功')
  338. },
  339. // 上传失败
  340. fail(e) {
  341. console.log('上传失败:', e)
  342. },
  343. goBack() {
  344. uni.navigateBack({
  345. //关闭当前页面,返回上一页面或多级页面。
  346. delta: 1,
  347. })
  348. },
  349. },
  350. }
  351. </script>
  352. <style>
  353. page {
  354. background: #f2f3f5;
  355. }
  356. </style>
  357. <style lang="scss" scoped>
  358. .home {
  359. padding-top: 188rpx;
  360. .nav {
  361. position: absolute;
  362. left: 0;
  363. top: 0;
  364. width: 100%;
  365. height: 284rpx;
  366. background: #3e7ef8;
  367. .title {
  368. position: relative;
  369. text-align: center;
  370. font-size: 32rpx;
  371. font-weight: bold;
  372. color: #ffffff;
  373. .back {
  374. position: absolute;
  375. top: 0;
  376. bottom: 0;
  377. margin: auto;
  378. left: 70rpx;
  379. display: flex;
  380. }
  381. }
  382. }
  383. .main {
  384. position: absolute;
  385. width: 100%;
  386. height: calc(100vh - 188rpx);
  387. background: #ffffff;
  388. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  389. border-radius: 31rpx 31rpx 0 0;
  390. padding: 0 32rpx;
  391. overflow: auto;
  392. padding-bottom: 64rpx;
  393. .form-label {
  394. font-size: 32rpx;
  395. font-weight: bold;
  396. color: #323232;
  397. padding-bottom: 18rpx;
  398. .label-tag {
  399. width: 15rpx;
  400. height: 15rpx;
  401. background: rgba(62, 126, 248, 0.6);
  402. border-radius: 50%;
  403. margin-right: -4rpx;
  404. }
  405. }
  406. .upload-file-box {
  407. padding: 20rpx 0;
  408. position: relative;
  409. .upload-btn {
  410. position: absolute;
  411. right: 0;
  412. top: 26rpx;
  413. }
  414. }
  415. }
  416. .save {
  417. width: 569rpx;
  418. height: 92rpx;
  419. background: #3e7ef8;
  420. border-radius: 31rpx;
  421. margin: 116rpx auto 0;
  422. font-size: 32rpx;
  423. color: #ffffff;
  424. text-align: center;
  425. line-height: 92rpx;
  426. }
  427. }
  428. </style>