edit.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. <template>
  2. <div>
  3. <el-button
  4. size="mini"
  5. :disabled="data.datastatus === 2 || !data.disabled || data.status == '已终止'"
  6. :type="data.datastatus === 2 || !data.disabled || data.status == '已终止' ? '' : 'primary'"
  7. @click="show"
  8. >{{ $t("编 辑") }}</el-button
  9. >
  10. <el-drawer
  11. :title="$t(`编辑客户`)"
  12. :visible.sync="dialogFormVisible"
  13. size="600px"
  14. direction="rtl"
  15. :show-close="false"
  16. append-to-body
  17. @close="onClose"
  18. >
  19. <div class="drawer__panel">
  20. <el-row :gutter="20">
  21. <el-form
  22. :model="form"
  23. :rules="rules"
  24. ref="form"
  25. :label-width="tool.onlyZh('100px')"
  26. label-position="right"
  27. size="mini"
  28. >
  29. <el-col :span="20">
  30. <el-form-item :label="$t('客户名称') + ':'" prop="enterprisename">
  31. <el-input
  32. v-model="form.enterprisename"
  33. :placeholder="$t('请输入客户名称')"
  34. style="width: 100%"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="4">
  39. <businessInquiry
  40. ref="businessRef"
  41. @businessData="businessSelect"
  42. :keyword="form.enterprisename"
  43. ></businessInquiry>
  44. </el-col>
  45. <el-col :span="24">
  46. <el-form-item :label="$t('企业简称') + ':'">
  47. <el-input
  48. v-model="form.abbreviation"
  49. :placeholder="$t('请输入企业简称')"
  50. style="width: 100%"
  51. ></el-input>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="24">
  55. <el-form-item :label="$t('客户类型') + ':'" prop="type">
  56. <el-select
  57. v-model="form.type"
  58. :placeholder="$t('请选择客户类型')"
  59. style="width: 100%"
  60. >
  61. <el-option
  62. v-for="item in options.type"
  63. :key="item.value"
  64. :label="$t(item.value)"
  65. :value="item.value"
  66. >
  67. <span style="float: left">{{ $t(item.value) }}</span>
  68. <span
  69. style="float: right; color: #8492a6; font-size: 12px"
  70. >{{
  71. item.remarks ? $t(item.remarks) : $t("暂无描述")
  72. }}</span
  73. >
  74. </el-option>
  75. </el-select>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="24">
  79. <el-form-item :label="$t('客户等级') + ':'">
  80. <el-select
  81. v-model="form.grade"
  82. :placeholder="$t('请选择客户等级')"
  83. style="width: 100%"
  84. >
  85. <el-option
  86. v-for="item in options.customerGrade"
  87. :key="item.rowindex"
  88. :label="$t(item.value)"
  89. :value="item.value"
  90. >
  91. <span style="float: left">{{ $t(item.value) }}</span>
  92. <span
  93. style="float: right; color: #8492a6; font-size: 12px"
  94. >{{
  95. item.remarks ? $t(item.remarks) : $t("暂无描述")
  96. }}</span
  97. >
  98. </el-option>
  99. </el-select>
  100. </el-form-item>
  101. </el-col>
  102. <el-col :span="24">
  103. <el-form-item :label="$t('客户分类') + ':'" prop="customergrade">
  104. <el-select
  105. v-model="form.customergrade"
  106. :placeholder="$t('请选择客户分类')"
  107. style="width: 100%"
  108. >
  109. <el-option
  110. v-for="item in options.customerClassification"
  111. :key="item.rowindex"
  112. :label="$t(item.value)"
  113. :value="item.value"
  114. >
  115. <span style="float: left">{{ $t(item.value) }}</span>
  116. <span
  117. style="float: right; color: #8492a6; font-size: 12px"
  118. >{{
  119. item.remarks ? $t(item.remarks) : $t("暂无描述")
  120. }}</span
  121. >
  122. </el-option>
  123. </el-select>
  124. </el-form-item>
  125. </el-col>
  126. <el-col :span="24">
  127. <el-form-item :label="$t('客户行业') + ':'" prop="industry">
  128. <el-select
  129. ref="sle"
  130. style="width: 100%"
  131. v-model="form.industry"
  132. multiple
  133. :placeholder="$t('请选择所属行业')"
  134. size="mini"
  135. >
  136. <el-option
  137. v-for="item in options.industryData"
  138. :key="item.value"
  139. :label="$t(item.value)"
  140. :value="item.value"
  141. >
  142. <span style="float: left">{{ $t(item.value) }}</span>
  143. <span
  144. style="float: right; color: #8492a6; font-size: 12px"
  145. >{{
  146. item.remarks ? $t(item.remarks) : $t("暂无描述")
  147. }}</span
  148. >
  149. </el-option>
  150. </el-select>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="24">
  154. <el-form-item :label="$t('联系人') + ':'">
  155. <el-input
  156. autosize
  157. v-model="form.contactsinfo.name"
  158. :placeholder="$t(`请输入联系人姓名`)"
  159. disabled
  160. ></el-input>
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="24" v-if="isPhone">
  164. <el-form-item
  165. :label="$t('联系方式') + ':'"
  166. prop="contactsinfo.phonenumber"
  167. >
  168. <el-button-group>
  169. <el-radio v-model="isPhone" :label="true" disabled>{{
  170. $t("手机号")
  171. }}</el-radio>
  172. <el-radio v-model="isPhone" :label="false" disabled>{{
  173. $t("座机电话")
  174. }}</el-radio>
  175. </el-button-group>
  176. <el-input
  177. v-model="form.contactsinfo.phonenumber"
  178. :placeholder="$t('请输入手机号')"
  179. style="width: 100%; margin-top: 10px"
  180. disabled
  181. ></el-input>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="24" v-if="!isPhone">
  185. <el-form-item
  186. :label="$t('联系方式') + ':'"
  187. prop="contactsinfo.telephone"
  188. >
  189. <el-button-group>
  190. <el-radio v-model="isPhone" :label="true" disabled>{{
  191. $t("手机号")
  192. }}</el-radio>
  193. <el-radio v-model="isPhone" :label="false" disabled>{{
  194. $t("座机电话")
  195. }}</el-radio>
  196. </el-button-group>
  197. <div style="width: 100%">
  198. <el-input
  199. v-model="areaCode"
  200. :placeholder="$t('请输入区号')"
  201. style="width: 25%; margin-top: 10px"
  202. disabled
  203. ></el-input>
  204. <span style="color: #999999">——</span>
  205. <el-input
  206. v-model="telephone"
  207. :placeholder="$t('请输入座机电话')"
  208. style="width: 68%; margin-top: 10px"
  209. disabled
  210. ></el-input>
  211. </div>
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="24">
  215. <el-form-item :label="$t('税号') + ':'">
  216. <el-input
  217. v-model="form.taxno"
  218. :placeholder="$t('请输入企业税号')"
  219. style="width: 100%"
  220. ></el-input>
  221. </el-form-item>
  222. </el-col>
  223. <el-col :span="24">
  224. <el-form-item :label="$t('法人') + ':'" prop="contact">
  225. <el-input
  226. v-model="form.contact"
  227. :placeholder="$t('请输入法人信息')"
  228. style="width: 100%"
  229. ></el-input>
  230. </el-form-item>
  231. </el-col>
  232. <el-col :span="24">
  233. <el-form-item :label="$t('联系电话') + ':'" prop="telephone">
  234. <el-input
  235. v-model="form.telephone"
  236. :placeholder="$t('请输入联系电话')"
  237. style="width: 100%"
  238. ></el-input>
  239. </el-form-item>
  240. </el-col>
  241. <el-col :span="24">
  242. <el-form-item :label="$t('省市县') + ':'" prop="province">
  243. <el-cascader
  244. :placeholder="$t('请选择')"
  245. style="width: 100%"
  246. v-model="form.value"
  247. :options="basicData.data().areaData"
  248. @change="cascaderChange"
  249. clearable
  250. >
  251. </el-cascader>
  252. </el-form-item>
  253. </el-col>
  254. <el-col :span="24">
  255. <el-form-item :label="$t('详细地址') + ':'">
  256. <el-input
  257. v-model="form.address"
  258. :placeholder="$t('请输入详细地址')"
  259. style="width: 100%"
  260. ></el-input>
  261. </el-form-item>
  262. </el-col>
  263. <el-col :span="24">
  264. <el-form-item
  265. :label="$t('上级企业') + ':'"
  266. prop="superiorenterprisename"
  267. >
  268. <el-popover
  269. placement="bottom"
  270. width="700"
  271. trigger="click"
  272. v-model="customerShow"
  273. @show="customerList"
  274. >
  275. <el-input
  276. style="width: 300px; margin-bottom: 10px"
  277. :placeholder="$t('请输入内容')"
  278. v-model="customerParam.content.where.condition"
  279. clearable
  280. @clear="
  281. customerList((customerParam.content.pageNumber = 1))
  282. "
  283. size="mini"
  284. @keyup.enter.native="
  285. customerList((customerParam.content.pageNumber = 1))
  286. "
  287. >
  288. <i
  289. slot="prefix"
  290. class="el-icon-search"
  291. @click="
  292. customerList((customerParam.content.pageNumber = 1))
  293. "
  294. ></i>
  295. </el-input>
  296. <el-table
  297. :data="customer.customerData"
  298. @row-click="customerData"
  299. height="396px"
  300. :header-cell-style="{
  301. background: '#EEEEEE',
  302. color: '#333',
  303. }"
  304. size="mini"
  305. >
  306. <el-table-column :label="$t('客户编号')" width="100">
  307. <template slot-scope="scope">
  308. <span style="margin-left: 10px">{{
  309. scope.row.sa_customersid
  310. ? scope.row.sa_customersid
  311. : "--"
  312. }}</span>
  313. </template>
  314. </el-table-column>
  315. <el-table-column :label="$t('客户名称')" width="260">
  316. <template slot-scope="scope">
  317. <span style="margin-left: 10px">{{
  318. scope.row.enterprisename
  319. ? scope.row.enterprisename
  320. : "--"
  321. }}</span>
  322. </template>
  323. </el-table-column>
  324. <el-table-column :label="$t('地址')">
  325. <template slot-scope="scope">
  326. <span style="margin-left: 10px">{{
  327. scope.row.address ? scope.row.address : "--"
  328. }}</span>
  329. </template>
  330. </el-table-column>
  331. </el-table>
  332. <div class="container normal-panel" style="text-align: right">
  333. <el-pagination
  334. background
  335. small
  336. @size-change="handleSizeChangeCustomer"
  337. @current-change="handleCurrentChangeCustomer"
  338. :page-sizes="[20, 50, 100]"
  339. layout="total,sizes, prev, pager, next, jumper"
  340. :current-page="customer.currentPage"
  341. :total="customer.total"
  342. >
  343. </el-pagination>
  344. </div>
  345. <el-input
  346. slot="reference"
  347. :readonly="true"
  348. v-model="form.superiorenterprisename"
  349. autocomplete="off"
  350. :placeholder="$t('请选择客户')"
  351. @input="selectCustomer"
  352. ></el-input>
  353. </el-popover>
  354. </el-form-item>
  355. </el-col>
  356. <el-col :span="24">
  357. <el-form-item :label="$t('客户来源') + ':'">
  358. <selectTemp
  359. ref="sourceRef"
  360. :placeholder="$t('请选择来源')"
  361. payload="cluesource"
  362. @selectChange="selectSource"
  363. :cluesource="form.source"
  364. ></selectTemp>
  365. </el-form-item>
  366. </el-col>
  367. <el-col :span="24">
  368. <el-form-item :label="$t(`归属经销商`) + ':'">
  369. <el-popover
  370. placement="bottom"
  371. width="700"
  372. trigger="click"
  373. v-model="agentsShow"
  374. @show="queryAgents"
  375. >
  376. <el-input
  377. style="width: 300px; margin-bottom: 10px"
  378. :placeholder="$t('请输入内容')"
  379. v-model="agentsParam.content.where.condition"
  380. clearable
  381. @clear="queryAgents((agentsParam.content.pageNumber = 1))"
  382. size="mini"
  383. @keyup.enter.native="
  384. queryAgents((agentsParam.content.pageNumber = 1))
  385. "
  386. >
  387. <i
  388. slot="prefix"
  389. class="el-icon-search"
  390. @click="queryAgents((agentsParam.content.pageNumber = 1))"
  391. ></i>
  392. </el-input>
  393. <el-table
  394. :data="agents.agentsData"
  395. @row-click="agentsData"
  396. height="396px"
  397. :header-cell-style="{
  398. background: '#EEEEEE',
  399. color: '#333',
  400. }"
  401. size="mini"
  402. >
  403. <el-table-column :label="$t(`经销商编码`)" width="100">
  404. <template slot-scope="scope">
  405. <span style="margin-left: 10px">{{
  406. scope.row.agentnum ? scope.row.agentnum : "--"
  407. }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column :label="$t('经销商名称')" width="260">
  411. <template slot-scope="scope">
  412. <span style="margin-left: 10px">{{
  413. scope.row.enterprisename
  414. ? scope.row.enterprisename
  415. : "--"
  416. }}</span>
  417. </template>
  418. </el-table-column>
  419. <el-table-column :label="$t('地址')">
  420. <template slot-scope="scope">
  421. <span style="margin-left: 10px">{{
  422. scope.row.address ? scope.row.address : "--"
  423. }}</span>
  424. </template>
  425. </el-table-column>
  426. </el-table>
  427. <div class="container normal-panel" style="text-align: right">
  428. <el-pagination
  429. background
  430. small
  431. @size-change="handleSizeChangeAgent"
  432. @current-change="handleCurrentChangeAgent"
  433. :page-sizes="[20, 50, 100]"
  434. layout="total,sizes, prev, pager, next, jumper"
  435. :current-page="agents.currentPage"
  436. :total="agents.total"
  437. >
  438. </el-pagination>
  439. </div>
  440. <el-input
  441. slot="reference"
  442. :readonly="true"
  443. v-model="form.agentname"
  444. autocomplete="off"
  445. :placeholder="$t(`请选择经销商`)"
  446. @input="selectAgents"
  447. ></el-input>
  448. </el-popover>
  449. </el-form-item>
  450. </el-col>
  451. </el-form>
  452. </el-row>
  453. </div>
  454. <div class="fixed__btn__panel">
  455. <el-button
  456. size="small"
  457. @click="onClose"
  458. class="normal-btn-width inline-16"
  459. >{{ $t("取 消") }}</el-button
  460. >
  461. <duplicateCheck
  462. :data="form"
  463. ref="check"
  464. @onSuccess="onClose"
  465. @onCheck="onCheck"
  466. ></duplicateCheck>
  467. <el-button
  468. size="small"
  469. type="warning"
  470. :loading="loading"
  471. @click="onSave"
  472. class="normal-btn-width"
  473. >{{ $t("保 存") }}</el-button
  474. >
  475. </div>
  476. </el-drawer>
  477. <enterprise
  478. :visible="visibleEnterprise"
  479. :index="index"
  480. :sa_projectid="form.sa_projectid"
  481. v-if="visibleEnterprise"
  482. @onEnterprise="onEnterprise"
  483. >
  484. </enterprise>
  485. </div>
  486. </template>
  487. <script>
  488. import enterprise from "@/SDrpManagement/salerPrivatecustomer/components/enterprise";
  489. import duplicateCheck from "@/components/duplicatesCheck/customerCheck";
  490. import businessInquiry from "@/template/businessInquiry/index";
  491. import { mapGetters } from "vuex";
  492. export default {
  493. name: "edit",
  494. props: ["data", "btnType"],
  495. components: { enterprise, duplicateCheck, businessInquiry },
  496. data() {
  497. return {
  498. isPhone: true,
  499. dialogFormVisible: false,
  500. visibleEnterprise: false,
  501. checkResults: "",
  502. index: "",
  503. disabled: true,
  504. userInfo: JSON.parse(window.sessionStorage.getItem("userInfo")),
  505. businessData: [],
  506. businessParam: {
  507. id: 20221208103601,
  508. content: {
  509. pageNumber: 1,
  510. pageSize: 5,
  511. keyword: "",
  512. },
  513. },
  514. businessShow: false,
  515. total: 0,
  516. currentPage: 0,
  517. form: {
  518. sa_customersid: 0, //新增是传0
  519. parentid: 0, //上级客户ID,默认或没有上级的时候传0
  520. sys_enterpriseid: 0, //合作企业档案ID,新增是传0,更新
  521. enterprisename: "", //客户名称(企业名称)
  522. type: "", //客户类型
  523. source: "", //客户来源
  524. province: "", //非必填,可选
  525. city: "", //非必填,可选
  526. county: "", //非必填,可选
  527. address: "", //非必填,可选
  528. abbreviation: "", //非必填,可选
  529. taxno: "", //税号,非必填,可选
  530. grade: "", // 客户等级(商户等级)
  531. industry: [], //非必填,可选,所属行业
  532. contact: "", //非必填,可选
  533. phonenumber: "", //非必填,可选
  534. customergrade: "",
  535. ispublic: 0, //1:公海客户,0:私域客户,自己新建的
  536. telephone: "",
  537. sa_agentsid: "",
  538. value: "",
  539. contactsinfo: {
  540. name: "",
  541. telephone: "",
  542. phonenumber: "",
  543. oldcontactsid: "",
  544. },
  545. },
  546. options: {
  547. type: [],
  548. parentCustomers: [],
  549. industryData: [],
  550. customerGrade: [],
  551. customerClassification: [],
  552. distributor: [],
  553. },
  554. rules: {
  555. enterprisename: [
  556. { required: true, message: this.$t("输入客户"), trigger: "blur" },
  557. ],
  558. type: [
  559. {
  560. required: true,
  561. message: this.$t("请选择客户类型"),
  562. trigger: "change",
  563. },
  564. ],
  565. contact: [
  566. {
  567. required: false,
  568. message: this.$t("请输入法人"),
  569. trigger: "change,blur",
  570. },
  571. ],
  572. telephone: [
  573. {
  574. required: false,
  575. message: this.$t("请输入联系电话"),
  576. trigger: "change,blur",
  577. },
  578. /* { pattern:/^1[3-9]\d{9}$/, message: this.$t('请输入正确手机号码'),trigger: 'change' }*/
  579. ],
  580. province: [
  581. {
  582. required: true,
  583. message: this.$t("请选择省市县"),
  584. trigger: "change,blur",
  585. },
  586. ],
  587. source: [
  588. {
  589. required: true,
  590. message: this.$t("请选择客户来源"),
  591. trigger: "change",
  592. },
  593. ],
  594. "contactsinfo.name": [
  595. {
  596. required: false,
  597. message: this.$t("请输入联系人姓名"),
  598. trigger: "change,blur",
  599. },
  600. ],
  601. "contactsinfo.phonenumber": [
  602. {
  603. required: false,
  604. message: this.$t("请输入联系电话"),
  605. trigger: "change",
  606. },
  607. {
  608. pattern: /^1[3-9]\d{9}$/,
  609. message: this.$t("请输入正确手机号码"),
  610. trigger: "change",
  611. },
  612. ],
  613. "contactsinfo.telephone": [
  614. {
  615. required: false,
  616. message: this.$t("请输入座机电话"),
  617. trigger: "change",
  618. },
  619. {
  620. pattern: /^0\d{2,3}-\d{7,8}$/,
  621. message: this.$t("请输入正确座机电话"),
  622. trigger: "change",
  623. },
  624. ],
  625. customergrade: [
  626. { required:JSON.parse(sessionStorage.getItem('active_account')).siteid == 'HY'?true:false, message: this.$t('请选择客户分类'), trigger: 'change' },
  627. ],
  628. industry: [
  629. { required:JSON.parse(sessionStorage.getItem('active_account')).siteid == 'HY'?true:false, message: this.$t('请选择客户行业'), trigger: 'change' },
  630. ],
  631. },
  632. areaCode: "",
  633. telephone: "",
  634. agentsShow: false,
  635. agentsParam: {
  636. id: 20230214162602,
  637. content: {
  638. hrid: "",
  639. pageNumber: 1,
  640. pageSize: 20,
  641. where: {
  642. condition: "",
  643. },
  644. },
  645. },
  646. agents: {
  647. agentsData: [],
  648. total: 0,
  649. currentPage: 0,
  650. },
  651. customerParam: {
  652. id: 20220920083901,
  653. content: {
  654. pageNumber: 1,
  655. pageSize: 20,
  656. where: {
  657. condition: "",
  658. type: 2,
  659. sa_projectid: "",
  660. },
  661. },
  662. },
  663. customer: {
  664. customerData: [],
  665. total: 0,
  666. currentPage: 0,
  667. },
  668. customerShow: false,
  669. };
  670. },
  671. watch: {
  672. mainData(val) {
  673. if (this.data.leader.length !== 0) {
  674. if (
  675. JSON.parse(window.sessionStorage.getItem("userInfo")).userid ===
  676. this.data.leader[0].userid
  677. ) {
  678. this.disabled = false;
  679. } else {
  680. this.disabled = true;
  681. }
  682. }
  683. console.log("权限结果", this.disabled);
  684. },
  685. },
  686. computed: {
  687. ...mapGetters({
  688. loading: "loading",
  689. }),
  690. },
  691. methods: {
  692. onClose() {
  693. this.dialogFormVisible = false;
  694. this.businessShow = false;
  695. this.$emit("onSuccess");
  696. },
  697. show() {
  698. this.dialogFormVisible = true;
  699. this.typeList();
  700. /*this.parentCustomer()*/
  701. this.gradeList();
  702. this.industryList();
  703. this.queryCustomerGrade();
  704. /*let arr = ['province','city','county']
  705. arr.forEach(e=>{
  706. this.data[e] !== '' ?this.form.value.push(this.data[e]):''
  707. })*/
  708. this.form = Object.assign({}, this.form, this.data);
  709. this.form.value = [this.form.province, this.form.city, this.form.county];
  710. if (this.form.grade === 0) {
  711. this.form.grade = "";
  712. }
  713. if (this.form.sa_agentsid === 0) {
  714. this.form.sa_agentsid = "";
  715. }
  716. this.form.contactsinfo.name = this.form.contactsinfo[0].name;
  717. if (
  718. this.form.contactsinfo[0].phonenumber.substring(
  719. 0,
  720. this.form.contactsinfo[0].phonenumber.indexOf("-")
  721. )
  722. ) {
  723. this.isPhone = false;
  724. this.areaCode = this.form.contactsinfo[0].phonenumber.substring(
  725. 0,
  726. this.form.contactsinfo[0].phonenumber.indexOf("-")
  727. );
  728. this.telephone = this.form.contactsinfo[0].phonenumber.substring(
  729. this.areaCode.length + 1
  730. );
  731. this.form.contactsinfo.phonenumber =
  732. this.areaCode + "-" + this.telephone;
  733. } else {
  734. this.isPhone = true;
  735. this.form.contactsinfo.phonenumber =
  736. this.form.contactsinfo[0].phonenumber;
  737. }
  738. /*if (this.form.parentid === 0){
  739. this.form.parentid = '未选择'
  740. }*/
  741. },
  742. /*工商查询*/
  743. async businessSearch() {
  744. this.businessParam.content.keyword = this.form.enterprisename;
  745. const res = await this.$api.requested(this.businessParam);
  746. console.log(res, "工商查询结果");
  747. this.businessData = res.data;
  748. this.total = res.total;
  749. this.currentPage = res.pageNumber;
  750. this.businessShow = true;
  751. },
  752. /*选择工商信息*/
  753. businessSelect(val, regProvince) {
  754. this.$confirm(
  755. this.$t("是否以查询的工商信息更新客户信息") + "?",
  756. this.$t("提示"),
  757. {
  758. confirmButtonText: this.$t("确定"),
  759. cancelButtonText: this.$t("取消"),
  760. type: "warning",
  761. }
  762. )
  763. .then(() => {
  764. this.$refs.businessRef.businessShow = false;
  765. this.form.enterprisename = val.companyName;
  766. this.form.address = val.address === "-" ? "" : val.address;
  767. this.form.taxno = val.taxNum;
  768. this.form.value = [regProvince, val.regCity, val.regArea];
  769. this.form.province = regProvince;
  770. this.form.city = val.regCity;
  771. this.form.county = val.regArea;
  772. this.form.contact = val.legalPerson;
  773. this.form.telephone = val.phone;
  774. })
  775. .catch(() => {
  776. this.$refs.businessRef.businessShow = false;
  777. this.$message({
  778. type: "info",
  779. message: this.$t("已取消更新"),
  780. });
  781. });
  782. },
  783. /*查重检查*/
  784. onCheck() {
  785. this.$refs.form.validate((valid) => {
  786. if (!valid) return false;
  787. this.$refs.check.creatShow = false;
  788. this.$refs.check.queryRule();
  789. });
  790. },
  791. /*自动查重判断*/
  792. duplicateCheck() {
  793. this.$refs.form.validate(async (valid) => {
  794. if (!valid) return false;
  795. const res = await this.$api.requested({
  796. id: 20221208172002,
  797. content: {
  798. sa_customersid: this.form.sa_customersid,
  799. enterprisename: this.form.enterprisename,
  800. taxno: this.form.taxno,
  801. address: this.form.address,
  802. },
  803. });
  804. console.log(res, "查重结果");
  805. if (res.data.length !== 0) {
  806. console.log("重复");
  807. }
  808. this.checkResults = res.data.length;
  809. this.onSave();
  810. });
  811. },
  812. onSave() {
  813. this.$refs.form.validate((valid) => {
  814. if (!valid) return false;
  815. this.$refs.check.creatShow = true;
  816. this.$refs.check.buttonTitle = "确定保存";
  817. this.$store.commit("setLoading", true);
  818. this.$refs.check.queryRule(() => {
  819. this.$store.commit("setLoading", false);
  820. });
  821. });
  822. },
  823. onSubmit() {
  824. console.log(this.form);
  825. this.$refs["form"].validate(async (valid) => {
  826. if (!valid) return false;
  827. const res = await this.$api.requested({
  828. id: 20221012163902,
  829. content: this.form,
  830. });
  831. this.tool.showMessage(res, () => {
  832. if (this.checkResults === 0) {
  833. this.$emit("onSuccess");
  834. this.$refs["form"].resetFields();
  835. this.dialogFormVisible = false;
  836. this.checkResults = "";
  837. } else {
  838. this.setTag(this.form.sa_customersid);
  839. }
  840. });
  841. });
  842. },
  843. async setTag(id) {
  844. const res = await this.$api.requested({
  845. id: 20220929090901,
  846. content: {
  847. ownertable: "sa_customers",
  848. ownerid: id,
  849. datatag: ["疑似重复"],
  850. },
  851. });
  852. this.$emit("onSuccess");
  853. this.$refs["form"].resetFields();
  854. this.dialogFormVisible = false;
  855. this.checkResults = "";
  856. },
  857. /*客户类型列表*/
  858. async typeList() {
  859. const siteid = JSON.parse(
  860. sessionStorage.getItem("active_account")
  861. ).siteid;
  862. const res = await this.$api.requested({
  863. classname: "sysmanage.develop.optiontype.optiontype",
  864. method: "optiontypeselect",
  865. content: {
  866. pageNumber: 1,
  867. pageSize: 20,
  868. typename: "customertypemx",
  869. parameter: {
  870. siteid: siteid,
  871. },
  872. },
  873. });
  874. this.options.type = res.data;
  875. },
  876. enterpriseList() {
  877. this.visibleEnterprise = true;
  878. },
  879. /*上级客户列表*/
  880. onEnterprise(data) {
  881. this.visibleEnterprise = false;
  882. console.log("企业信息", data);
  883. this.form.parentid = data.sys_enterpriseid;
  884. this.form.superiorenterprisename = data.enterprisename;
  885. },
  886. /*省市县*/
  887. cascaderChange(val) {
  888. this.form.province = val[0];
  889. if (val.length === 1)
  890. return (this.form = Object.assign({}, this.form, {
  891. province: val[0],
  892. city: "",
  893. county: "",
  894. }));
  895. this.form = Object.assign({}, this.form, {
  896. province: val[0],
  897. city: val[1],
  898. county: val[2],
  899. });
  900. this.$refs.form.validateField("province");
  901. },
  902. /*客户分类*/
  903. async gradeList() {
  904. const siteid = JSON.parse(
  905. sessionStorage.getItem("active_account")
  906. ).siteid;
  907. const res = await this.$api.requested({
  908. classname: "sysmanage.develop.optiontype.optiontype",
  909. method: "optiontypeselect",
  910. content: {
  911. pageNumber: 1,
  912. pageSize: 20,
  913. typename: "customergrade",
  914. parameter: {
  915. siteid: siteid,
  916. },
  917. },
  918. });
  919. this.options.customerClassification = res.data;
  920. },
  921. /*客户等级*/
  922. queryCustomerGrade() {
  923. this.$store.dispatch("optiontypeselect", "agentgrade").then((res) => {
  924. this.options.customerGrade = res.data;
  925. });
  926. },
  927. /*行业列表*/
  928. async industryList() {
  929. const siteid = JSON.parse(
  930. sessionStorage.getItem("active_account")
  931. ).siteid;
  932. const res = await this.$api.requested({
  933. classname: "sysmanage.develop.optiontype.optiontype",
  934. method: "optiontypeselect",
  935. content: {
  936. pageNumber: 1,
  937. pageSize: 20,
  938. typename: "industry",
  939. parameter: {
  940. siteid: siteid,
  941. },
  942. },
  943. });
  944. this.options.industryData = res.data;
  945. },
  946. /*所属经销商*/
  947. async queryAgents() {
  948. var sessionData = sessionStorage.getItem("active_account");
  949. this.agentsParam.content.hrid = JSON.parse(sessionData).hrid;
  950. const res = await this.$api.requested(this.agentsParam);
  951. this.agents.agentsData = res.data;
  952. this.agents.total = res.total;
  953. this.agents.currentPage = res.pageNumber;
  954. console.log(this.agents.agentsData, "经销商");
  955. },
  956. selectAgents() {
  957. this.agentsParam.content.where.condition = this.form.agentname;
  958. this.queryAgents();
  959. },
  960. /*客户选择信息*/
  961. agentsData(val) {
  962. this.form.sa_agentsid = val.sa_agentsid;
  963. this.form.agentname = val.enterprisename;
  964. this.agentsShow = false;
  965. },
  966. /*客户分页*/
  967. handleSizeChangeAgent(val) {
  968. // console.log(`每页 ${val} 条`);
  969. this.agentsParam.content.pageSize = val;
  970. this.queryAgents();
  971. },
  972. handleCurrentChangeAgent(val) {
  973. // console.log(`当前页: ${val}`);
  974. this.agentsParam.content.pageNumber = val;
  975. this.queryAgents();
  976. },
  977. async customerList() {
  978. const res = await this.$api.requested(this.customerParam);
  979. this.customer.customerData = res.data;
  980. this.customer.total = res.total;
  981. this.customer.currentPage = res.pageNumber;
  982. },
  983. selectCustomer() {
  984. this.customerParam.content.where.condition = this.form.enterprisename;
  985. this.customerList();
  986. },
  987. /*客户选择信息*/
  988. customerData(val) {
  989. this.form.parentid = val.sa_customersid;
  990. this.form.superiorenterprisename = val.enterprisename;
  991. this.customerShow = false;
  992. },
  993. /*客户分页*/
  994. handleSizeChangeCustomer(val) {
  995. // console.log(`每页 ${val} 条`);
  996. this.customerParam.content.pageSize = val;
  997. this.customerList();
  998. },
  999. handleCurrentChangeCustomer(val) {
  1000. // console.log(`当前页: ${val}`);
  1001. this.customerParam.content.pageNumber = val;
  1002. this.customerList();
  1003. },
  1004. selectSource(data) {
  1005. this.form.source = data;
  1006. },
  1007. },
  1008. };
  1009. </script>
  1010. <style scoped>
  1011. </style>