follow.vue 13 KB

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