editContact.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div>
  3. <el-button size="small" type="text" @click="onshow" >{{
  4. $t("编辑")
  5. }}</el-button>
  6. <el-drawer
  7. :title="$t(`编辑联系人`)"
  8. :visible.sync="dialogFormVisible"
  9. size="600px"
  10. direction="rtl"
  11. :show-close="false"
  12. append-to-body
  13. @close="onClose"
  14. >
  15. <div class="drawer__panel">
  16. <el-row :gutter="20">
  17. <el-form
  18. :model="form"
  19. :rules="rules"
  20. ref="form"
  21. size="mini"
  22. label-position="right"
  23. :label-width="tool.onlyZh('90px')"
  24. >
  25. <el-col :span="24">
  26. <el-form-item :label="$t(`姓名`) + ':'" prop="name">
  27. <el-input autosize v-model="form.name" :placeholder="$t('请填写联系人')" ></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="24">
  31. <el-form-item>
  32. <el-radio v-model="form.isTelephone" label="0">{{
  33. $t("手机号")
  34. }}</el-radio>
  35. <el-radio v-model="form.isTelephone" label="1">{{
  36. $t("座机电话")
  37. }}</el-radio>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="24" v-if="form.isTelephone == '1'">
  41. <el-form-item :label="$t('联系方式') + ':'" prop="telephone">
  42. <el-input
  43. v-model="form.areaCode"
  44. style="width: 25%"
  45. autocomplete="on"
  46. :placeholder="$t('请填写区号')"
  47. ></el-input>
  48. <span style="color: #999999">——</span>
  49. <el-input
  50. v-model="form.telephone"
  51. style="width: 68%"
  52. autocomplete="on"
  53. :placeholder="$t('请填写座机电话')"
  54. ></el-input>
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="24">
  58. <el-form-item
  59. v-if="form.isTelephone == '0'"
  60. :label="$t('联系方式') + ':'"
  61. prop="phonenumber"
  62. :rules="[
  63. { required: true, message: this.$t('手机号码不能为空') },
  64. {
  65. pattern: /^1[3-9][0-9]\d{8}$/,
  66. message: this.$t('请输入正确手机号码'),
  67. trigger: 'change',
  68. },
  69. ]"
  70. >
  71. <el-input
  72. v-model="form.phonenumber"
  73. autocomplete="on"
  74. :placeholder="$t('请填写手机号码')"
  75. ></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="24">
  79. <el-form-item :label="$t('微信') + ':'" prop="wechatnum">
  80. <el-input
  81. autosize
  82. v-model="form.wechatnum"
  83. :placeholder="$t(`请输入微信`)"
  84. ></el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="24">
  88. <el-form-item
  89. :label="$t(`邮箱`) + ':'"
  90. :rules="[
  91. {
  92. pattern:
  93. /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
  94. message: $t('请输入有效的邮箱'),
  95. trigger: 'change',
  96. },
  97. ]"
  98. >
  99. <el-input
  100. autosize
  101. v-model="form.email"
  102. :placeholder="$t(`请输入邮箱`)"
  103. ></el-input>
  104. </el-form-item>
  105. </el-col>
  106. <!-- <el-col :span="24">-->
  107. <!-- <el-form-item :label="$t(`传真`) + ':'">-->
  108. <!-- <el-input-->
  109. <!-- autosize-->
  110. <!-- v-model="form.fax"-->
  111. <!-- :placeholder="$t(`请输入传真`)"-->
  112. <!-- ></el-input>-->
  113. <!-- </el-form-item>-->
  114. <!-- </el-col>-->
  115. <el-col :span="24">
  116. <el-form-item :label="$t(`关联企业`) + ':'">
  117. <el-input
  118. autosize
  119. v-model="form.enterprisename"
  120. :placeholder="$t(`请输入关联企业`)"
  121. disabled
  122. ></el-input>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="24">
  126. <el-form-item :label="$t(`部门`) + ':'" prop="depname">
  127. <el-input
  128. autosize
  129. v-model="form.depname"
  130. :placeholder="$t(`请输入部门`)"
  131. ></el-input>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="24">
  135. <el-form-item :label="$t(`职位`) + ':'" prop="position">
  136. <el-input
  137. autosize
  138. v-model="form.position"
  139. :placeholder="$t(`请输入职位`)"
  140. ></el-input>
  141. </el-form-item>
  142. </el-col>
  143. <el-col :span="24">
  144. <el-form-item :label="$t(`性别`) + ':'">
  145. <el-radio v-model="form.sex" label="男">{{
  146. $t("男")
  147. }}</el-radio>
  148. <el-radio v-model="form.sex" label="女">{{
  149. $t("女")
  150. }}</el-radio>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="24">
  154. <el-form-item :label="$t(`生日`) + ':'">
  155. <el-date-picker
  156. v-model="form.birthday"
  157. value-format="yyyy-MM-dd"
  158. type="date"
  159. :placeholder="$t('选择日期')"
  160. style="width: 100%"
  161. >
  162. </el-date-picker>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="24">
  166. <el-form-item :label="$t(`家庭住址`) + ':'">
  167. <el-input
  168. type="textarea"
  169. rows="5"
  170. v-model="form.address"
  171. :placeholder="$t(`请输入家庭住址`)"
  172. ></el-input>
  173. </el-form-item>
  174. </el-col>
  175. <el-col :span="24">
  176. <el-form-item :label="$t(`偏好`)" prop="preference">
  177. <el-input
  178. v-model="form.preference"
  179. autocomplete="on"
  180. :placeholder="$t(`请填写偏好`)"
  181. ></el-input>
  182. </el-form-item>
  183. </el-col>
  184. <el-col :span="24">
  185. <el-form-item :label="$t(`爱好`)" prop="hobby">
  186. <el-input
  187. v-model="form.hobby"
  188. autocomplete="on"
  189. :placeholder="$t(`请填写爱好`)"
  190. ></el-input>
  191. </el-form-item>
  192. </el-col>
  193. <el-col :span="24">
  194. <el-form-item :label="$t(`备注`) + ':'">
  195. <el-input
  196. type="textarea"
  197. rows="5"
  198. v-model="form.remarks"
  199. :placeholder="$t(`请输入备注`)"
  200. ></el-input>
  201. </el-form-item>
  202. </el-col>
  203. </el-form>
  204. </el-row>
  205. </div>
  206. <div class="fixed__btn__panel">
  207. <el-button size="small" @click="onClose" class="normal-btn-width">{{
  208. $t("取 消")
  209. }}</el-button>
  210. <el-button
  211. size="small"
  212. type="primary"
  213. :loading="loading"
  214. @click="onSubmit"
  215. class="normal-btn-width"
  216. >{{ $t("确 定") }}</el-button
  217. >
  218. </div>
  219. </el-drawer>
  220. </div>
  221. </template>
  222. <script>
  223. import { mapGetters } from "vuex";
  224. import contactsNewTemplate from "@/template/contactsNewTemplate/index";
  225. export default {
  226. name: "editContact",
  227. props: ["data"],
  228. components: { contactsNewTemplate },
  229. data() {
  230. var validateMobilePhone = (rule, value, callback) => {
  231. if (value === "") {
  232. callback(new Error(this.$t("手机号不可为空")));
  233. } else {
  234. if (value !== "") {
  235. var reg = /^1[3456789]\d{9}$/;
  236. if (!reg.test(value)) {
  237. callback(new Error(this.$t("请输入有效的手机号码")));
  238. }
  239. }
  240. callback();
  241. }
  242. };
  243. var telephone = (rule, value, callback) => {
  244. if (this.form.areaCode === "" && this.form.telephone === "") {
  245. callback(new Error(this.$t("座机电话不能为空")));
  246. } else {
  247. var reg = /^0\d{2,3}-\d{7,8}$/;
  248. let telephone = this.form.areaCode + "-" + this.form.telephone;
  249. if (!reg.test(telephone)) {
  250. callback(new Error(this.$t("请输入正确座机电话")));
  251. } else {
  252. callback();
  253. }
  254. }
  255. };
  256. return {
  257. dialogFormVisible: false,
  258. activeName: "first",
  259. visible: false,
  260. tagList: [],
  261. tags: [],
  262. groupname: "客户联系人",
  263. form: {
  264. "sat_orderclue_contactsid": 0,
  265. "sys_phonebookid": '',
  266. "sat_orderclueid": '',
  267. "phonenumber": "",
  268. "birthday": "",
  269. "name": "",
  270. "depname": "",
  271. "wechatnum": "",
  272. "position": "",
  273. "email": "",
  274. "sex": "",
  275. "homeaddress": "",
  276. "remarks": "",
  277. "fax": "",
  278. "isleader": "",
  279. "grade": "",
  280. "hobby": "",
  281. "preference": "",
  282. "sys_phonebookgroupid": 0,
  283. "telephone": "",
  284. "isTelephone": "0",
  285. "areaCode": "",
  286. },
  287. rules: {
  288. name: [
  289. { required: true, message: this.$t("姓名不能为空"), trigger: "blur,change" },
  290. ],
  291. // phonenumber: [
  292. // { required: true, validator: validateMobilePhone, trigger: 'blur' },
  293. // ]
  294. telephone: [
  295. { required: true, validator: telephone, trigger: "change" },
  296. ],
  297. depname: [
  298. { required: true, message: this.$t('部门不能为空'), trigger: 'blur' },
  299. ],
  300. position: [
  301. { required: true, message: this.$t('职位不能为空'), trigger: 'blur' },
  302. ],
  303. },
  304. enterpriseContact: {
  305. param: {
  306. content: {
  307. sys_enterpriseid: "",
  308. pageNumber: 1,
  309. pageSize: 9999,
  310. where: {
  311. condition: "",
  312. },
  313. },
  314. id: 20221219193002,
  315. },
  316. listData: [],
  317. total: 0,
  318. currentPage: 0,
  319. show: false,
  320. },
  321. myContacts: {
  322. param: {
  323. id: 20221219161202,
  324. content: {
  325. pageNumber: 1,
  326. pageSize: 9999,
  327. ownertable: "sa_customers",
  328. ownerid: "",
  329. where: {
  330. condition: "",
  331. },
  332. },
  333. },
  334. listData: [],
  335. total: 0,
  336. currentPage: 0,
  337. show: false,
  338. },
  339. paramTag: {
  340. id: "20220929085401",
  341. content: {
  342. nocache: true,
  343. ownertable: "",
  344. ownerid: 0,
  345. },
  346. },
  347. contactParam:{
  348. "id": 2025042110061502,
  349. "content": {
  350. "sat_orderclueid": this.$route.query.id,
  351. "pageSize": 20,
  352. "pageNumber": 1,
  353. "where":{
  354. "condition":""
  355. }
  356. },
  357. }
  358. };
  359. },
  360. computed: {
  361. ...mapGetters({
  362. loading: "loading",
  363. }),
  364. },
  365. methods: {
  366. onshow() {
  367. this.dialogFormVisible = true;
  368. this.activeName = "first";
  369. this.enterpriseContact.param.content.pageNumber = 1;
  370. this.myContacts.param.content.pageNumber = 1;
  371. this.enterpriseContactList();
  372. this.myContactList();
  373. this.getTag();
  374. // this.form.sys_enterpriseid = this.data.sys_enterpriseid;
  375. this.form = Object.assign({}, this.form, this.data);
  376. // this.tags = this.form.tag;
  377. if (this.form.phonenumber.indexOf("-") != "-1") {
  378. this.form.isTelephone = "1";
  379. this.form.areaCode = this.data.phonenumber.substring(
  380. 0,
  381. this.form.phonenumber.indexOf("-")
  382. );
  383. this.form.telephone = this.data.phonenumber.substring(
  384. this.form.areaCode.length + 1
  385. );
  386. this.form.phonenumber = "";
  387. }
  388. // this.form.enterprisename = this.data.enterprisename_customer;
  389. },
  390. onSubmit() {
  391. this.$refs["form"].validate(async (valid) => {
  392. if (!valid) return false;
  393. this.$store.commit("setLoading", true);
  394. if (this.form.isTelephone == "1") {
  395. this.form.phonenumber =
  396. this.form.areaCode + "-" + this.form.telephone;
  397. }
  398. this.form.sat_orderclueid = this.$route.query.id
  399. const res = await this.$api.requested({
  400. id: "2025042110003902",
  401. content: this.form,
  402. });
  403. this.tool.showMessage(res, async () => {
  404. /*let res2 = await this.$api.requested({
  405. "id": 20220929090901,
  406. "content": {
  407. "ownertable":"sys_phonebook",
  408. "ownerid":res.data.sys_phonebookid,
  409. "datatag": this.tags
  410. }
  411. })*/
  412. this.$emit("updateSuccess");
  413. this.$refs["form"].resetFields();
  414. this.tags = [];
  415. this.form = {
  416. "sat_orderclue_contactsid": 0,
  417. "sys_phonebookid": '',
  418. "sat_orderclueid": '',
  419. "phonenumber": "",
  420. "birthday": "",
  421. "name": "",
  422. "depname": "",
  423. "wechatnum": "",
  424. "position": "",
  425. "email": "",
  426. "sex": "",
  427. "homeaddress": "",
  428. "remarks": "",
  429. "fax": "",
  430. "isleader": "",
  431. "grade": "",
  432. "hobby": "",
  433. "preference": "",
  434. "sys_phonebookgroupid": 0,
  435. "telephone": "",
  436. "isTelephone": "0",
  437. "areaCode": "",
  438. };
  439. this.$store.commit("setLoading", false);
  440. this.dialogFormVisible = false;
  441. });
  442. });
  443. },
  444. searchData() {
  445. this.changeTab();
  446. },
  447. changeTab() {
  448. this.enterpriseContactList();
  449. this.myContactList();
  450. },
  451. /*企业联系人*/
  452. async enterpriseContactList() {
  453. this.enterpriseContact.param.content.where.condition = this.form.name;
  454. this.enterpriseContact.param.content.sys_enterpriseid =
  455. this.data.sys_enterpriseid;
  456. const res = await this.$api.requested(this.enterpriseContact.param);
  457. this.enterpriseContact.listData = res.data;
  458. this.enterpriseContact.total = res.total;
  459. this.enterpriseContact.currentPage = res.pageNumber;
  460. },
  461. /*选择企业联系人*/
  462. enterpriseContactSelect(val) {
  463. this.form.name = val.name;
  464. if (val.phonenumber.indexOf("-") != "-1") {
  465. this.form.isTelephone = "1";
  466. this.form.areaCode = val.phonenumber.substring(
  467. 0,
  468. val.phonenumber.indexOf("-")
  469. );
  470. this.form.telephone = val.phonenumber.substring(
  471. this.form.areaCode.length + 1
  472. );
  473. this.form.phonenumber = "";
  474. } else {
  475. this.form.isTelephone = "0";
  476. this.form.phonenumber = val.phonenumber;
  477. this.form.areaCode = "";
  478. this.form.telephone = "";
  479. }
  480. this.form.email = val.email;
  481. this.form.position = val.position;
  482. this.form.depname = val.depname;
  483. this.form.sex = val.sex;
  484. this.form.birthday = val.birthday;
  485. this.form.address = val.address;
  486. this.form.remarks = val.remarks;
  487. this.enterpriseContact.show = false;
  488. },
  489. handleSizeChangeEnterprise(val) {
  490. // console.log(`每页 ${val} 条`);
  491. this.enterpriseContact.param.content.pageSize = val;
  492. this.enterpriseContactList();
  493. },
  494. handleCurrentChangeEnterprise(val) {
  495. // console.log(`当前页: ${val}`);
  496. this.enterpriseContact.param.content.pageNumber = val;
  497. this.enterpriseContactList();
  498. },
  499. /*我的联系人*/
  500. async myContactList() {
  501. this.myContacts.param.content.where.condition = this.form.name;
  502. this.myContacts.param.content.sys_enterpriseid =
  503. this.data.sys_enterpriseid;
  504. this.myContacts.param.content.ownerid = this.data.sys_enterpriseid;
  505. const res = await this.$api.requested(this.myContacts.param);
  506. this.myContacts.listData = res.data;
  507. this.myContacts.total = res.total;
  508. this.myContacts.currentPage = res.pageNumber;
  509. },
  510. /*选择我的联系人*/
  511. myContactSelect(val) {
  512. this.form.name = val.name;
  513. if (val.phonenumber.indexOf("-") != "-1") {
  514. this.form.isTelephone = "1";
  515. this.form.areaCode = val.phonenumber.substring(
  516. 0,
  517. val.phonenumber.indexOf("-")
  518. );
  519. this.form.telephone = val.phonenumber.substring(
  520. this.form.areaCode.length + 1
  521. );
  522. this.form.phonenumber = "";
  523. } else {
  524. this.form.isTelephone = "0";
  525. this.form.phonenumber = val.phonenumber;
  526. this.form.areaCode = "";
  527. this.form.telephone = "";
  528. }
  529. this.form.email = val.email;
  530. this.form.position = val.position;
  531. this.form.depname = val.depname;
  532. this.form.sex = val.sex;
  533. this.form.birthday = val.birthday;
  534. this.form.address = val.address;
  535. this.form.remarks = val.remarks;
  536. this.form.sys_phonebookid = val.sys_phonebookid;
  537. this.enterpriseContact.show = false;
  538. },
  539. inputChange(val) {
  540. this.form.name = val;
  541. },
  542. contactData(val) {
  543. this.form.name = val.name;
  544. if (val.phonenumber.indexOf("-") != "-1") {
  545. this.form.isTelephone = "1";
  546. this.form.areaCode = val.phonenumber.substring(
  547. 0,
  548. val.phonenumber.indexOf("-")
  549. );
  550. this.form.telephone = val.phonenumber.substring(
  551. this.form.areaCode.length + 1
  552. );
  553. this.form.phonenumber = "";
  554. } else {
  555. this.form.isTelephone = "0";
  556. this.form.phonenumber = val.phonenumber;
  557. this.form.areaCode = "";
  558. this.form.telephone = "";
  559. }
  560. this.form.email = val.email;
  561. this.form.position = val.position;
  562. this.form.depname = val.depname;
  563. this.form.sex = val.sex;
  564. this.form.birthday = val.birthday;
  565. this.form.address = val.address;
  566. this.form.remarks = val.remarks;
  567. this.form.sys_phonebookid = val.sys_phonebookid;
  568. },
  569. handleSizeChangeMy(val) {
  570. // console.log(`每页 ${val} 条`);
  571. this.myContacts.param.content.pageSize = val;
  572. this.myContactList();
  573. },
  574. handleCurrentChangeMy(val) {
  575. // console.log(`当前页: ${val}`);
  576. this.myContacts.param.content.pageNumber = val;
  577. this.myContactList();
  578. },
  579. onClose() {
  580. this.$refs["form"].resetFields();
  581. this.tags = [];
  582. this.form = {
  583. "sat_orderclue_contactsid": 0,
  584. "sys_phonebookid": '',
  585. "sat_orderclueid": '',
  586. "phonenumber": "",
  587. "birthday": "",
  588. "name": "",
  589. "depname": "",
  590. "wechatnum": "",
  591. "position": "",
  592. "email": "",
  593. "sex": "",
  594. "homeaddress": "",
  595. "remarks": "",
  596. "fax": "",
  597. "isleader": "",
  598. "grade": "",
  599. "hobby": "",
  600. "preference": "",
  601. "sys_phonebookgroupid": 0,
  602. "telephone": "",
  603. "isTelephone": "0",
  604. "areaCode": "",
  605. };
  606. this.dialogFormVisible = false;
  607. },
  608. async getTag() {
  609. this.paramTag.content.ownertable = "plm_unit";
  610. const res = await this.$api.requested(this.paramTag);
  611. this.tagList = res.data.option;
  612. },
  613. hasDisabledTag(item) {
  614. let arr = [];
  615. let arr2 = [];
  616. arr = this.tagList.filter((item) => {
  617. return this.tags.includes(item.tag);
  618. });
  619. arr.forEach((e) => {
  620. arr2 = arr2.concat(e.mutextag);
  621. });
  622. arr2 = this.tags.length === 0 ? [] : arr2;
  623. let _isSame = arr2.some((tag) => item.tag === tag);
  624. return _isSame;
  625. },
  626. },
  627. }
  628. </script>
  629. <style scoped>
  630. </style>