edit.vue 21 KB

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