FollowAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <el-dialog :title="title" :visible.sync="dialogFormVisible" @close="close">
  3. <el-form ref="form" label-width="96px" :model="form" :rules="rules">
  4. <el-row>
  5. <el-col :span="12">
  6. <el-form-item label="跟进时间" prop="followDate">
  7. <el-date-picker
  8. v-model="form.followDate"
  9. :picker-options="{
  10. // 时间不能大于当前时间
  11. disabledDate: (time) => {
  12. return time.getTime() > Date.now()
  13. },
  14. }"
  15. placeholder="选择日期"
  16. style="width: 100%"
  17. type="datetime"
  18. value-format="yyyy-MM-dd HH:mm:ss" />
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="12">
  22. <el-form-item label="跟进方式" prop="followType">
  23. <el-select v-model="form.followType" placeholder="请选择" style="width: 100%">
  24. <el-option v-for="item in followTypeOptions" :key="item.key" :label="item.value" :value="item.key" />
  25. </el-select>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="24">
  29. <el-form-item label="本次跟进内容" prop="followContent">
  30. <el-input
  31. v-model="form.followContent"
  32. placeholder="请输入本次跟进内容"
  33. rows="5"
  34. show-word-limit
  35. type="textarea" />
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="24">
  39. <el-form-item label="达成效果" prop="effect">
  40. <el-input v-model="form.effect" placeholder="请输入达成效果" rows="5" show-word-limit type="textarea" />
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="24">
  44. <el-form-item label="问题或困难" prop="issue">
  45. <el-input v-model="form.issue" placeholder="请输入问题或困难" rows="5" show-word-limit type="textarea" />
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="24">
  49. <el-form-item label="下一步跟进计划和目标" prop="furtherPlan">
  50. <el-input
  51. v-model="form.furtherPlan"
  52. placeholder="请输入下一步工作计划及完成时间"
  53. rows="5"
  54. show-word-limit
  55. type="textarea" />
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="12">
  59. <el-form-item label="联系人" prop="contactsName">
  60. <el-input v-model="form.contactsName" readonly suffix-icon="el-icon-search" @focus="handleSelectContact" />
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="12">
  64. <el-form-item label="上传附件" prop="files">
  65. <el-upload
  66. ref="uploadRef"
  67. action="#"
  68. :before-upload="
  69. (file) => {
  70. return beforeAvatarUpload(file)
  71. }
  72. "
  73. :file-list="fileList"
  74. :http-request="uploadrequest">
  75. <el-button size="mini" type="primary">点击上传</el-button>
  76. </el-upload>
  77. </el-form-item>
  78. </el-col>
  79. <!-- <el-col :span="12">-->
  80. <!-- <el-form-item label="提醒对象" prop="reminders">-->
  81. <!-- <el-input v-model="form.reminders" />-->
  82. <!-- </el-form-item>-->
  83. <!-- </el-col>-->
  84. <!-- <el-col :span="12">-->
  85. <!-- <el-form-item label="下次联系时间" prop="nextTime">-->
  86. <!-- <el-date-picker v-model="form.nextTime" placeholder="选择日期" style="width: 100%" type="datetime" />-->
  87. <!-- </el-form-item>-->
  88. <!-- </el-col>-->
  89. <!-- <el-col :span="24">-->
  90. <!-- <el-form-item label="备注" prop="remark">-->
  91. <!-- <el-input v-model="form.remark" placeholder="请输入备注信息" rows="5" show-word-limit type="textarea" />-->
  92. <!-- </el-form-item>-->
  93. <!-- </el-col>-->
  94. </el-row>
  95. </el-form>
  96. <div slot="footer" class="dialog-footer">
  97. <el-button @click="close">取 消</el-button>
  98. <el-button :loading="loading" type="primary" @click="save">确 定</el-button>
  99. </div>
  100. <!-- 选择客户联系人弹窗 -->
  101. <select-contact
  102. ref="selectContact"
  103. :default-customer="customerInfo"
  104. :query-params="queryContact"
  105. @save="selectContact" />
  106. <select-distributor
  107. ref="selectDistributor"
  108. :query-params="queryContact"
  109. :title="distrTitle"
  110. @save="selectContact" />
  111. </el-dialog>
  112. </template>
  113. <script>
  114. import axios from 'axios'
  115. import to from 'await-to-js'
  116. import followApi from '@/api/customer/follow'
  117. import SelectContact from '@/components/select/SelectCustomerContact'
  118. import SelectDistributor from '@/components/select/SelectDistributorContact'
  119. import asyncUploadFile from '@/utils/uploadajax'
  120. export default {
  121. name: 'FollowAdd',
  122. components: {
  123. SelectContact,
  124. SelectDistributor,
  125. },
  126. data() {
  127. return {
  128. distrTitle: '',
  129. loading: false,
  130. form: {
  131. followType: '',
  132. followDate: '',
  133. followContentType: '',
  134. effect: '',
  135. followContent: '',
  136. issue: '',
  137. furtherPlan: '',
  138. targetId: '',
  139. targetName: '',
  140. targetType: '',
  141. custId: 0,
  142. custName: '',
  143. contactsId: '',
  144. contactsName: '',
  145. reminders: '',
  146. nextTime: '',
  147. remark: '',
  148. supportName: '',
  149. files: [],
  150. },
  151. rules: {
  152. followType: [{ required: true, trigger: 'blur', message: '请输入跟进方式' }],
  153. followDate: [{ required: true, trigger: 'blur', message: '请输入跟进时间' }],
  154. followContentType: [{ required: true, trigger: 'blur', message: '请输入跟进内容类型' }],
  155. followContent: [{ required: true, trigger: 'blur', message: '请输入本次跟进内容' }],
  156. effect: [{ required: true, trigger: 'blur', message: '请输入达成效果' }],
  157. issue: [{ required: true, trigger: 'blur', message: '请输入问题或困难' }],
  158. furtherPlan: [{ required: true, trigger: 'blur', message: '请输入下一步跟进计划和目标' }],
  159. targetId: [{ required: true, trigger: 'blur', message: '请选择跟进对象' }],
  160. targetName: [{ required: true, trigger: 'blur', message: '跟进对象不能为空' }],
  161. targetType: [{ required: true, trigger: 'blur', message: '跟进对象类型不能为空' }],
  162. custId: [{ required: true, trigger: 'blur', message: '请选择关联客户' }],
  163. custName: [{ required: true, trigger: 'blur', message: '客户名称不能为空' }],
  164. contactsId: [{ required: true, trigger: 'blur', message: '请选择关联联系人' }],
  165. contactsName: [{ required: true, trigger: 'blur', message: '联系人姓名不能为空' }],
  166. supportName: [{ required: true, trigger: 'blur', message: '总部支持人员不能为空' }],
  167. },
  168. title: '',
  169. dialogFormVisible: false,
  170. fileList: [],
  171. fileSettings: {
  172. // 文件配置信息
  173. fileSize: 52428800,
  174. fileTypes: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.txt',
  175. pictureSize: 52428800,
  176. pictureTypes: '.jpg,.jpeg,.gif,.png,.jfif,.txt',
  177. types: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.mp4,.txt',
  178. videoSize: 104857600,
  179. videoType: '.mp4',
  180. },
  181. queryContact: {},
  182. customerInfo: {},
  183. followTypeOptions: [],
  184. followContentTypeOptions: [],
  185. }
  186. },
  187. watch: {},
  188. created() {
  189. this.getOptions()
  190. },
  191. methods: {
  192. getOptions() {
  193. Promise.all([this.getDicts('plat_follow_type'), this.getDicts('plat_follow_content_type')]).then(
  194. ([followType, followContentType]) => {
  195. this.followTypeOptions = followType.data.values || []
  196. this.followContentTypeOptions = followContentType.data.values || []
  197. }
  198. )
  199. },
  200. handleSelectContact() {
  201. console.log(this.form.targetType)
  202. if (this.form.targetType == '50') {
  203. this.$refs.selectDistributor.open()
  204. } else {
  205. if (!this.queryContact.custId) {
  206. this.$message.warning('请先选择客户')
  207. return
  208. }
  209. this.$refs.selectContact.open()
  210. }
  211. },
  212. selectContact(val) {
  213. if (val && val.length > 0) {
  214. if (this.form.targetType == '50') {
  215. this.form.contactsName = val.map((item) => item.name).join()
  216. } else {
  217. this.form.contactsName = val.map((item) => item.cuctName).join()
  218. }
  219. this.form.contactsId = val[0].id
  220. }
  221. console.log(this.form)
  222. },
  223. showEdit(row, title = null) {
  224. this.title = '添加跟进记录'
  225. this.form = Object.assign(this.form, row)
  226. console.log(this.form)
  227. if (this.form.targetType == '10' || this.form.targetType == '20' || this.form.targetType == '60') {
  228. this.queryContact.custId = this.form.custId
  229. this.customerInfo = {
  230. custId: this.form.custId,
  231. custName: this.form.custName,
  232. }
  233. } else if (this.form.targetType == '50') {
  234. this.queryContact.distId = this.form.targetId
  235. }
  236. this.distrTitle = title
  237. this.dialogFormVisible = true
  238. },
  239. close() {
  240. this.$refs['form'].resetFields()
  241. this.form = this.$options.data().form
  242. this.fileList = []
  243. this.dialogFormVisible = false
  244. this.loading = false
  245. },
  246. save() {
  247. this.$refs['form'].validate(async (valid) => {
  248. if (valid) {
  249. this.loading = true
  250. const [err, res] = await to(followApi.addFollowUp(this.form))
  251. if (err) {
  252. this.$baseMessage(res.msg, 'error')
  253. } else {
  254. this.$baseMessage(res.msg, 'success')
  255. }
  256. this.loading = false
  257. this.$emit('fetch-data')
  258. this.close()
  259. } else {
  260. return false
  261. }
  262. })
  263. },
  264. // 上传图片
  265. beforeAvatarUpload(file) {
  266. let flag1 = file.size < this.fileSettings.fileSize
  267. if (!flag1) {
  268. this.$message.warning('文件过大,请重新选择!')
  269. return false
  270. }
  271. let flag2 = this.fileSettings.fileTypes.split(',').includes('.' + file.name.split('.').pop())
  272. if (!flag2) {
  273. this.$message.warning('文件类型不符合,请重新选择!')
  274. return false
  275. }
  276. return true
  277. },
  278. // 上传
  279. uploadrequest(option) {
  280. let _this = this
  281. let url = process.env.VUE_APP_UPLOAD_WEED
  282. axios
  283. .post(url)
  284. .then(function (res) {
  285. if (res.data && res.data.fid && res.data.fid !== '') {
  286. option.action = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`
  287. let file_name = option.file.name
  288. let index = file_name.lastIndexOf('.')
  289. let file_extend = ''
  290. if (index > 0) {
  291. // 截取名称中的扩展名
  292. file_extend = file_name.substr(index + 1)
  293. }
  294. let uploadform = {
  295. fileName: file_name, // 资料名称
  296. fileUrl: `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`, // 资料存储url
  297. size: option.file.size.toString(), // 资料大小
  298. fileType: file_extend, // 资料文件类型
  299. }
  300. asyncUploadFile(option).then(() => {
  301. _this.form.files.push(uploadform)
  302. })
  303. } else {
  304. _this.$message({
  305. type: 'warning',
  306. message: '未上传成功!请刷新界面重新上传!',
  307. })
  308. }
  309. })
  310. .catch(function () {
  311. _this.$message({
  312. type: 'warning',
  313. message: '未上传成功!请重新上传!',
  314. })
  315. })
  316. },
  317. },
  318. }
  319. </script>