edit.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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" :loading="loading" 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. import {mapGetters} from "vuex";
  260. export default {
  261. name: "add",
  262. inject:['arealist'],
  263. components:{duplicateCheck},
  264. data(){
  265. return {
  266. dialogFormVisible:false,
  267. isordercheck:true,
  268. isusedcheck:false,
  269. checkResults:'',
  270. customerShow:false,
  271. businessData:[],
  272. customerLead:[],
  273. customerType:[],
  274. publicList:[],
  275. businessParam:{
  276. "id": 20221208103601,
  277. "content": {
  278. "pageNumber":1,
  279. "pageSize":5,
  280. "keyword":''
  281. },
  282. },
  283. businessShow:false,
  284. total:0,
  285. currentPage:0,
  286. value:'',
  287. options:{
  288. industryData:[],
  289. customerGrade:[],
  290. customerClassification:[],
  291. },
  292. form:{
  293. value:[],
  294. sa_customersid: 0,//新增是传0
  295. parentid: 0, //上级客户ID,默认或没有上级的时候传0
  296. sys_enterpriseid: 0, //合作企业档案ID,新增是传0,更新
  297. enterprisename:"",//客户名称(企业名称)
  298. type: "", //客户类型
  299. customergrade:'',//客户等级
  300. sa_customerpoolid: '', //客户池(公海池)ID,默认或没有的时候传0
  301. source: "", //客户来源
  302. province:"",//非必填,可选
  303. city:"",//非必填,可选
  304. county:"",//非必填,可选
  305. address:"",//非必填,可选
  306. abbreviation:"",//非必填,可选
  307. taxno:"",//税号,非必填,可选
  308. grade:'',// 客户等级(商户等级)
  309. industry:[],//非必填,可选,所属行业
  310. contact:"",//非必填,可选
  311. phonenumber:"",//非必填,可选
  312. ispublic:1,
  313. telephone: "",
  314. sa_agentsid: ""
  315. },
  316. rules:{
  317. enterprisename:[
  318. { required: true, message: '输入客户名称', trigger: 'blur'},
  319. ],
  320. type: [
  321. { required: true, message: '还未选择客户类型', trigger: 'change' },
  322. ],
  323. source:[
  324. { required: true, message: '请填写客户来源', trigger: 'blur'}
  325. ],
  326. contact: [
  327. { required: true, message: '请输入法人', trigger: 'change,blur' },
  328. ],
  329. telephone: [
  330. { required: true, message: '请输入联系电话', trigger: 'change,blur' },
  331. ],
  332. province: [
  333. { required: true, message: '请选择省市县', trigger: 'change,blur' },
  334. ],
  335. },
  336. customerParam:{
  337. "id": 20220920083901,
  338. "content": {
  339. "pageNumber": 1,
  340. "pageSize": 10,
  341. "where": {
  342. "condition": "",
  343. "type":2,
  344. "sa_projectid":""
  345. }
  346. }
  347. },
  348. customer:{
  349. customerData:[],
  350. total:0,
  351. currentPage:0,
  352. },
  353. }
  354. },
  355. props:['data','btnType'],
  356. computed:{
  357. ...mapGetters({
  358. loading:'loading'
  359. })
  360. },
  361. methods:{
  362. onClose(){
  363. this.businessShow = false
  364. this.dialogFormVisible = false
  365. this.$emit('onSuccess')
  366. },
  367. editBtn () {
  368. this.industryList()
  369. this.gradeList()
  370. this.queryCustomerGrade()
  371. this.getSysOption()
  372. this.getPublicList()
  373. this.dialogFormVisible = true
  374. /* let arr = ['province','city','county']
  375. arr.forEach(e=>{
  376. this.data[e] !== '' ?this.form.value.push(this.data[e]):''
  377. })*/
  378. /* this.form = Object.assign({},this.form,this.data)*/
  379. console.log(this.form)
  380. this.form = Object.assign({},this.form,this.data)
  381. console.log(this.form)
  382. this.form.value = [this.form.province,this.form.city,this.form.county]
  383. if (this.form.grade === 0){
  384. this.form.grade = ''
  385. }
  386. },
  387. /*工商查询*/
  388. async businessSearch(){
  389. this.businessParam.content.keyword = this.form.enterprisename
  390. const res = await this.$api.requested(this.businessParam)
  391. console.log(res,"工商查询结果")
  392. this.businessData = res.data
  393. this.total = res.total
  394. this.currentPage = res.pageNumber
  395. this.businessShow = true
  396. },
  397. /*选择工商信息*/
  398. businessSelect(val){
  399. console.log("选择的工商信息",val)
  400. this.$confirm('是否以查询的工商信息更新客户信息?', '提示', {
  401. confirmButtonText: '确定',
  402. cancelButtonText: '取消',
  403. type: 'warning'
  404. }).then(() => {
  405. this.businessShow = false
  406. this.form.enterprisename = val.companyName
  407. this.form.address = val.address === "-" ? '' : val.address
  408. this.form.taxno = val.taxNum
  409. this.form.value = [val.regProvince,val.regCity,val.regArea]
  410. this.form.province = val.regProvince
  411. this.form.city = val.regCity
  412. this.form.county = val.regArea
  413. this.form.contact = val.legalPerson
  414. console.log(this.form)
  415. }).catch(() => {
  416. this.businessShow = false
  417. this.$message({
  418. type: 'info',
  419. message: '已取消更新'
  420. });
  421. })
  422. },
  423. /*handleSizeChange(val) {
  424. // console.log(`每页 ${val} 条`);
  425. this.param.content.pageSize = val
  426. this.businessSearch()
  427. },
  428. handleCurrentChange(val) {
  429. // console.log(`当前页: ${val}`);
  430. this.param.content.pageNumber = val
  431. this.businessSearch()
  432. },*/
  433. /*查重检查*/
  434. onCheck(){
  435. this.$refs.form.validate((valid) => {
  436. if (!valid) return false
  437. this.$refs.check.queryRule()
  438. })
  439. },
  440. /*自动查重判断*/
  441. duplicateCheck(){
  442. this.$refs.form.validate(async (valid) => {
  443. if (!valid) return false
  444. const res = await this.$api.requested({
  445. "id": 20221208172002,
  446. "content": {
  447. "sa_customersid":this.form.sa_customersid,
  448. "enterprisename":this.form.enterprisename,
  449. "taxno":this.form.taxno,
  450. "address":this.form.address
  451. },
  452. })
  453. console.log(res,"查重结果")
  454. if (res.data.length !== 0){
  455. console.log("重复")
  456. }
  457. this.checkResults = res.data.length
  458. this.onSave()
  459. })
  460. },
  461. onSave(){
  462. this.$refs.form.validate((valid) => {
  463. if (!valid) return false
  464. this.$store.commit('setLoading',true)
  465. this.$refs.check.creatShow = true
  466. this.$refs.check.buttonTitle = '确定保存'
  467. this.$refs.check.queryRule(()=>{
  468. this.$store.commit('setLoading',false)
  469. })
  470. })
  471. },
  472. onSubmit(){
  473. this.$refs['form'].validate(async (valid) => {
  474. if (!valid) return false
  475. /*if (this.form.province) {
  476. this.form.city = this.form.province[1]
  477. this.form.county = this.form.province[2]
  478. this.form.province = this.form.province[0]
  479. }*/
  480. const res = await this.$api.requested({
  481. "id": "20221010164302",
  482. "version":1,
  483. "content": this.form
  484. })
  485. this.tool.showMessage(res,()=>{
  486. if (this.checkResults === 0){
  487. this.$emit('onSuccess')
  488. this.$refs['form'].resetFields();
  489. this.dialogFormVisible = false
  490. this.checkResults = ''
  491. }else {
  492. this.setTag(this.form.sa_customersid)
  493. }
  494. })
  495. })
  496. },
  497. async setTag(id) {
  498. const res = await this.$api.requested({
  499. "id": 20220929090901,
  500. "content": {
  501. "ownertable": "sa_customers",
  502. "ownerid": id,
  503. "datatag": [
  504. "疑似重复",
  505. ]
  506. }
  507. })
  508. this.$emit('onSuccess')
  509. this.$refs['form'].resetFields();
  510. this.dialogFormVisible = false
  511. this.checkResults = ''
  512. },
  513. cascaderChange (val) {
  514. this.form.province = val[0]
  515. if (val.length === 1)
  516. return this.form = Object.assign({},this.form,{province:val[0],city:'',county:''})
  517. this.form = Object.assign({},this.form,{province:val[0],city:val[1],county:val[2]})
  518. this.$refs.form.validateField('province')
  519. },
  520. async customerList(){
  521. const res = await this.$api.requested(this.customerParam)
  522. this.customer.customerData = res.data
  523. this.customer.total = res.total
  524. this.customer.currentPage = res.pageNumber
  525. },
  526. selectCustomer(){
  527. this.customerParam.content.where.condition = this.form.enterprisename
  528. this.customerList()
  529. },
  530. /*客户选择信息*/
  531. customerData(val){
  532. this.form.parentid = val.sa_customersid
  533. this.form.superiorenterprisename = val.enterprisename
  534. this.customerShow = false
  535. },
  536. /*客户分页*/
  537. handleSizeChangeCustomer(val) {
  538. // console.log(`每页 ${val} 条`);
  539. this.customerParam.content.pageSize = val
  540. this.customerList()
  541. },
  542. handleCurrentChangeCustomer(val) {
  543. // console.log(`当前页: ${val}`);
  544. this.customerParam.content.pageNumber = val
  545. this.customerList()
  546. },
  547. /*行业列表*/
  548. async industryList(){
  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": "industry",
  557. "parameter": {
  558. "siteid": siteid
  559. }
  560. }
  561. })
  562. this.options.industryData = res.data
  563. },
  564. /*客户分类*/
  565. async gradeList(){
  566. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  567. const res = await this.$api.requested({
  568. "classname": "sysmanage.develop.optiontype.optiontype",
  569. "method": "optiontypeselect",
  570. "content": {
  571. "pageNumber": 1,
  572. "pageSize": 20,
  573. "typename": "customergrade",
  574. "parameter": {
  575. "siteid": siteid
  576. }
  577. }
  578. })
  579. console.log("客户等级",res.data)
  580. /*for (var i=0;i<res.data.length; i++){
  581. if (res.data[i].remarks !== ''){
  582. this.options.gradeData[i] = res.data[i].value + "——" + res.data[i].remarks
  583. }else{
  584. this.options.gradeData[i] = res.data[i].value
  585. }
  586. }*/
  587. this.options.customerClassification = res.data
  588. console.log("处理后客户等级",this.options.customerClassification)
  589. },
  590. /*客户等级*/
  591. queryCustomerGrade(){
  592. this.$store.dispatch('optiontypeselect','agentgrade').then(res=>{
  593. this.options.customerGrade = res.data
  594. })
  595. },
  596. /* 获取系统选项数据 */
  597. async getSysOption() {
  598. /* 获取客户类型 */
  599. let res = await this.$store.dispatch('optiontypeselect','customertypemx')
  600. this.customerType = res.data
  601. /* 获取客户等级 */
  602. let res2 = await this.$store.dispatch('optiontypeselect','customergrade')
  603. this.customerLead = res2.data
  604. },
  605. /* 获取公海数据 */
  606. async getPublicList() {
  607. const res = await this.$api.requested({
  608. "id": 20221009100702,
  609. "content": {
  610. "pageNumber": 1,
  611. "pageSize": 999999,
  612. "where": {
  613. }
  614. },
  615. })
  616. this.publicList = res.data
  617. },
  618. },
  619. mounted() {
  620. }
  621. }
  622. </script>
  623. <style scoped>
  624. /deep/.el-select,.el-cascader {
  625. width: 100%;
  626. }
  627. /deep/.el-input__prefix {
  628. display: flex;
  629. align-items: center;
  630. }
  631. </style>