detail.vue 18 KB

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