leave-info-dialog.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. // 模板字符串
  2. var temp = `
  3. <div>
  4. <div class="user-data-dialog" id="collectUserInfoDialog" v-if="showForm">
  5. <div class="mask"></div>
  6. <div class="dialog-container">
  7. <div class="dialog-header"></div>
  8. <div class="dialog-content">
  9. <el-form class="user-form" :model="form" :rules="rules" ref="ruleForm">
  10. <!-- 基本信息 -->
  11. <div class="basic clearfix">
  12. <div class="form-title">基本信息</div>
  13. <div class="form-main clearfix">
  14. <div class="short-control fl" v-if="moduleShow.name">
  15. <el-form-item label="姓名 :" prop="name">
  16. <el-input v-model.trim="form.name" class="item-input" placeholder="请输入姓名" @focus="nameFocus" required>
  17. </el-input>
  18. </el-form-item>
  19. </div>
  20. <div class="short-control fr" v-if="moduleShow.mail">
  21. <el-form-item label="邮箱 :" prop="mail">
  22. <el-input v-model.trim="form.mail" class="item-input" placeholder="请输入邮箱" @focus="mailFocus"></el-input>
  23. </el-form-item>
  24. </div>
  25. <div class="short-control fl" v-if="moduleShow.phone">
  26. <el-form-item label="手机号 :" prop="phone">
  27. <el-input v-model.trim="form.phone" maxlength="11" @input="inputPhone" class="item-input" placeholder="请输入准确的手机号" @focus="phoneFocus"></el-input>
  28. </el-form-item>
  29. </div>
  30. <div class="short-control fr" v-if="showCode">
  31. <el-form-item label="验证码 :" prop="code">
  32. <el-input v-model.trim="form.code" maxlength="6" @change="checkCode" class="item-input code-input" placeholder="请输入手机验证码" @focus="codeFocus">
  33. <el-button slot="append" :disabled="sendCodeBtn" @click="sendCode">@@codeText@@</el-button>
  34. </el-input>
  35. </el-form-item>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="company clearfix">
  40. <div class="form-title">公司信息</div>
  41. <div class="form-main">
  42. <div class="long-control" style="position: relative;" v-if="moduleShow.companyName">
  43. <el-form-item label="公司名称 :" prop="companyName">
  44. <el-input
  45. v-model.trim="form.companyName"
  46. data-long-input
  47. class="item-input company-name"
  48. @focus="companyFocus"
  49. @input="searchCompany"
  50. placeholder="请输入准确的公司名称">
  51. </el-input>
  52. </el-form-item>
  53. <div class="company-result" v-if="showSearchResult">
  54. <div class="company-list" v-for="item in companyList" :key="item" @click="selectCompany(item)" v-html="item"></div>
  55. </div>
  56. </div>
  57. <div class="long-control" v-if="moduleShow.companyType">
  58. <el-form-item label="公司类型 :" class="company-type" prop="companyType">
  59. <el-checkbox-group v-model="form.companyType">
  60. <el-checkbox label="投标企业"></el-checkbox>
  61. <el-checkbox label="招标采购单位"></el-checkbox>
  62. <el-checkbox label="厂商"></el-checkbox>
  63. <el-checkbox label="招标代理机构"></el-checkbox>
  64. <el-checkbox label="经销商"></el-checkbox>
  65. <el-checkbox label="服务提供商"></el-checkbox>
  66. <el-checkbox label="其他"></el-checkbox>
  67. </el-checkbox-group>
  68. </el-form-item>
  69. </div>
  70. <div class="short-control fl" v-if="moduleShow.job">
  71. <el-form-item label="职位 :" prop="job">
  72. <el-select v-model="form.job" placeholder="请选择职位" class="item-input" clearable>
  73. <el-option v-for="item in jobData" :key="item.value" :label="item.label" :value="item.value">
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. </div>
  78. <div class="short-control fr" v-if="showBranch">
  79. <el-form-item label-width="0" label="" prop="branch" class="no-label">
  80. <el-select v-model="form.branch" placeholder="请选择部门" class="item-input" clearable>
  81. <el-option v-for="item in branchData" :key="item.value" :label="item.label" :value="item.value">
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="warm-prompt">
  89. <span class="icon-warning"></span>
  90. <span class="warm-text">温馨提示:请提供准确的信息,我们将为您推荐更准确、更个性化的商机和服务</span>
  91. </div>
  92. <div class="dialog-footer">
  93. <el-button class="cancel-btn" @click="cancelForm">暂不提供</el-button>
  94. <el-button class="submit-btn" @click="submitForm('ruleForm')">提交</el-button>
  95. </div>
  96. </el-form>
  97. </div>
  98. </div>
  99. </div>
  100. <div id="success-dialog" style="display: none;" v-show="showSuccess">
  101. <div class="mask"></div>
  102. <div class="success-dialog-container">
  103. <div class="success-title">提交成功</div>
  104. <div class="success-content" v-if="defaultSource">我们的客户经理会在24小时内尽快与您联系。</div>
  105. <div class="success-content" v-else>我们稍后将以邮件的形式发送数据样例。</div>
  106. <div class="success-footer">
  107. <button type="button" class="custom-btn go-know" @click="showSuccess = false">我知道了</button>
  108. </div>
  109. <div class="dialog-adv" v-if="!defaultSource" @click="dataExport">
  110. <img src="/common-module/pc-dialog/image/data-export.png" />
  111. </div>
  112. </div>
  113. </div>
  114. <div id="export-dialog" v-show="showExport">
  115. <div class="mask"></div>
  116. <div class="export-dialog-container">
  117. <div class="export-title">
  118. <span class="export-close" @click="showExport = false"></span>
  119. </div>
  120. <div class="export-content">您可以通过剑鱼标讯提供的全国招投标数据自助导出功能,指定关键词、发布时间、地区或行业等筛选条件,以Excel表格的形式打包下载,精准获取所需数据。</div>
  121. <div class="export-footer">
  122. <button type="button" class="custom-btn go-know" @click="dataExport">数据自助导出</button>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. `
  128. var jobJson = [
  129. '总裁',
  130. '总经理',
  131. '总监',
  132. '经理',
  133. '主管',
  134. '职员'
  135. ]
  136. var branchJson = [
  137. '市场',
  138. '产品',
  139. '销售',
  140. '渠道',
  141. '其他'
  142. ]
  143. var jobData = jobJson.map(function (item) {
  144. return {
  145. value: item,
  146. label: item
  147. }
  148. })
  149. // 防抖
  150. function debounce(fn, delay) {
  151. var timer
  152. return function () {
  153. var context = this
  154. var args = arguments
  155. clearTimeout(timer)
  156. timer = setTimeout(function () {
  157. fn.apply(context, args)
  158. }, delay)
  159. }
  160. }
  161. // 部门数据处理
  162. var branchData = branchJson.map(function(item) {
  163. return {
  164. value: item,
  165. label: item
  166. }
  167. })
  168. var vm = new Vue({
  169. el: '#vue-collect-user-info',
  170. delimiters: ['@@', '@@'],
  171. props: ['type'],
  172. template: temp,
  173. data: function () {
  174. var validName = function(rule,value,callback) {
  175. if(value === '') {
  176. return callback(new Error('姓名为必填项'));
  177. } else {
  178. if (value.length < 2) {
  179. return callback(new Error('姓名填写不正确'));
  180. }
  181. callback();
  182. }
  183. }
  184. var validPhone = function(rule,value,callback) {
  185. var status = /^1[3-9]\d{9}$/.test(value)
  186. if(value === '') {
  187. return callback(new Error('手机号为必填项'));
  188. } else if (!status) {
  189. return callback(new Error('手机号填写不正确'));
  190. } else {
  191. callback();
  192. }
  193. }
  194. var validCode = function(rule,value,callback) {
  195. var status = /\d{6}/.test(value)
  196. if(value === '') {
  197. return callback(new Error('短信验证码为必填项'));
  198. } else if (!status) {
  199. return callback(new Error('验证码格式不正确'));
  200. } else {
  201. setTimeout(function() {
  202. if (!vm.codeStatus) {
  203. return callback(new Error('短信验证码不正确'));
  204. } else {
  205. callback();
  206. }
  207. }, 500)
  208. }
  209. }
  210. var validEmail = function(rule,value,callback) {
  211. var status = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value)
  212. if (value === '') {
  213. return callback(new Error('邮箱为必填项'));
  214. } else {
  215. if (!status) {
  216. return callback(new Error('邮箱填写不正确'));
  217. } else {
  218. callback();
  219. }
  220. }
  221. }
  222. var validCompany = function(rule,value,callback) {
  223. if (value === '') {
  224. return callback(new Error('公司名称为必填项'));
  225. } else {
  226. if (value.length < 2) {
  227. return callback(new Error('公司名称至少输入2个字'));
  228. } else {
  229. callback();
  230. }
  231. }
  232. }
  233. var validComType = function(rule,value,callback) {
  234. if (value.length === 0) {
  235. return callback(new Error('公司类型为必填项'));
  236. } else {
  237. callback();
  238. }
  239. }
  240. var validJob = function(rule,value,callback) {
  241. if(value === '') {
  242. return callback(new Error('职位为必填项'));
  243. return callback();
  244. } else {
  245. if (value === '其他' && vm.form.otherJob === '') {
  246. return callback();
  247. } else {
  248. callback();
  249. }
  250. }
  251. }
  252. var validBranch = function(rule,value,callback) {
  253. if(value === '') {
  254. return callback(new Error('请选择部门'));
  255. } else {
  256. callback();
  257. }
  258. }
  259. return {
  260. dialogTitle: '为给您匹配精准的推荐信息,请完善个人信息',
  261. jobData: jobData, // 职位数据
  262. branchData: branchData,
  263. form: {
  264. oldPhone: '', // 带出来的手机号,用于判断是否需要短信验证码
  265. name: '', // 姓名
  266. phone: '', // 手机号
  267. mail: '', // 邮箱
  268. code: '', // 短信验证码
  269. companyName: '', // 公司名称
  270. companyType: [], // 公司类型
  271. job: '', // 职位值
  272. otherJob: '', //自定义职位
  273. branch: ''
  274. },
  275. codeText: '获取验证码',
  276. sendCodeBtn: false,
  277. countdown: 0,
  278. codeStatus: true,
  279. rules: {
  280. name: [
  281. {
  282. required: true,
  283. validator: validName,
  284. trigger: 'blur'
  285. }
  286. ],
  287. phone: [
  288. {
  289. required: true,
  290. validator: validPhone,
  291. trigger: 'blur'
  292. }
  293. ],
  294. mail: [
  295. {
  296. required: true,
  297. validator: validEmail,
  298. trigger: 'blur'
  299. }
  300. ],
  301. code: [
  302. {
  303. required: true,
  304. validator: validCode,
  305. message: '',
  306. trigger: 'blur'
  307. }
  308. ],
  309. companyName: [
  310. {
  311. required: true,
  312. validator: validCompany,
  313. trigger: 'blur'
  314. }
  315. ],
  316. companyType: [
  317. {
  318. required: true,
  319. validator: validComType,
  320. trigger: 'blur'
  321. }
  322. ],
  323. job: [
  324. {
  325. required: true,
  326. validator: validJob,
  327. trigger: 'blur'
  328. }
  329. ],
  330. branch: [
  331. {
  332. required: true,
  333. trigger: 'blur',
  334. validator: validBranch,
  335. message: ''
  336. }
  337. ],
  338. },
  339. showSearchResult: false,
  340. companyList: [],
  341. showForm: false, // 显示表单填写弹框
  342. showSuccess: false, // 显示提交成功弹框
  343. showExport: false,
  344. isForce: false, // 是否强制
  345. source: '', // 来源模块
  346. interest: '', // 感兴趣内容
  347. moduleShow: {
  348. name: true,
  349. phone: true,
  350. mail: true,
  351. code: false,
  352. companyName: true,
  353. companyType: true,
  354. job: true,
  355. branch: false
  356. }
  357. }
  358. },
  359. computed: {
  360. showOtherJob: function() {
  361. return this.form.job == '其他'
  362. },
  363. showCode: function () {
  364. return (this.form.phone !== this.form.oldPhone && this.form.phone.length === 11) || !this.form.oldPhone
  365. },
  366. defaultSource: function() {
  367. // 默认提交成功不显示广告图和邮箱文案 如果是结构化数据则显示
  368. var noEmailSource = ['structedData', 'pc_data_custom_export']
  369. return noEmailSource.indexOf(this.source) === -1
  370. },
  371. showBranch: function () {
  372. // 切换到总裁或总经理之后 把之前选择的部门清空
  373. if (this.form.job.indexOf('总裁') > -1 || this.form.job.indexOf('总经理') > -1) {
  374. this.form.branch = ''
  375. }
  376. var zc = this.form.job.indexOf('总裁') > -1
  377. var zjl = this.form.job.indexOf('总经理') > -1
  378. return !(zc || zjl) && this.form.job
  379. }
  380. },
  381. mounted() {
  382. var that = this;
  383. $(document).on('click', function (e) {
  384. let dom = $('.company-name')[0];
  385. if (dom) {
  386. // 如果点击的区域不在自定义dom范围
  387. if (!dom.contains((e.target))) {
  388. that.showSearchResult = false
  389. }
  390. }
  391. })
  392. $(window).on('resize', this.changeTop)
  393. },
  394. beforeDestroy() {
  395. $(document).off('click')
  396. },
  397. methods: {
  398. getModules: function () {
  399. var source = this.source
  400. switch (source) {
  401. case 'pc_supermarket_Noresults_customization':
  402. case 'pc_market_ApplicationScenario':
  403. case 'pc_supermarket_details_customization':
  404. case 'pc_supermarket_details_buy': {
  405. this.hideModule(['mail'])
  406. break;
  407. }
  408. default:
  409. this.hideModule()
  410. break;
  411. }
  412. },
  413. hideModule: function (keys) {
  414. if (!keys) return
  415. var hideType = keys
  416. for (var k in this.moduleShow) {
  417. if (hideType.indexOf(k) !== -1) {
  418. this.moduleShow[k] = false
  419. }
  420. }
  421. },
  422. changeTop: function () {
  423. this.$nextTick(function () {
  424. var dialogDom = $('#collectUserInfoDialog .dialog-container')
  425. var diffHeight = window.innerHeight - dialogDom.height() - 240
  426. if (diffHeight < 0) {
  427. dialogDom.css('margin-top', diffHeight.toString() + 'px')
  428. }
  429. })
  430. },
  431. nameFocus:function(){
  432. this.$refs['ruleForm'].clearValidate(['name']);
  433. },
  434. phoneFocus:function(){
  435. this.$refs['ruleForm'].clearValidate(['phone']);
  436. },
  437. mailFocus:function(){
  438. this.$refs['ruleForm'].clearValidate(['mail']);
  439. },
  440. codeFocus: function() {
  441. this.$refs['ruleForm'].clearValidate(['code']);
  442. },
  443. // 公司名称获取焦点时
  444. companyFocus: function() {
  445. this.$refs['ruleForm'].clearValidate(['companyName']);
  446. this.getResult(this.form.companyName)
  447. },
  448. otherFocus:function() {
  449. this.$refs['ruleForm'].clearValidate(['job','otherJob']);
  450. },
  451. // 发送验证码
  452. sendCode: function() {
  453. var status = /^1[3-9]\d{9}$/.test(this.form.phone)
  454. var _this = this
  455. if (!status) return
  456. $.ajax({
  457. type:'POST',
  458. url:'/salesLeads/sendMsg',
  459. data: {
  460. phoneNum: _this.form.phone
  461. },
  462. success:function (res) {
  463. if (res.data && res.data.success) {
  464. _this.sendCodeBtn = true
  465. _this.countdown = 60
  466. _this.codeText = '重新获取' + _this.countdown + 's'
  467. var timeInt = setInterval(function() {
  468. _this.countdown--
  469. _this.codeText = '重新获取' + _this.countdown + 's'
  470. if (_this.countdown <= 0) {
  471. _this.sendCodeBtn = false
  472. _this.codeText = '获取验证码'
  473. window.clearInterval(timeInt)
  474. }
  475. }, 1000)
  476. } else {
  477. _this.$message.error('短信验证码发送失败');
  478. }
  479. }
  480. })
  481. },
  482. // 校验验证码
  483. checkCode: function(val) {
  484. var _this = this
  485. if (val.length !== 6) return
  486. $.ajax({
  487. type:'POST',
  488. url:'/salesLeads/checkCode',
  489. data: {
  490. code: _this.form.code,
  491. phoneNum: _this.form.phone
  492. },
  493. success:function (res) {
  494. if (res.data && res.data.flag) {
  495. _this.$message.success('验证成功')
  496. _this.codeStatus = true
  497. } else {
  498. _this.codeStatus = false
  499. }
  500. }
  501. })
  502. },
  503. // 日志统计
  504. logAjax: function(source) {
  505. $.ajax({
  506. type:'POST',
  507. url:'/front/portraitClassify?source=' + source,
  508. success:function (res) {
  509. console.log(res)
  510. }
  511. })
  512. },
  513. // 是否留资
  514. isNeedSubmit: function(source, callback, interest) {
  515. if (!loginflag) {
  516. openLoginDig()
  517. return
  518. }
  519. this.source = source
  520. this.interest = interest
  521. this.logAjax(source)
  522. var _this = this
  523. $.ajax({
  524. type:'GET',
  525. url:'/salesLeads/retainedCapital',
  526. data: {
  527. source: source
  528. },
  529. success:function (res) {
  530. // 判断当前信息否在其他页面留资 如果全部留资 直接弹窗提交成功
  531. var checkKeys = ['name', 'phone', 'company', 'mail', 'branch', 'position', 'companyType']
  532. var result = checkRequiredKeys(checkKeys, res.info)
  533. res.info.interest = interest
  534. if (result) {
  535. callback && callback()
  536. _this.formAjax(_this.source, res.info)
  537. } else if (res.data) {
  538. _this.isForce = res.data.fource
  539. if (res.data.retainedCapital) {
  540. _this.showForm = true
  541. // 当前头部背景图
  542. _this.isSelfHeader()
  543. _this.changeTop()
  544. if (res.info) {
  545. echoRequiredValues(_this.form, res.info, ['name', 'phone', 'mail', 'branch'])
  546. // 原有赋值回显逻辑
  547. _this.form.oldPhone = res.info.phone ? res.info.phone : ''
  548. _this.form.companyName = res.info.company ? res.info.company : ''
  549. _this.form.companyType = res.info.companyType ? res.info.companyType.split(',') : []
  550. if (res.info.position) {
  551. if (jobJson.indexOf(res.info.position) == -1) {
  552. // _this.form.job = '其他'
  553. // _this.form.otherJob = res.data.position.replace('其他/', '')
  554. _this.form.job = ''
  555. _this.form.otherJob = ''
  556. } else {
  557. _this.form.job = res.info.position
  558. }
  559. } else {
  560. _this.form.job = ''
  561. }
  562. }
  563. } else {
  564. callback && callback()
  565. }
  566. }
  567. }
  568. })
  569. },
  570. // 自定义弹窗头部
  571. isSelfHeader: function(){
  572. var imgUrl = '/common-module/pc-dialog/image/structed-title.png'
  573. var custom_export = this.source.indexOf('custom_export') > -1
  574. var custom_data = this.source.indexOf('custom_data') > -1
  575. var api_interface = this.source.indexOf('api_interface') > -1
  576. // 数据超市source
  577. var marketNoResult = this.source.indexOf('pc_supermarket_Noresults_customization') > -1 // 数据超市列表无数据-申请定制
  578. var marketApplicationScenario = this.source.indexOf('pc_market_ApplicationScenario') > -1 // 数据市场落地页-大数据服务应用场景-立即咨询
  579. var marketBuy = this.source.indexOf('pc_supermarket_details_buy') > -1 // 数据超市详情页-申请购买
  580. var marketDetailCustom = this.source.indexOf('pc_supermarket_details_customization') > -1 // 数据超市详情页-申请定制
  581. if (custom_export || custom_data || marketNoResult || marketDetailCustom) {
  582. imgUrl = '/common-module/pc-dialog/image/leave-title-custom.png'
  583. } else if (api_interface) {
  584. imgUrl = '/common-module/pc-dialog/image/leave-title-api.png'
  585. } else if (marketApplicationScenario) {
  586. imgUrl = '/common-module/pc-dialog/image/data-supermarket-contact.png'
  587. } else if (marketBuy) {
  588. imgUrl = '/common-module/pc-dialog/image/data-supermarket-buy.png'
  589. }
  590. this.getModules()
  591. this.$nextTick(function(){
  592. $('#collectUserInfoDialog .dialog-header').css('background-image', 'url(' + imgUrl + ')')
  593. })
  594. },
  595. // 表单提交事件
  596. submitForm: function(formName) {
  597. var _this = this
  598. this.$refs[formName].validate(function (valid) {
  599. if (valid) {
  600. _this.formAjax(_this.source)
  601. } else {
  602. console.log('error submit!!');
  603. return false;
  604. }
  605. });
  606. },
  607. // 表单提交请求
  608. formAjax: function(source, info) {
  609. var params = {
  610. source: source,
  611. name: this.form.name,
  612. phone: this.form.phone,
  613. mail: this.form.mail,
  614. company: this.form.companyName, // 公司名称
  615. companyType: this.form.companyType.join(','),
  616. position: this.form.job == '其他' ? this.form.job + '/' + this.form.otherJob : this.form.job,
  617. code: this.form.code,
  618. agree: true, // 原来留资模块的同意协议字段,,,默认传一个true 方便后端处理
  619. branch: this.form.branch.indexOf('总裁') > -1 || this.form.branch.indexOf('总经理') > -1 || !this.form.job ? '' : this.form.branch,
  620. // interest: this.interest
  621. }
  622. if (info) {
  623. params = info
  624. params.source = source
  625. params.interest = info.interest // 感兴趣内容
  626. }
  627. var _this = this
  628. $.ajax({
  629. type:'POST',
  630. url: '/salesLeads/collectInfo',
  631. contentType: "application/json;charset=utf-8",
  632. data: JSON.stringify(params),
  633. success:function (res) {
  634. if (res.data) {
  635. _this.showForm = false
  636. _this.showSuccess = true
  637. } else {
  638. _this.$message.error(res.error_msg);
  639. }
  640. }
  641. })
  642. },
  643. // 手机号输入框input事件
  644. inputPhone: function(val) {
  645. this.form.phone = val.replace(/[^\d]/g,'')
  646. },
  647. // 企业名称联想
  648. getResult:function(name) {
  649. // 名称为空或长度小于2不发请求
  650. if (!name || name.length < 2) return
  651. var _this = this
  652. $.ajax({
  653. type:'POST',
  654. url:'/jypay/user/company/association',
  655. data: {
  656. name: name,
  657. companyCount:10
  658. },
  659. heads : {
  660. 'content-type': 'application/x-www-form-urlencoded'
  661. },
  662. success:function (res) {
  663. console.log(res)
  664. if (res.data && res.data.length > 0) {
  665. var result = []
  666. res.data.map(function(item){
  667. item = _this.brightKeyword(item)
  668. result.push(item)
  669. return result
  670. })
  671. _this.companyList = result
  672. _this.showSearchResult = true
  673. }
  674. }
  675. })
  676. },
  677. searchCompany: debounce(function(val){
  678. if(val === '') { this.showSearchResult = false}
  679. this.getResult(val)
  680. }, 600),
  681. // 选择联想出来的公司名称
  682. selectCompany: function(item) {
  683. this.form.companyName = item.replace(/<.*?>/ig, '')
  684. this.showSearchResult = false
  685. },
  686. // 关键词高亮
  687. brightKeyword: function (val) {
  688. var name = this.form.companyName
  689. if (val.indexOf(name) !== -1) {
  690. return val.replace(name, `<span style='color:#2ABED1;'>${name}</span>`)
  691. } else {
  692. return val
  693. }
  694. },
  695. // 暂不提供
  696. cancelForm: function() {
  697. this.form.name = ''
  698. this.form.phone = ''
  699. this.form.mail = ''
  700. this.form.companyName = ''
  701. this.form.job = ''
  702. this.form.otherJob = ''
  703. this.form.code = ''
  704. var needExportSource = ['structedData', 'pc_data_custom_export', 'pc_data_custom_data']
  705. if (needExportSource.indexOf(this.source) > -1) {
  706. this.showForm = false
  707. this.showExport = true
  708. } else {
  709. this.showForm = false
  710. }
  711. this.showSearchResult=false
  712. },
  713. // 数据导出
  714. dataExport: function() {
  715. location.href = "/front/dataExport/toSieve"
  716. }
  717. }
  718. })