detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <div class="s-page">
  3. <el-page-header @back="goBack" :content="title"></el-page-header>
  4. <el-divider></el-divider>
  5. <el-card class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>基本信息</span>
  8. </div>
  9. <div class="mymain-container">
  10. <el-form ref="formData" :rules="rules" :model="formData" label-width="110px" size="small" label-position="left">
  11. <el-row :gutter="20" justify="start">
  12. <el-col :span="6">
  13. <el-form-item label="所属商户" :required="true" >
  14. <el-input type="text" :value="companyName" disabled></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="6" style="height: 51px;">
  18. <el-form-item label="活动名称" prop="promotionActivityId">
  19. <el-select v-model="formData.active" :disabled="formType!=0" value-key="id" @change="(e)=>{
  20. formData.promotionActivityId = e.id
  21. formData.activeDate = [e.startTime,e.endTime]
  22. this.getActiveDetail(e.id)
  23. }" placeholder="请选择" style="width: 100%;">
  24. <el-option
  25. v-for="item in activeList"
  26. :key="item.id"
  27. :label="item.name"
  28. :value="item">
  29. </el-option>
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12" style="margin-bottom: 1px;">
  34. <el-form-item label="活动时间" prop="" class="is-required">
  35. <el-date-picker
  36. v-model="formData.activeDate"
  37. disabled
  38. type="daterange"
  39. range-separator="至"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期">
  42. </el-date-picker>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="6">
  46. <el-form-item label="客户名称" prop="userName">
  47. <el-input type="text" :disabled="formType!=0" v-model="formData.userName" placeholder="请输入"></el-input>
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="6">
  51. <el-form-item label="联系人" prop="linkName">
  52. <el-input type="text" :disabled="formType!=0" v-model="formData.linkName" placeholder="请输入"></el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6">
  56. <el-form-item label="客户电话" prop="userMobile">
  57. <el-input type="number" :disabled="formType!=0" v-model="formData.userMobile" placeholder="请输入"></el-input>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="6">
  61. <el-form-item label="客户电话2" prop="userMobile2">
  62. <el-input type="text" :disabled="formType!=0" v-model="formData.userMobile2" placeholder="请输入电话 (固话加区号)"></el-input>
  63. </el-form-item>
  64. </el-col>
  65. <el-col :span="24">
  66. <el-form-item label="客户地址" prop="userAddress">
  67. <el-input type="text" v-model="formData.userAddress" :disabled="formType!=0" placeholder="详细地址"></el-input>
  68. </el-form-item>
  69. </el-col>
  70. <template v-if="formType!=0">
  71. <el-col :span="6">
  72. <el-form-item label="提交人" prop="createBy">
  73. <el-input type="text" v-model="formData.createBy" :disabled="true" placeholder="提交人"></el-input>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="6">
  77. <el-form-item label="提交时间" prop="createTime">
  78. <el-input type="text" v-model="formData.createTime" :disabled="true" placeholder="提交时间"></el-input>
  79. </el-form-item>
  80. </el-col>
  81. </template>
  82. </el-row>
  83. </el-form>
  84. </div>
  85. </el-card>
  86. <el-card class="box-card" v-if="activeItems.length > 0">
  87. <div slot="header" class="clearfix">
  88. <span>报名信息</span>
  89. </div>
  90. <div v-for="(item, index) in activeItems" :key="index">
  91. <div class="picker-container" v-if="item.type == 1 || item.type == 2">
  92. <div class="label"><span v-if="item.isRequire">*</span>{{item.question}}({{{1: '单选', 2: '多选'}[item.type]}})</div>
  93. <div class="img-list" v-if="item.answer && item.answer.length > 0 && item.answer[0].option_files && item.answer[0].option_files.length > 0 && item.answer[0].option_files[0].url">
  94. <div
  95. class="item1"
  96. :class="it.active ? 'active' : ''"
  97. v-for="(it, idx) in item.answer"
  98. :key="idx"
  99. @click="clickOption(index, idx)">
  100. <el-image class="image" :src="returnUrl(it)" mode="aspectFill"></el-image>
  101. <div class="text">{{it.option_value}}</div>
  102. </div>
  103. </div>
  104. <div class="text-list" v-else>
  105. <div
  106. class="item"
  107. :class="it.active ? 'active' : ''"
  108. v-for="(it, idx) in item.answer"
  109. :key="idx"
  110. @click="clickOption(index, idx)">
  111. {{it.option_value}}
  112. </div>
  113. </div>
  114. </div>
  115. <div class="input-container" v-else-if="item.type == 3">
  116. <div class="label"><span v-if="item.isRequire">*</span>{{item.question}}</div>
  117. <el-input type="text" v-model="item.inputValue" show-word-limit :maxlength="item.answer[0].option_limit" :disabled="formType!=0" :placeholder="`请输入${item.question}`"></el-input>
  118. </div>
  119. <div class="input-container" v-else>
  120. <div class="label"><span v-if="item.isRequire">*</span>{{item.question}}</div><br/>
  121. <ImageUpload :fileList="item.inputValue" :limit="1" :isEdit="formType==0" :fileType="['image','video']"/>
  122. </div>
  123. </div>
  124. </el-card>
  125. <el-card class="box-card" v-if="formType != 0">
  126. <div slot="header" class="clearfix">
  127. <span>跟进记录</span>
  128. </div>
  129. <div class="mymain-container">
  130. <el-form ref="formData" :model="formData" label-width="110px" size="small" label-position="left">
  131. <el-row :gutter="20" justify="start">
  132. <el-col :span="24">
  133. <el-form-item label="最新跟进结果" prop="status" class="is-required">
  134. <el-radio-group v-model="formData.status">
  135. <el-radio :disabled="status == 'END'" label="ING">继续跟进</el-radio>
  136. <el-radio :disabled="status == 'END'" label="END">无需跟进</el-radio>
  137. </el-radio-group>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="24">
  141. <el-form-item label="备注" prop="remark" :rules="[{ required: true, message: `请输入备注内容`, trigger: 'blur' }]">
  142. <el-input type="textarea" :rows="3" :disabled="status == 'END'" v-model="formData.remark" placeholder="请输入"></el-input>
  143. </el-form-item>
  144. </el-col>
  145. </el-row>
  146. </el-form>
  147. </div>
  148. <div class="table">
  149. <div>跟进记录</div><br/>
  150. <el-table :data="formData.records" element-loading-text="Loading" border fit highlight-current-row stripe>
  151. <el-table-column prop="status" label="跟进结果" align="center">
  152. <template slot-scope="scope">
  153. {{scope.row.status == 'ING'?'继续跟进':scope.row.status == 'END'?'无需跟进':''}}
  154. </template>
  155. </el-table-column>
  156. <el-table-column prop="remark" label="备注" align="center"></el-table-column>
  157. <el-table-column prop="createBy" align="center" label="跟进人" ></el-table-column>
  158. <el-table-column prop="createTime" align="center" label="跟进时间" ></el-table-column>
  159. </el-table>
  160. </div>
  161. </el-card>
  162. <div class="page-footer">
  163. <div class="footer">
  164. <el-button size="small" type="info" @click="goBack">返回</el-button>
  165. <el-button v-if="formType == 0 || status == 'ING'" size="small" type="primary" @click="submit()">提交</el-button>
  166. </div>
  167. </div>
  168. </div>
  169. </template>
  170. <script>
  171. import ImageUpload from '@/components/file-upload'
  172. import { getDetail, add, follow, getActiveList, getActiveDetail } from "@/api/activityOrder";
  173. export default {
  174. components: {ImageUpload},
  175. props: ['id','title','formType','activeId'],
  176. data() {
  177. return {
  178. dataList: [],
  179. activeList: [],
  180. activeItems: [],
  181. formData: {
  182. active: {},
  183. activeDate: [],
  184. promotionActivityId: '',
  185. userName: '',
  186. linkName: '',
  187. userMobile: '',
  188. userMobile2: '',
  189. userAddress: '',
  190. status: '',
  191. remark: ''
  192. },
  193. status: '',
  194. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  195. rules: {
  196. userMobile: [
  197. { required: true, message: `请输入客户电话`, trigger: 'blur' },
  198. { required: true, message: `请输入客户电话`, trigger: 'change' },
  199. { pattern:/^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  200. ],
  201. userName: [
  202. { required: true, message: '请输入客户名称', trigger: 'blur' }
  203. ],
  204. linkName: [
  205. { required: true, message: '请输入联系人', trigger: 'blur' }
  206. ],
  207. userAddress: [
  208. { required: true, message: '请输入客户地址', trigger: 'blur' }
  209. ],
  210. promotionActivityId: [
  211. { required: true, message: '请选择活动名称', trigger: 'change' }
  212. ]
  213. }
  214. };
  215. },
  216. computed: {
  217. returnUrl(){
  218. return function(it){
  219. return it.option_files.length > 0?it.option_files[0].url:''
  220. }
  221. }
  222. },
  223. created() {
  224. if(this.id){
  225. this.getDetail()
  226. }
  227. if(this.activeId){
  228. this.formData.active = {id: this.activeId}
  229. this.getActiveDetail(this.activeId)
  230. }
  231. this.getActiveList()
  232. },
  233. methods: {
  234. // 返回
  235. goBack() {
  236. this.$emit('back');
  237. },
  238. async getDetail(){
  239. const that = this
  240. getDetail({promotionActivityId: this.id}).then( async res => {
  241. Object.assign(this.formData, res.data, {
  242. active: {id: res.data.promotionQuestionnaireId}
  243. })
  244. this.status = res.data.status
  245. this.getActiveDetail(res.data.promotionQuestionnaireId,res.data.items)
  246. })
  247. },
  248. getActiveList(){
  249. getActiveList({pageNum: 1,pageSize: -1,status: 1}).then(res => {
  250. this.activeList = res.data.records
  251. })
  252. },
  253. getActiveDetail(id,items){
  254. getActiveDetail({id}).then(res => {
  255. this.formData.activeDate = [res.data.startTime,res.data.endTime]
  256. this.formData.promotionActivityId = res.data.promotionQuestionnaireId
  257. res.data.promotionQuestionnaireItems.forEach((item,index)=>{
  258. item.answer = JSON.parse(item.answer)
  259. if(items){
  260. item.answer.forEach(it1 => {
  261. items.forEach(it2=>{
  262. JSON.parse(it2.answer).forEach(t=>{
  263. if(item.id == it2.id && t.active && it1.option_value == t.option_value){
  264. console.log(t.option_value)
  265. it1.active = true;
  266. }
  267. if(it2.type == 3){
  268. item.inputValue = t.option_value
  269. }else if(it2 == 4 || it2 == 5){
  270. item.inputValue = [{url: t.option_value}]
  271. }
  272. })
  273. })
  274. // let data = JSON.parse(items[index].answer)
  275. // console.log(data[ind]?.option_value,it.option_value)
  276. // if(data[ind]?.active && data[ind]?.option_value == it.option_value){
  277. // it.active = true;
  278. // }else{
  279. // it.active = false;
  280. // }
  281. // if(items[index].type == 3){
  282. // item.inputValue = data[ind]?.option_value
  283. // }else if(item.type == 4 || item.type == 5){
  284. // item.inputValue = [{url: data[ind]?.option_value}]
  285. // }
  286. })
  287. }else{
  288. if(item.type == 4 || item.type == 5){
  289. item.inputValue = []
  290. }else{
  291. item.inputValue = '';
  292. }
  293. item.answer.forEach(it => {
  294. it.active = false;
  295. })
  296. }
  297. })
  298. this.activeItems = res.data.promotionQuestionnaireItems
  299. console.log(this.activeItems,111)
  300. })
  301. },
  302. clickOption(index, idx) {
  303. if(this.id){return false}
  304. // 单选题
  305. if(this.activeItems[index].type == 1) {
  306. this.activeItems[index].answer.forEach((item, ind_) => {
  307. this.activeItems[index].answer.splice(ind_, 1, {...item, active: ind_ == idx ? (this.activeItems[index].isRequire ? true : !item.active) : false})
  308. })
  309. }
  310. // 多选题
  311. else {
  312. this.activeItems[index].answer.splice(idx, 1, {...this.activeItems[index].answer[idx], active: !this.activeItems[index].answer[idx].active})
  313. }
  314. },
  315. submit(){
  316. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  317. if (valid) {
  318. if(this.formType == 0){
  319. for(let i = 0; i < this.activeItems.length; i++) {
  320. if(this.activeItems[i].isRequire) {
  321. // 单选题多选题
  322. if((this.activeItems[i].type == 1 || this.activeItems[i].type == 2) && this.activeItems[i].answer.every(o => !o.active)) {
  323. return this.$message.warning(`请选择${this.activeItems[i].question}`)
  324. }
  325. // 填写题
  326. if(this.activeItems[i].type == 3 && !this.activeItems[i].inputValue) {
  327. return this.$message.warning(`请输入${this.activeItems[i].question}`)
  328. }
  329. // 图片视频
  330. if((this.activeItems[i].type == 4 || this.activeItems[i].type == 5) && this.activeItems[i].inputValue.length==0) {
  331. return this.$message.warning(`请上传${this.activeItems[i].question}`)
  332. }
  333. }
  334. }
  335. // 生成题目提交信息
  336. let items = [];
  337. let activeItems = JSON.parse(JSON.stringify(this.activeItems));
  338. for(let index = 0; index < activeItems.length; index++) {
  339. // 单选题多选题
  340. if ((activeItems[index].type == 1 || activeItems[index].type == 2)) {
  341. activeItems[index].answer = activeItems[index].answer.filter(o => o.active);
  342. activeItems[index].answer = JSON.stringify(activeItems[index].answer);
  343. items.push(activeItems[index]);
  344. }
  345. // 填写题
  346. if (activeItems[index].type == 3) {
  347. activeItems[index].answer[0].option_value = activeItems[index].inputValue;
  348. activeItems[index].answer = JSON.stringify(activeItems[index].answer);
  349. items.push(activeItems[index]);
  350. }
  351. // 图片视频
  352. if (activeItems[index].type == 4 || activeItems[index].type == 5) {
  353. activeItems[index].answer[0].option_value = activeItems[index].inputValue.length>0?activeItems[index].inputValue[0].url:'';
  354. activeItems[index].answer = JSON.stringify(activeItems[index].answer);
  355. items.push(activeItems[index]);
  356. }
  357. }
  358. add({
  359. promotionQuestionnaireId: this.formData.promotionActivityId,
  360. userName: this.formData.userName,
  361. linkName: this.formData.linkName,
  362. userMobile: this.formData.userMobile,
  363. userMobile2: this.formData.userMobile2,
  364. userAddress: this.formData.userAddress,
  365. items
  366. }).then(res => {
  367. if(res.code == 200){
  368. this.$message.success('提交成功!')
  369. this.goBack()
  370. }
  371. })
  372. }else{
  373. follow({
  374. ids: [this.id],
  375. status: this.formData.status,
  376. remark: this.formData.remark,
  377. }).then(res => {
  378. if(res.code == 200){
  379. this.dataList = []
  380. this.$message.success('提交成功!')
  381. this.goBack()
  382. }
  383. })
  384. }
  385. }
  386. })
  387. }
  388. }
  389. };
  390. </script>
  391. <style scoped="scoped" lang="scss">
  392. .s-page {
  393. padding: 20px;
  394. background-color: #ffffff;
  395. }
  396. .page-footer {
  397. height: 70px;
  398. }
  399. .input-container {
  400. margin-top: 20px;
  401. .label {
  402. font-size: 14px;
  403. font-weight: bold;
  404. span {
  405. color: red;
  406. }
  407. }
  408. }
  409. .picker-container {
  410. margin-top: 20px;
  411. .label {
  412. font-size: 14px;
  413. font-weight: bold;
  414. span {
  415. color: red;
  416. }
  417. }
  418. .text-list {
  419. display: flex;
  420. flex-wrap: wrap;
  421. .item {
  422. margin-top: 20px;
  423. margin-right: 20px;
  424. height: 40px;
  425. border-radius: 30px;
  426. background: #f5f5f5;
  427. font-size: 14px;
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. box-sizing: border-box;
  432. cursor: pointer;
  433. padding: 0 40px;
  434. &.active {
  435. border: 1px solid #f6390d;
  436. color: #f6390d;
  437. background: #ffffff;
  438. }
  439. }
  440. }
  441. .img-list {
  442. display: flex;
  443. flex-wrap: wrap;
  444. .item,.item1 {
  445. margin-top: 10px;
  446. margin-right: 10px;
  447. border-radius: 20px;
  448. height: 40px;
  449. display: flex;
  450. flex-direction: column;
  451. align-items: center;
  452. justify-content: center;
  453. box-sizing: border-box;
  454. padding: 0 40px;
  455. background-color: #f3f3f3;
  456. cursor: pointer;
  457. .image {
  458. width: 100%;
  459. height: 60px;
  460. }
  461. .text {
  462. font-size: 14px;
  463. }
  464. &.active {
  465. border: 1px solid #f6390d;
  466. background-color: #ffffff;
  467. .text {
  468. color: #f6390d;
  469. }
  470. }
  471. }
  472. .item1{
  473. height: 130px;
  474. border-radius: 6px;
  475. padding: 6px;
  476. .image {
  477. width: 120px;
  478. height: 100px;
  479. }
  480. }
  481. }
  482. }
  483. .footer {
  484. position: fixed;
  485. bottom: 0;
  486. left: 0;
  487. z-index: 1;
  488. width: 100%;
  489. background: #fff;
  490. padding: 15px 40px;
  491. box-sizing: border-box;
  492. transition: all 0.28s;
  493. text-align: right;
  494. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  495. &.hideSidebar {
  496. margin-left: 54px;
  497. width: calc(100vw - 54px);
  498. }
  499. &.openSidebar {
  500. margin-left: 210px;
  501. width: calc(100vw - 210px);
  502. }
  503. .tips {
  504. font-size: 12px;
  505. color: red;
  506. margin-top: 10px;
  507. }
  508. }
  509. </style>