edit.vue 23 KB

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