follow.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. console.log(option)
  197. this.targetType = option.targetType
  198. this.curId = parseInt(option.id)
  199. },
  200. created() {
  201. const navData = uni.getMenuButtonBoundingClientRect()
  202. this.height = navData.height + 'px'
  203. this.paddingTop = navData.top + 'px'
  204. },
  205. mounted() {
  206. console.log(this.details)
  207. this.initData()
  208. },
  209. methods: {
  210. // 获取客户/项目信息
  211. async initData() {
  212. if (this.targetType == '10') {
  213. //客户
  214. const [err, res] = await to(
  215. custApi.getDetail({
  216. ids: [this.curId],
  217. })
  218. )
  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(
  226. prodApi.getDetail({
  227. id: this.curId,
  228. })
  229. )
  230. if (err) return
  231. if (res && res.code == 200) {
  232. this.details = res.data
  233. }
  234. }
  235. },
  236. // 打开客户联系人
  237. open() {
  238. console.log(this.details)
  239. if (this.targetType == '10') {
  240. this.$refs.concat.open(this.details.id)
  241. } else if (this.targetType == '20') {
  242. this.$refs.projectConcat.open(this.details.id, this.details.custId)
  243. }
  244. },
  245. // 行业选择
  246. pickMode(e) {
  247. console.log(e)
  248. this.addForm.modeId = e.value[0].id
  249. this.addForm.mode = e.value[0].label
  250. this.showMode = false
  251. },
  252. async pickDate(e) {
  253. this.showDate = false
  254. const timeFormat = uni.$u.timeFormat
  255. let timeValue = await timeFormat(e.value, 'yyyy-mm-dd hh:MM')
  256. this.addForm.date = timeValue
  257. console.log(timeValue)
  258. },
  259. // 关闭选择用户
  260. closeConcat(user) {
  261. if (user) {
  262. console.log(user)
  263. this.addForm.contactsName = user.label
  264. this.addForm.contactsId = user.id
  265. }
  266. },
  267. handleAdd() {
  268. console.log(this.details)
  269. this.$refs.addForm
  270. .validate()
  271. .then(async () => {
  272. let idParams = {}
  273. if (this.targetType == '10') {
  274. idParams = {
  275. custId: this.details.id,
  276. custName: this.details.custName,
  277. targetId: this.details.id,
  278. targetName: this.details.custName,
  279. }
  280. } else if (this.targetType == '20') {
  281. idParams = {
  282. custId: this.details.custId,
  283. custName: this.details.custName,
  284. targetId: this.details.id,
  285. targetName: this.details.nboName,
  286. }
  287. }
  288. let params = Object.assign(
  289. {
  290. contactsId: this.addForm.contactsId,
  291. contactsName: this.addForm.contactsName,
  292. followContent: this.addForm.content,
  293. followDate: this.addForm.date,
  294. followType: this.addForm.modeId,
  295. targetType: this.targetType,
  296. files: this.addForm.files,
  297. },
  298. idParams
  299. )
  300. const [err, res] = await to(followApi.createFollow(params))
  301. if (err) return
  302. if (res && res.code == 200) {
  303. this.$refs.uToast.show({
  304. type: 'success',
  305. message: '创建成功',
  306. complete: () => {
  307. uni.navigateBack({
  308. //关闭当前页面,返回上一页面或多级页面。
  309. delta: 1,
  310. })
  311. },
  312. })
  313. }
  314. })
  315. .catch((err) => {
  316. console.log(err)
  317. this.$refs.uNotify.show({
  318. top: this.height + this.paddingTop + 10,
  319. type: 'warning',
  320. message: err[0].message,
  321. duration: 1000 * 3,
  322. })
  323. })
  324. },
  325. // // 选择上传触发函数
  326. select(e) {
  327. console.log(e)
  328. let url = process.uniEnv.VUE_APP_UPLOAD_WEED
  329. uni.request({
  330. url, //仅为示例,并非真实接口地址。
  331. success: (res) => {
  332. this.uploadFiles(e, res.data)
  333. },
  334. })
  335. },
  336. // 上传函数
  337. async uploadFiles(e, res) {
  338. let action = process.uniEnv.VUE_APP_PROTOCOL + res.publicUrl + '/' + res.fid
  339. uni.uploadFile({
  340. url: action,
  341. filePath: e.tempFilePaths[0],
  342. name: 'file',
  343. formData: {
  344. file: e.tempFiles[0].file,
  345. },
  346. success: (res) => {
  347. this.$refs.uToast.show({
  348. type: 'success',
  349. message: '附件上传成功',
  350. })
  351. this.addForm.files = [
  352. {
  353. fileName: e.tempFiles[0].file.name,
  354. fileUrl: action,
  355. },
  356. ]
  357. },
  358. fail: (err) => {},
  359. })
  360. },
  361. goBack() {
  362. uni.navigateBack({
  363. //关闭当前页面,返回上一页面或多级页面。
  364. delta: 1,
  365. })
  366. },
  367. },
  368. }
  369. </script>
  370. <style>
  371. page {
  372. background: #f2f3f5;
  373. }
  374. </style>
  375. <style lang="scss" scoped>
  376. .home {
  377. padding-top: 188rpx;
  378. .nav {
  379. position: absolute;
  380. left: 0;
  381. top: 0;
  382. width: 100%;
  383. height: 284rpx;
  384. background: #3e7ef8;
  385. .title {
  386. position: relative;
  387. text-align: center;
  388. font-size: 32rpx;
  389. font-weight: bold;
  390. color: #ffffff;
  391. .back {
  392. position: absolute;
  393. top: 0;
  394. bottom: 0;
  395. margin: auto;
  396. left: 70rpx;
  397. display: flex;
  398. }
  399. }
  400. }
  401. .main {
  402. position: absolute;
  403. width: 100%;
  404. height: calc(100vh - 188rpx);
  405. background: #ffffff;
  406. box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
  407. border-radius: 31rpx 31rpx 0 0;
  408. padding: 0 32rpx;
  409. overflow: auto;
  410. padding-bottom: 64rpx;
  411. .form-label {
  412. font-size: 32rpx;
  413. font-weight: bold;
  414. color: #323232;
  415. padding-bottom: 18rpx;
  416. .label-tag {
  417. width: 15rpx;
  418. height: 15rpx;
  419. background: #ff4d4f;
  420. border-radius: 50%;
  421. margin-right: 10rpx;
  422. }
  423. }
  424. .upload-file-box {
  425. padding: 20rpx 0;
  426. position: relative;
  427. .upload-btn {
  428. position: absolute;
  429. right: 0;
  430. top: 26rpx;
  431. }
  432. }
  433. }
  434. .save {
  435. width: 569rpx;
  436. height: 92rpx;
  437. background: #3e7ef8;
  438. border-radius: 31rpx;
  439. margin: 116rpx auto 0;
  440. font-size: 32rpx;
  441. color: #ffffff;
  442. text-align: center;
  443. line-height: 92rpx;
  444. }
  445. }
  446. </style>