edit.vue 23 KB

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