add.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <!--上级企业 负责人-->
  3. <div>
  4. <el-button size="small" type="primary" @click="dialogFormVisible = true">新 建</el-button>
  5. <el-drawer
  6. direction="rtl"
  7. append-to-body
  8. title="创建公海客户"
  9. :show-close="false"
  10. :visible.sync="dialogFormVisible"
  11. @close="onClose"
  12. size="600px">
  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="click">
  27. <el-table :data="businessData" @row-click="businessSelect" :header-cell-style="{background:'#EEEEEE',color:'#333'}" size="mini">
  28. <el-table-column width="260" label="客户名称">
  29. <template slot-scope="scope">
  30. <span style="margin-left: 10px">{{ scope.row.companyName?scope.row.companyName:'--' }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="客户地址">
  34. <template slot-scope="scope">
  35. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column width="200" label="客户税号">
  39. <template slot-scope="scope">
  40. <span style="margin-left: 10px">{{ scope.row.taxNum?scope.row.taxNum:'--' }}</span>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. <!-- <div class="container normal-panel" style="text-align:right">
  45. <el-pagination
  46. background
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentChange"
  49. :current-page="currentPage"
  50. :page-sizes="[5]"
  51. layout="total,sizes, prev, pager, next, jumper"
  52. :total="total">
  53. </el-pagination>
  54. </div>-->
  55. <el-button size="mini" type="primary" style="width: 100%" @click="businessSearch" slot="reference">工商查询</el-button>
  56. </el-popover>
  57. </el-col>
  58. <el-col :span="24">
  59. <el-form-item label="客户类型:" prop="type">
  60. <el-select v-model="form.type" placeholder="请选择客户类型" size="small">
  61. <el-option
  62. v-for="item in customerType()"
  63. :key="item.value"
  64. :label="item.value"
  65. :value="item.value">
  66. <span style="float: left">{{ item.value }}</span>
  67. <span v-if="item.remarks !== ''" style="float: right; color: #8492a6; font-size: 10px">{{ 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="客户来源:" prop="source">
  74. <el-input v-model="form.source" placeholder="客户来源"></el-input>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :span="24">
  78. <el-form-item label="客户等级:" prop="grade">
  79. <el-select v-model="form.grade" placeholder="请选择客户等级" size="small">
  80. <el-option
  81. v-for="item in customerLead()"
  82. :key="item.rowindex"
  83. :label="item.value"
  84. :value="item.rowindex">
  85. </el-option>
  86. </el-select>
  87. </el-form-item>
  88. </el-col>
  89. <el-col :span="24">
  90. <el-form-item label="详细地址:" prop="address">
  91. <el-input v-model="form.address" placeholder="详细地址"></el-input>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :span="24">
  95. <el-form-item label="企业简称:" prop="abbreviation">
  96. <el-input v-model="form.abbreviation" placeholder="企业简称"></el-input>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="24">
  100. <el-form-item label="税号:" prop="taxno">
  101. <el-input v-model="form.taxno" placeholder="税号"></el-input>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="24">
  105. <el-form-item label="所属行业:" prop="industry">
  106. <el-input v-model="form.industry" placeholder="所属行业"></el-input>
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="24">
  110. <el-form-item label="联系人:" prop="contact">
  111. <el-input v-model="form.contact" placeholder="联系人"></el-input>
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="24">
  115. <el-form-item label="联系电话:" prop="phonenumber">
  116. <el-input v-model="form.phonenumber" placeholder="联系电话"></el-input>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="24">
  120. <el-form-item label="省市县:" prop="province">
  121. <el-cascader
  122. size="small"
  123. v-model="form.province"
  124. :options="arealist()"
  125. @change="cascaderChange"
  126. ref="cascader">
  127. </el-cascader>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="24">
  131. <el-form-item label="公海池:" prop="sa_customerpoolid">
  132. <el-select v-model="form.sa_customerpoolid" placeholder="请选择公海池" size="small">
  133. <el-option
  134. v-for="item in publicList()"
  135. :key="item.sa_customerpoolid"
  136. :label="item.poolname"
  137. :value="item.sa_customerpoolid">
  138. </el-option>
  139. </el-select>
  140. </el-form-item>
  141. </el-col>
  142. </el-form>
  143. </el-row>
  144. </div>
  145. <div class="fixed__btn__panel">
  146. <el-button size="small" @click="onClose" class="normal-btn-width">取 消</el-button>
  147. <duplicateCheck :data="form"></duplicateCheck>
  148. <el-button size="small" type="primary" @click="onSave" class="normal-btn-width">确 定</el-button>
  149. </div>
  150. </el-drawer>
  151. </div>
  152. </template>
  153. <script>
  154. import duplicateCheck from "@/SDrpManagement/salerPrivatecustomer/components/duplicateCheck";
  155. export default {
  156. name: "add",
  157. inject:['customerLead','customerType','arealist','publicList'],
  158. components:{duplicateCheck},
  159. data(){
  160. return {
  161. dialogFormVisible:false,
  162. isordercheck:true,
  163. isusedcheck:false,
  164. checkResults:'',
  165. businessData:[],
  166. businessParam:{
  167. "id": 20221208103601,
  168. "content": {
  169. "pageNumber":1,
  170. "pageSize":5,
  171. "keyword":''
  172. },
  173. },
  174. businessShow:false,
  175. total:0,
  176. currentPage:0,
  177. form:{
  178. "sa_customersid": 0,//新增是传0
  179. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  180. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  181. "enterprisename":"",//客户名称(企业名称)
  182. "type": "", //客户类型
  183. "sa_customerpoolid": '', //客户池(公海池)ID,默认或没有的时候传0
  184. "source": "", //客户来源
  185. "province":"",//非必填,可选
  186. "city":"",//非必填,可选
  187. "county":"",//非必填,可选
  188. "address":"",//非必填,可选
  189. "abbreviation":"",//非必填,可选
  190. "taxno":"",//税号,非必填,可选
  191. "grade":'',// 客户等级(商户等级)
  192. "industry":"",//非必填,可选,所属行业
  193. "contact":"",//非必填,可选
  194. "phonenumber":"",//非必填,可选
  195. "ispublic":1
  196. },
  197. rules:{
  198. enterprisename:[
  199. { required: true, message: '输入客户名称', trigger: 'blur'},
  200. ],
  201. type: [
  202. { required: true, message: '还未选择客户类型', trigger: 'change' },
  203. ],
  204. source:[
  205. { required: false, message: '请填写客户来源', trigger: 'blur'}
  206. ],
  207. sa_customerpoolid:[
  208. { required: true, message: '请选择公海池', trigger: 'blur'}
  209. ]
  210. }
  211. }
  212. },
  213. methods:{
  214. /*工商查询*/
  215. async businessSearch(){
  216. this.businessParam.content.keyword = this.form.enterprisename
  217. const res = await this.$api.requested(this.businessParam)
  218. console.log(res,"工商查询结果")
  219. this.businessData = res.data
  220. this.total = res.total
  221. this.currentPage = res.pageNumber
  222. },
  223. /*选择工商信息*/
  224. businessSelect(val){
  225. console.log("选择的工商信息",val)
  226. this.$confirm('是否以查询的工商信息更新客户信息?', '提示', {
  227. confirmButtonText: '确定',
  228. cancelButtonText: '取消',
  229. type: 'warning'
  230. }).then(() => {
  231. this.businessShow = false
  232. this.form.enterprisename = val.companyName
  233. this.form.address = val.address
  234. this.form.taxno = val.taxNum
  235. }).catch(() => {
  236. this.$message({
  237. type: 'info',
  238. message: '已取消更新'
  239. });
  240. })
  241. },
  242. /*handleSizeChange(val) {
  243. // console.log(`每页 ${val} 条`);
  244. this.param.content.pageSize = val
  245. this.businessSearch()
  246. },
  247. handleCurrentChange(val) {
  248. // console.log(`当前页: ${val}`);
  249. this.param.content.pageNumber = val
  250. this.businessSearch()
  251. },*/
  252. /*自动查重判断*/
  253. duplicateCheck(){
  254. this.$refs.form.validate(async (valid) => {
  255. if (!valid) return false
  256. const res = await this.$api.requested({
  257. "id": 20221208172002,
  258. "content": {
  259. "sa_customersid":this.form.sa_customersid,
  260. "enterprisename":this.form.enterprisename,
  261. "taxno":this.form.taxno,
  262. "address":this.form.address
  263. },
  264. })
  265. console.log(res,"查重结果")
  266. if (res.data.length !== 0){
  267. console.log("重复")
  268. }
  269. this.checkResults = res.data.length
  270. this.onSave()
  271. })
  272. },
  273. onSave(){
  274. if (this.checkResults === ''){
  275. this.duplicateCheck()
  276. }else {
  277. if (this.checkResults !== 0){
  278. this.$confirm('该客户疑似重复,是否确认创建客户?', '提示', {
  279. confirmButtonText: '确定',
  280. cancelButtonText: '取消',
  281. type: 'warning'
  282. }).then(() => {
  283. this.onSubmit()
  284. }).catch(() => {
  285. this.$message({
  286. type: 'info',
  287. message: '已取消创建'
  288. });
  289. });
  290. }else {
  291. this.onSubmit()
  292. }
  293. }
  294. },
  295. onSubmit(){
  296. this.$refs['form'].validate(async (valid) => {
  297. if (!valid) return false
  298. if (this.form.province) {
  299. this.form.city = this.form.province[1]
  300. this.form.county = this.form.province[2]
  301. this.form.province = this.form.province[0]
  302. }
  303. const res = await this.$api.requested({
  304. "id": "20221010164302",
  305. "version":1,
  306. "content": this.form
  307. })
  308. this.tool.showMessage(res,()=>{
  309. if (this.checkResults === 0){
  310. this.$emit('onSuccess')
  311. this.$refs['form'].resetFields();
  312. this.form = {
  313. "sa_customersid": 0,//新增是传0
  314. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  315. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  316. "enterprisename":"",//客户名称(企业名称)
  317. "type": "", //客户类型
  318. "sa_customerpoolid": '', //客户池(公海池)ID,默认或没有的时候传0
  319. "source": "", //客户来源
  320. "province":"",//非必填,可选
  321. "city":"",//非必填,可选
  322. "county":"",//非必填,可选
  323. "address":"",//非必填,可选
  324. "abbreviation":"",//非必填,可选
  325. "taxno":"",//税号,非必填,可选
  326. "grade":'',// 客户等级(商户等级)
  327. "industry":"",//非必填,可选,所属行业
  328. "contact":"",//非必填,可选
  329. "phonenumber":""//非必填,可选
  330. }
  331. this.dialogFormVisible = false
  332. this.checkResults = ''
  333. }else {
  334. this.setTag(res.data.sa_customersid)
  335. }
  336. /*this.$router.push({path:'/PublicCustomerDetail',query:{id:res.data.sa_customersid,rowindex:0}})
  337. this.$store.dispatch('changeDetailDrawer',true)*/
  338. })
  339. })
  340. },
  341. async setTag(id){
  342. const res = await this.$api.requested({
  343. "id": 20220929090901,
  344. "content": {
  345. "ownertable":"sa_customers",
  346. "ownerid":id,
  347. "datatag":[
  348. "疑似重复",
  349. ]
  350. }
  351. })
  352. this.$emit('onSuccess')
  353. this.$refs['form'].resetFields();
  354. this.form = {
  355. "sa_customersid": 0,//新增是传0
  356. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  357. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  358. "enterprisename":"",//客户名称(企业名称)
  359. "type": "", //客户类型
  360. "sa_customerpoolid": '', //客户池(公海池)ID,默认或没有的时候传0
  361. "source": "", //客户来源
  362. "province":"",//非必填,可选
  363. "city":"",//非必填,可选
  364. "county":"",//非必填,可选
  365. "address":"",//非必填,可选
  366. "abbreviation":"",//非必填,可选
  367. "taxno":"",//税号,非必填,可选
  368. "grade":'',// 客户等级(商户等级)
  369. "industry":"",//非必填,可选,所属行业
  370. "contact":"",//非必填,可选
  371. "phonenumber":""//非必填,可选
  372. }
  373. this.dialogFormVisible = false
  374. this.checkResults = ''
  375. },
  376. onClose(){
  377. this.$refs['form'].resetFields();
  378. this.form = {
  379. "sa_customersid": 0,//新增是传0
  380. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  381. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  382. "enterprisename":"",//客户名称(企业名称)
  383. "type": "", //客户类型
  384. "sa_customerpoolid": '', //客户池(公海池)ID,默认或没有的时候传0
  385. "source": "", //客户来源
  386. "province":"",//非必填,可选
  387. "city":"",//非必填,可选
  388. "county":"",//非必填,可选
  389. "address":"",//非必填,可选
  390. "abbreviation":"",//非必填,可选
  391. "taxno":"",//税号,非必填,可选
  392. "grade":'',// 客户等级(商户等级)
  393. "industry":"",//非必填,可选,所属行业
  394. "contact":"",//非必填,可选
  395. "phonenumber":""//非必填,可选
  396. }
  397. this.dialogFormVisible = false
  398. this.checkResults = ''
  399. },
  400. cascaderChange() {
  401. }
  402. }
  403. }
  404. </script>
  405. <style scoped>
  406. /deep/.el-select,.el-cascader {
  407. width: 100%;
  408. }
  409. </style>