follow.vue 12 KB

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