FollowAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 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 followApi from '@/api/customer/follow'
  115. import SelectContact from '@/components/select/SelectCustomerContact'
  116. import SelectDistributor from '@/components/select/SelectDistributorContact'
  117. import asyncUploadFile from '@/utils/uploadajax'
  118. import axios from 'axios'
  119. export default {
  120. name: 'FollowAdd',
  121. components: {
  122. SelectContact,
  123. SelectDistributor,
  124. },
  125. data() {
  126. return {
  127. distrTitle: '',
  128. form: {
  129. followType: '',
  130. followDate: '',
  131. followContentType: '',
  132. effect: '',
  133. followContent: '',
  134. issue: '',
  135. furtherPlan: '',
  136. targetId: '',
  137. targetName: '',
  138. targetType: '',
  139. custId: 0,
  140. custName: '',
  141. contactsId: '',
  142. contactsName: '',
  143. reminders: '',
  144. nextTime: '',
  145. remark: '',
  146. supportName: '',
  147. files: [],
  148. },
  149. rules: {
  150. followType: [{ required: true, trigger: 'blur', message: '请输入跟进方式' }],
  151. followDate: [{ required: true, trigger: 'blur', message: '请输入跟进时间' }],
  152. followContentType: [{ required: true, trigger: 'blur', message: '请输入跟进内容类型' }],
  153. followContent: [{ required: true, trigger: 'blur', message: '请输入本次跟进内容' }],
  154. effect: [{ required: true, trigger: 'blur', message: '请输入达成效果' }],
  155. issue: [{ required: true, trigger: 'blur', message: '请输入问题或困难' }],
  156. furtherPlan: [{ required: true, trigger: 'blur', message: '请输入下一步跟进计划和目标' }],
  157. targetId: [{ required: true, trigger: 'blur', message: '请选择跟进对象' }],
  158. targetName: [{ required: true, trigger: 'blur', message: '跟进对象不能为空' }],
  159. targetType: [{ required: true, trigger: 'blur', message: '跟进对象类型不能为空' }],
  160. custId: [{ required: true, trigger: 'blur', message: '请选择关联客户' }],
  161. custName: [{ required: true, trigger: 'blur', message: '客户名称不能为空' }],
  162. contactsId: [{ required: true, trigger: 'blur', message: '请选择关联联系人' }],
  163. contactsName: [{ required: true, trigger: 'blur', message: '联系人姓名不能为空' }],
  164. supportName: [{ required: true, trigger: 'blur', message: '总部支持人员不能为空' }],
  165. },
  166. title: '',
  167. dialogFormVisible: false,
  168. fileList: [],
  169. fileSettings: {
  170. // 文件配置信息
  171. fileSize: 52428800,
  172. fileTypes: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.txt',
  173. pictureSize: 52428800,
  174. pictureTypes: '.jpg,.jpeg,.gif,.png,.jfif,.txt',
  175. types: '.doc,.docx,.zip,.xls,.xlsx,.rar,.jpg,.jpeg,.gif,.png,.jfif,.mp4,.txt',
  176. videoSize: 104857600,
  177. videoType: '.mp4',
  178. },
  179. queryContact: {},
  180. customerInfo: {},
  181. followTypeOptions: [],
  182. followContentTypeOptions: [],
  183. }
  184. },
  185. watch: {},
  186. created() {
  187. this.getOptions()
  188. },
  189. methods: {
  190. getOptions() {
  191. Promise.all([this.getDicts('plat_follow_type'), this.getDicts('plat_follow_content_type')]).then(
  192. ([followType, followContentType]) => {
  193. this.followTypeOptions = followType.data.values || []
  194. this.followContentTypeOptions = followContentType.data.values || []
  195. }
  196. )
  197. },
  198. handleSelectContact() {
  199. console.log(this.form.targetType)
  200. if (this.form.targetType == '50') {
  201. this.$refs.selectDistributor.open()
  202. } else {
  203. if (!this.queryContact.custId) {
  204. this.$message.warning('请先选择客户')
  205. return
  206. }
  207. this.$refs.selectContact.open()
  208. }
  209. },
  210. selectContact(val) {
  211. if (val && val.length > 0) {
  212. if (this.form.targetType == '50') {
  213. this.form.contactsName = val.map((item) => item.name).join()
  214. } else {
  215. this.form.contactsName = val.map((item) => item.cuctName).join()
  216. }
  217. this.form.contactsId = val[0].id
  218. }
  219. console.log(this.form)
  220. },
  221. showEdit(row, title = null) {
  222. this.title = '添加跟进记录'
  223. this.form = Object.assign(this.form, row)
  224. console.log(this.form)
  225. if (this.form.targetType == '10' || this.form.targetType == '20' || this.form.targetType == '60') {
  226. this.queryContact.custId = this.form.custId
  227. this.customerInfo = {
  228. custId: this.form.custId,
  229. custName: this.form.custName,
  230. }
  231. } else if (this.form.targetType == '50') {
  232. this.queryContact.distId = this.form.targetId
  233. }
  234. this.distrTitle = title
  235. this.dialogFormVisible = true
  236. },
  237. close() {
  238. this.$refs['form'].resetFields()
  239. this.form = this.$options.data().form
  240. this.fileList = []
  241. this.dialogFormVisible = false
  242. },
  243. save() {
  244. this.$refs['form'].validate(async (valid) => {
  245. if (valid) {
  246. const { msg } = await followApi.addFollowUp(this.form)
  247. this.$baseMessage(msg, 'success')
  248. this.$emit('fetch-data')
  249. this.close()
  250. } else {
  251. return false
  252. }
  253. })
  254. },
  255. // 上传图片
  256. beforeAvatarUpload(file) {
  257. let flag1 = file.size < this.fileSettings.fileSize
  258. if (!flag1) {
  259. this.$message.warning('文件过大,请重新选择!')
  260. return false
  261. }
  262. let flag2 = this.fileSettings.fileTypes.split(',').includes('.' + file.name.split('.').pop())
  263. if (!flag2) {
  264. this.$message.warning('文件类型不符合,请重新选择!')
  265. return false
  266. }
  267. return true
  268. },
  269. // 上传
  270. uploadrequest(option) {
  271. let _this = this
  272. let url = process.env.VUE_APP_UPLOAD_WEED
  273. axios
  274. .post(url)
  275. .then(function (res) {
  276. if (res.data && res.data.fid && res.data.fid !== '') {
  277. option.action = `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`
  278. let file_name = option.file.name
  279. let index = file_name.lastIndexOf('.')
  280. let file_extend = ''
  281. if (index > 0) {
  282. // 截取名称中的扩展名
  283. file_extend = file_name.substr(index + 1)
  284. }
  285. let uploadform = {
  286. fileName: file_name, // 资料名称
  287. fileUrl: `${process.env.VUE_APP_PROTOCOL}${res.data.publicUrl}/${res.data.fid}`, // 资料存储url
  288. size: option.file.size.toString(), // 资料大小
  289. fileType: file_extend, // 资料文件类型
  290. }
  291. asyncUploadFile(option).then(() => {
  292. _this.form.files.push(uploadform)
  293. })
  294. } else {
  295. _this.$message({
  296. type: 'warning',
  297. message: '未上传成功!请刷新界面重新上传!',
  298. })
  299. }
  300. })
  301. .catch(function () {
  302. _this.$message({
  303. type: 'warning',
  304. message: '未上传成功!请重新上传!',
  305. })
  306. })
  307. },
  308. },
  309. }
  310. </script>