changeCustomer.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <div>
  3. <el-button size="mini" :type="disabled || data.status === '已无效'?'':'primary'" @click="onShow" :disabled="disabled || data.status === '已无效'" >转化客户</el-button>
  4. <el-drawer
  5. title="转化为客户"
  6. :visible.sync="drawer"
  7. size="600px"
  8. direction="rtl"
  9. :show-close="false"
  10. append-to-body
  11. @close="onClose">
  12. <div class="drawer__panel">
  13. <el-row :gutter="20">
  14. <el-form :model="form" :rules="rules" ref="form" label-width="85px" label-position="right" size="mini">
  15. <el-col :span="20">
  16. <el-form-item label="客户名称:" prop="enterprisename_customer">
  17. <el-input v-model="form.enterprisename_customer" placeholder="请输入客户名称" style="width: 100%"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="4">
  21. <businessMessage :keyWord="form.enterprisename_customer" @businessData="onBusinessData"></businessMessage>
  22. </el-col>
  23. <el-col :span="24">
  24. <el-form-item label="企业简称:" prop="abbreviation">
  25. <el-input v-model="form.abbreviation" placeholder="请输入企业简称" style="width: 100%"></el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="24" >
  29. <el-form-item label="客户类型:" prop="type">
  30. <el-select v-model="form.type" placeholder="请选择客户类型" style="width: 100%">
  31. <el-option
  32. v-for="item in options.type"
  33. :key="item.value"
  34. :label="item.value"
  35. :value="item.value">
  36. <!-- <span style="float: left">{{ item.value }}</span>
  37. <span v-if="item.remarks !== ''" style="float: right; color: #8492a6; font-size: 10px">{{ item.remarks }}</span>-->
  38. <span style="float: left">{{ item.value }}</span>
  39. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="24">
  45. <el-form-item label="客户等级:" >
  46. <el-select v-model="form.customergrade" placeholder="请选择客户等级" style="width: 100%">
  47. <el-option
  48. v-for="item in options.customerGrade"
  49. :key="item.rowindex"
  50. :label="item.value "
  51. :value="item.value">
  52. <span style="float: left">{{ item.value }}</span>
  53. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="24">
  59. <el-form-item label="客户分类:" >
  60. <el-select v-model="form.customergrade" placeholder="请选择客户分类" style="width: 100%">
  61. <el-option
  62. v-for="item in options.customerClassification"
  63. :key="item.rowindex"
  64. :label="item.value "
  65. :value="item.value">
  66. <span style="float: left">{{ item.value }}</span>
  67. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  68. </el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="24">
  73. <el-form-item label="客户行业:" >
  74. <el-select
  75. ref="sle"
  76. style="width:100%;"
  77. v-model="form.industry"
  78. multiple
  79. placeholder="请选择所属行业"
  80. size="mini"
  81. >
  82. <el-option
  83. v-for="item in options.industryData"
  84. :key="item.value"
  85. :label="item.value"
  86. :value="item.value"
  87. >
  88. <span style="float: left">{{ item.value }}</span>
  89. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  90. </el-option>
  91. </el-select>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="24">
  95. <el-form-item label="税号:" prop="taxno">
  96. <el-input v-model="form.taxno" placeholder="请输入企业税号" style="width: 100%"></el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="24">
  100. <el-form-item label="法人:" prop="contact">
  101. <el-input v-model="form.contact" placeholder="请输入法人信息" style="width: 100%"></el-input>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="24">
  105. <el-form-item label="电话:" prop="contact">
  106. <el-input v-model="form.telephone" placeholder="请输入电话" style="width: 100%"></el-input>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="24">
  110. <el-form-item label="省市县:" >
  111. <el-cascader
  112. style="width: 100%"
  113. v-model="value"
  114. :options="basicData.data().areaData"
  115. @change="cascaderChange" clearable>
  116. </el-cascader>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="24">
  120. <el-form-item label="详细地址:" prop="address">
  121. <el-input v-model="form.address" placeholder="请输入企业地址" style="width: 100%"></el-input>
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="24">
  125. <el-form-item label="上级企业:" >
  126. <el-popover
  127. placement="bottom"
  128. width="700"
  129. trigger="click"
  130. v-model="customerShow"
  131. @show="customerList">
  132. <el-input
  133. style="width:300px;margin-bottom: 10px"
  134. placeholder="请输入内容"
  135. v-model="customerParam.content.where.condition"
  136. clearable
  137. @clear="customerList(customerParam.content.pageNumber = 1)"
  138. size="mini"
  139. @keyup.enter.native="customerList(customerParam.content.pageNumber = 1)">
  140. <i slot="prefix" class="el-icon-search" @click="customerList(customerParam.content.pageNumber = 1)"></i>
  141. </el-input>
  142. <el-table :data="customer.customerData" @row-click="customerData" height="396px" :header-cell-style="{background:'#EEEEEE',color:'#333'}" size="mini">
  143. <el-table-column
  144. label="客户编号"
  145. width="75">
  146. <template slot-scope="scope">
  147. <span style="margin-left: 10px">{{ scope.row.sa_customersid?scope.row.sa_customersid:'--' }}</span>
  148. </template>
  149. </el-table-column>
  150. <el-table-column
  151. label="客户名称"
  152. width="260">
  153. <template slot-scope="scope">
  154. <span style="margin-left: 10px">{{ scope.row.enterprisename?scope.row.enterprisename:'--'}}</span>
  155. </template>
  156. </el-table-column>
  157. <el-table-column
  158. label="地址"
  159. >
  160. <template slot-scope="scope">
  161. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  162. </template>
  163. </el-table-column>
  164. </el-table>
  165. <div class="container normal-panel" style="text-align:right">
  166. <el-pagination
  167. background
  168. small
  169. @size-change="handleSizeChangeCustomer"
  170. @current-change="handleCurrentChangeCustomer"
  171. :page-sizes="[10,20,50,100,]"
  172. layout="total,sizes, prev, pager, next, jumper"
  173. :current-page="customer.currentPage"
  174. :total="customer.total">
  175. </el-pagination>
  176. </div>
  177. <el-input slot="reference" :readonly="true" v-model="form.superiorenterprisename" autocomplete="off" placeholder="请选择客户" @input="selectCustomer"></el-input>
  178. </el-popover>
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="24">
  182. <el-form-item label="客户来源:" >
  183. <el-input v-model="form.source" placeholder="请输入客户来源" style="width: 100%"></el-input>
  184. </el-form-item>
  185. </el-col>
  186. </el-form>
  187. </el-row>
  188. </div>
  189. <div class="fixed__btn__panel">
  190. <el-button size="small" @click="onClose" class="normal-btn-width inline-16">取 消</el-button>
  191. <duplicateCheck :data="form" @checkSuccess="checkSuccess"></duplicateCheck>
  192. <el-button size="small" type="primary" @click="onSave" class="normal-btn-width">确 定</el-button>
  193. </div>
  194. </el-drawer>
  195. </div>
  196. </template>
  197. <script>
  198. import businessMessage from '@/components/businessMessage/index'
  199. import duplicateCheck from "@/SDrpManagement/salerPrivatecustomer/components/duplicateCheck";
  200. export default {
  201. props:["disabled","data"],
  202. name: "changeCustomer",
  203. components:{businessMessage,duplicateCheck},
  204. data(){
  205. return {
  206. drawer:false,
  207. customerShow:false,
  208. checkResults:'',
  209. rules:{
  210. phonenumber: [
  211. { required: true, message: '请输入手机号码', trigger: 'blur' },
  212. { pattern:/^1[3-9]\d{9}$/, message: '请输入正确手机号码',trigger: 'blur' }
  213. ],
  214. enterprisename_customer: [
  215. { required: true, message: '请输入客户名称', trigger: 'blur' },
  216. ],
  217. roleids: [
  218. { required: true, message: '请选择授权角色', trigger: 'change' }
  219. ],
  220. type: [
  221. { required: true, message: '请选择客户类型', trigger: 'change' }
  222. ],
  223. },
  224. form:{
  225. "sat_orderclueid": '',
  226. "enterprisename_customer":'',
  227. "sa_customersid": 0, //新增是传0
  228. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  229. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  230. "enterprisename": "", //客户名称(企业名称)
  231. "type": "", //客户类型
  232. "source": "", //客户来源
  233. "province": "", //非必填,可选
  234. "city": "", //非必填,可选
  235. "county": "", //非必填,可选
  236. "address": "", //非必填,可选
  237. "abbreviation": "", //非必填,可选
  238. "taxno": "", //税号,非必填,可选
  239. "grade": '', // 客户等级(商户等级)
  240. "industry": [], //非必填,可选,所属行业
  241. "contact": "", //非必填,可选
  242. "phonenumber": "", //非必填,可选
  243. "customergrade": "", //客户等级
  244. },
  245. customerParam:{
  246. "id": 20220920083901,
  247. "content": {
  248. "pageNumber": 1,
  249. "pageSize": 10,
  250. "where": {
  251. "condition": "",
  252. "type":6,
  253. "sa_projectid":""
  254. }
  255. }
  256. },
  257. customer:{
  258. customerData:[],
  259. total:0,
  260. currentPage:0,
  261. },
  262. value:'',
  263. options:{
  264. type:[],
  265. parentCustomers:[],
  266. gradeData:[],
  267. industryData:[],
  268. customerGrade:[],
  269. customerClassification:[],
  270. distributor:[]
  271. },
  272. }
  273. },
  274. methods:{
  275. onShow(){
  276. console.log(this.data,"转化客户信息")
  277. this.drawer = true
  278. this.form = Object.assign({},this.form,this.data)
  279. this.form.source = this.form.cluesource
  280. this.value = [this.form.province,this.form.city,this.form.county]
  281. console.log(this.form,"获取的表单数据")
  282. this.gradeList()
  283. this.industryList()
  284. this.typeList()
  285. },
  286. /*自动查重判断*/
  287. duplicateCheck(){
  288. this.$refs.form.validate(async (valid) => {
  289. if (!valid) return false
  290. const res = await this.$api.requested({
  291. "id": 20221208172002,
  292. "content": {
  293. "sa_customersid":0,
  294. "enterprisename":this.form.enterprisename_customer,
  295. "taxno":this.form.taxno,
  296. "address":this.form.address
  297. },
  298. })
  299. console.log(res,"查重结果")
  300. if (res.data.length !== 0){
  301. console.log("重复")
  302. }
  303. this.checkResults = res.data.length
  304. this.onSave()
  305. })
  306. },
  307. onSave(){
  308. if (this.checkResults === '' || this.checkResults === undefined){
  309. this.duplicateCheck()
  310. }else {
  311. if (this.checkResults !== 0){
  312. this.$confirm('该客户疑似重复,是否确认创建客户?', '提示', {
  313. confirmButtonText: '确定',
  314. cancelButtonText: '取消',
  315. type: 'warning'
  316. }).then(() => {
  317. this.onSubmit()
  318. }).catch(() => {
  319. this.$message({
  320. type: 'info',
  321. message: '已取消创建'
  322. });
  323. });
  324. }else {
  325. this.onSubmit()
  326. }
  327. }
  328. },
  329. async setTag(id){
  330. const res = await this.$api.requested({
  331. "id": 20220929090901,
  332. "content": {
  333. "ownertable":"sa_customers",
  334. "ownerid":id,
  335. "datatag":[
  336. "疑似重复",
  337. ]
  338. }
  339. })
  340. this.$emit('onChangeCustomer')
  341. this.$refs['form'].resetFields();
  342. this.form = {
  343. "sat_orderclueid": '',
  344. "enterprisename_customer":'',
  345. "sa_customersid": 0, //新增是传0
  346. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  347. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  348. "enterprisename": "", //客户名称(企业名称)
  349. "type": "", //客户类型
  350. "source": "", //客户来源
  351. "province": "", //非必填,可选
  352. "city": "", //非必填,可选
  353. "county": "", //非必填,可选
  354. "address": "", //非必填,可选
  355. "abbreviation": "", //非必填,可选
  356. "taxno": "", //税号,非必填,可选
  357. "grade": '', // 客户等级(商户等级)
  358. "industry": "", //非必填,可选,所属行业
  359. "contact": "", //非必填,可选
  360. "phonenumber": "", //非必填,可选
  361. "customergrade": "", //客户等级
  362. }
  363. this.drawer = false
  364. this.checkResults = ''
  365. this.value = ''
  366. },
  367. onSubmit(){
  368. this.form.enterprisename = this.form.enterprisename_customer
  369. this.$refs.form.validate(async (valid)=>{
  370. if (!valid) return false
  371. const res = await this.$api.requested({
  372. "id": 20221216184302,
  373. "content": this.form,
  374. })
  375. this.tool.showMessage(res,()=>{
  376. console.log(this.checkResults,"查重结果")
  377. if (this.checkResults === 0){
  378. this.$emit('onChangeCustomer')
  379. this.$refs['form'].resetFields();
  380. this.form = {
  381. }
  382. this.drawer = false
  383. this.checkResults = ''
  384. this.value = ''
  385. }else {
  386. this.setTag(res.data.sa_customersid)
  387. }
  388. })
  389. })
  390. },
  391. onClose(){
  392. this.$refs['form'].resetFields();
  393. this.form = {
  394. "sat_orderclueid": '',
  395. "enterprisename_customer":'',
  396. "sa_customersid": 0, //新增是传0
  397. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  398. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  399. "enterprisename": "", //客户名称(企业名称)
  400. "type": "", //客户类型
  401. "source": "", //客户来源
  402. "province": "", //非必填,可选
  403. "city": "", //非必填,可选
  404. "county": "", //非必填,可选
  405. "address": "", //非必填,可选
  406. "abbreviation": "", //非必填,可选
  407. "taxno": "", //税号,非必填,可选
  408. "grade": '', // 客户等级(商户等级)
  409. "industry": "", //非必填,可选,所属行业
  410. "contact": "", //非必填,可选
  411. "phonenumber": "", //非必填,可选
  412. "customergrade": "", //客户等级
  413. }
  414. this.drawer = false
  415. this.checkResults = ''
  416. this.value = ''
  417. },
  418. /*获取工商信息*/
  419. onBusinessData(val){
  420. this.form.enterprisename_customer = val.companyName
  421. this.form.enterprisename = val.companyName
  422. this.form.address = val.address
  423. this.form.taxno = val.taxNum
  424. this.value = [val.regProvince,val.regCity,val.regArea]
  425. this.form.province = val.regProvince
  426. this.form.city = val.regCity
  427. this.form.county = val.regArea
  428. this.form.contact = val.legalPerson
  429. },
  430. /*省市县*/
  431. cascaderChange (val) {
  432. if (val.length === 1)
  433. return this.form = Object.assign({},this.form,{province:val[0],city:'',county:''})
  434. this.form = Object.assign({},this.form,{province:val[0],city:val[1],county:val[2]})
  435. },
  436. /*客户分类*/
  437. async gradeList(){
  438. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  439. const res = await this.$api.requested({
  440. "classname": "sysmanage.develop.optiontype.optiontype",
  441. "method": "optiontypeselect",
  442. "content": {
  443. "pageNumber": 1,
  444. "pageSize": 20,
  445. "typename": "customergrade",
  446. "parameter": {
  447. "siteid": siteid
  448. }
  449. }
  450. })
  451. console.log("客户等级",res.data)
  452. /*for (var i=0;i<res.data.length; i++){
  453. if (res.data[i].remarks !== ''){
  454. this.options.gradeData[i] = res.data[i].value + "——" + res.data[i].remarks
  455. }else{
  456. this.options.gradeData[i] = res.data[i].value
  457. }
  458. }*/
  459. this.options.customerClassification = res.data
  460. console.log("处理后客户等级",this.options.customerClassification)
  461. },
  462. /*客户等级*/
  463. queryCustomerGrade(){
  464. this.$store.dispatch('optiontypeselect','agentgrade').then(res=>{
  465. this.options.customerGrade = res.data
  466. })
  467. },
  468. /*行业列表*/
  469. async industryList(){
  470. console.log("行业类别")
  471. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  472. const res = await this.$api.requested({
  473. "classname": "sysmanage.develop.optiontype.optiontype",
  474. "method": "optiontypeselect",
  475. "content": {
  476. "pageNumber": 1,
  477. "pageSize": 20,
  478. "typename": "industry",
  479. "parameter": {
  480. "siteid": siteid
  481. }
  482. }
  483. })
  484. this.options.industryData = res.data
  485. },
  486. async customerList(){
  487. const res = await this.$api.requested(this.customerParam)
  488. this.customer.customerData = res.data
  489. this.customer.total = res.total
  490. this.customer.currentPage = res.pageNumber
  491. },
  492. selectCustomer(){
  493. this.customerParam.content.where.condition = this.form.superiorenterprisename
  494. this.customerList()
  495. },
  496. /*客户选择信息*/
  497. customerData(val){
  498. this.form.parentid = val.sa_customersid
  499. this.form.superiorenterprisename = val.enterprisename
  500. this.customerShow = false
  501. },
  502. /*客户分页*/
  503. handleSizeChangeCustomer(val) {
  504. // console.log(`每页 ${val} 条`);
  505. this.customerParam.content.pageSize = val
  506. this.customerList()
  507. },
  508. handleCurrentChangeCustomer(val) {
  509. // console.log(`当前页: ${val}`);
  510. this.customerParam.content.pageNumber = val
  511. this.customerList()
  512. },
  513. /*客户类型列表*/
  514. async typeList(){
  515. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  516. const res = await this.$api.requested({
  517. "classname": "sysmanage.develop.optiontype.optiontype",
  518. "method": "optiontypeselect",
  519. "content": {
  520. "pageNumber": 1,
  521. "pageSize": 20,
  522. "typename": "customertypemx",
  523. "parameter": {
  524. "siteid": siteid
  525. }
  526. }
  527. })
  528. this.options.type = res.data
  529. },
  530. checkSuccess(val){
  531. this.checkResults = val
  532. },
  533. },
  534. mounted() {
  535. }
  536. }
  537. </script>
  538. <style scoped>
  539. /deep/.el-input__prefix {
  540. display: flex;
  541. align-items: center;
  542. }
  543. </style>