follow.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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
  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 followApi from '../../api/follow'
  125. import custApi from '../../api/customer'
  126. import prodApi from '../../api/project'
  127. import ProjectContact from '../../components/ProjectContact'
  128. import CustomerContact from '../../components/CustomerContact'
  129. export default {
  130. name: 'omsIndex',
  131. components: { CustomerContact, ProjectContact },
  132. data() {
  133. return {
  134. imageValue: [],
  135. height: '',
  136. paddingTop: '',
  137. showMode: false, //选择行业
  138. showDate: false,
  139. modeColumns: [
  140. [
  141. {
  142. label: '电话',
  143. id: '10',
  144. },
  145. {
  146. label: '邮件',
  147. id: '20',
  148. },
  149. {
  150. label: '拜访',
  151. id: '30',
  152. },
  153. ],
  154. ],
  155. addForm: {
  156. files: [],
  157. date: this.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}'), //时间
  158. content: '', //客户姓名
  159. mode: '', //跟进方式
  160. modeId: 0,
  161. fileName: '', //附件
  162. contactsName: '', //联系人
  163. contactsId: 0, //联系人ID
  164. },
  165. targetType: 0, //跟进对象类型(10客户,20项目,30合同,40回款)
  166. rules: {
  167. content: {
  168. type: 'string',
  169. required: true,
  170. message: '请填写跟进内容',
  171. trigger: ['blur'],
  172. },
  173. date: {
  174. type: 'string',
  175. required: true,
  176. message: '请填写跟进时间',
  177. trigger: ['blur'],
  178. },
  179. mode: {
  180. type: 'string',
  181. required: true,
  182. message: '请选择跟进方式',
  183. trigger: ['blur', 'change'],
  184. },
  185. contactsName: {
  186. type: 'string',
  187. required: true,
  188. message: '请选择联系人',
  189. trigger: ['blur', 'change'],
  190. },
  191. },
  192. details: {},
  193. curId: 0,
  194. }
  195. },
  196. computed: {
  197. // ...mapGetters(['details']),
  198. },
  199. onLoad(option) {
  200. console.log(option)
  201. this.targetType = option.targetType
  202. this.curId = parseInt(option.id)
  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.details)
  211. this.initData()
  212. },
  213. methods: {
  214. // 获取客户/项目信息
  215. async initData() {
  216. if (this.targetType == '10') {
  217. //客户
  218. const [err, res] = await to(custApi.getDetail({ ids: [this.curId] }))
  219. if (err) return
  220. if (res && res.code == 200) {
  221. this.details = res.data.list[0]
  222. }
  223. } else if (this.targetType == '20') {
  224. //项目
  225. const [err, res] = await to(prodApi.getDetail({ id: this.curId }))
  226. if (err) return
  227. if (res && res.code == 200) {
  228. this.details = res.data
  229. }
  230. }
  231. },
  232. // 打开客户联系人
  233. open() {
  234. console.log(this.details)
  235. if (this.targetType == '10') {
  236. this.$refs.concat.open(this.details.id)
  237. } else if (this.targetType == '20') {
  238. this.$refs.projectConcat.open(this.details.id, this.details.custId)
  239. }
  240. },
  241. // 行业选择
  242. pickMode(e) {
  243. console.log(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. console.log(timeValue)
  254. },
  255. // 关闭选择用户
  256. closeConcat(user) {
  257. if (user) {
  258. console.log(user)
  259. this.addForm.contactsName = user.label
  260. this.addForm.contactsId = user.id
  261. }
  262. },
  263. handleAdd() {
  264. console.log(this.details)
  265. this.$refs.addForm
  266. .validate()
  267. .then(async () => {
  268. let idParams = {}
  269. if (this.targetType == '10') {
  270. idParams = {
  271. custId: this.details.id,
  272. custName: this.details.custName,
  273. targetId: this.details.id,
  274. targetName: this.details.custName,
  275. }
  276. } else if (this.targetType == '20') {
  277. idParams = {
  278. custId: this.details.custId,
  279. custName: this.details.custName,
  280. targetId: this.details.id,
  281. targetName: this.details.nboName,
  282. }
  283. }
  284. let params = Object.assign(
  285. {
  286. contactsId: this.addForm.contactsId,
  287. contactsName: this.addForm.contactsName,
  288. followContent: this.addForm.content,
  289. followDate: this.addForm.date,
  290. followType: this.addForm.modeId,
  291. targetType: this.targetType,
  292. files: this.addForm.files,
  293. },
  294. idParams
  295. )
  296. const [err, res] = await to(followApi.createFollow(params))
  297. if (err) return
  298. if (res && res.code == 200) {
  299. this.$refs.uToast.show({
  300. type: 'success',
  301. message: '创建成功',
  302. complete: () => {
  303. uni.navigateBack({
  304. //关闭当前页面,返回上一页面或多级页面。
  305. delta: 1,
  306. })
  307. },
  308. })
  309. }
  310. })
  311. .catch((err) => {
  312. console.log(err)
  313. this.$refs.uNotify.show({
  314. top: this.height + this.paddingTop + 10,
  315. type: 'warning',
  316. message: err[0].message,
  317. duration: 1000 * 3,
  318. })
  319. })
  320. },
  321. // // 选择上传触发函数
  322. select(e) {
  323. console.log(e)
  324. let url = process.uniEnv.VUE_APP_UPLOAD_WEED
  325. uni.request({
  326. url, //仅为示例,并非真实接口地址。
  327. success: (res) => {
  328. this.uploadFiles(e, res.data)
  329. },
  330. })
  331. },
  332. // 上传函数
  333. async uploadFiles(e, res) {
  334. let action = process.uniEnv.VUE_APP_PROTOCOL + res.publicUrl + '/' + res.fid
  335. uni.uploadFile({
  336. url: action,
  337. filePath: e.tempFilePaths[0],
  338. name: 'file',
  339. formData: {
  340. file: e.tempFiles[0].file,
  341. },
  342. success: (res) => {
  343. this.addForm.files = [{ fileName: e.tempFiles[0].file.name, fileUrl: action }]
  344. },
  345. fail: (err) => {},
  346. })
  347. },
  348. // 获取上传进度
  349. progress(e) {
  350. console.log('上传进度:', e)
  351. },
  352. // 上传成功
  353. success(e) {
  354. console.log('上传成功')
  355. },
  356. // 上传失败
  357. fail(e) {
  358. console.log('上传失败:', e)
  359. },
  360. goBack() {
  361. uni.navigateBack({
  362. //关闭当前页面,返回上一页面或多级页面。
  363. delta: 1,
  364. })
  365. },
  366. },
  367. }
  368. </script>
  369. <style>
  370. page {
  371. background: #f2f3f5;
  372. }
  373. </style>
  374. <style lang="scss" scoped>
  375. .home {
  376. padding-top: 188rpx;
  377. .nav {
  378. position: absolute;
  379. left: 0;
  380. top: 0;
  381. width: 100%;
  382. height: 284rpx;
  383. background: #3e7ef8;
  384. .title {
  385. position: relative;
  386. text-align: center;
  387. font-size: 32rpx;
  388. font-weight: bold;
  389. color: #ffffff;
  390. .back {
  391. position: absolute;
  392. top: 0;
  393. bottom: 0;
  394. margin: auto;
  395. left: 70rpx;
  396. display: flex;
  397. }
  398. }
  399. }
  400. .main {
  401. position: absolute;
  402. width: 100%;
  403. height: calc(100vh - 188rpx);
  404. background: #ffffff;
  405. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  406. border-radius: 31rpx 31rpx 0 0;
  407. padding: 0 32rpx;
  408. overflow: auto;
  409. padding-bottom: 64rpx;
  410. .form-label {
  411. font-size: 32rpx;
  412. font-weight: bold;
  413. color: #323232;
  414. padding-bottom: 18rpx;
  415. .label-tag {
  416. width: 15rpx;
  417. height: 15rpx;
  418. background: #ff4d4f;
  419. border-radius: 50%;
  420. margin-right: 10rpx;
  421. }
  422. }
  423. .upload-file-box {
  424. padding: 20rpx 0;
  425. position: relative;
  426. .upload-btn {
  427. position: absolute;
  428. right: 0;
  429. top: 26rpx;
  430. }
  431. }
  432. }
  433. .save {
  434. width: 569rpx;
  435. height: 92rpx;
  436. background: #3e7ef8;
  437. border-radius: 31rpx;
  438. margin: 116rpx auto 0;
  439. font-size: 32rpx;
  440. color: #ffffff;
  441. text-align: center;
  442. line-height: 92rpx;
  443. }
  444. }
  445. </style>