You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

472 lines
18 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <div style="display: flex;">
  4. <div :style="'width:' + (window.pageWidth - 200 - 110 - 25) + 'px;'">
  5. <el-table :data="customerOrg.contactPersonList" border :height="(window.pageHeight < 600 ? 100:window.pageHeight - 400)/2"
  6. size="small" highlight-current-row @row-click="rowClick" ref="customerOrg.contactPersonList">
  7. <el-table-column prop="displayName" label="姓名" min-width="70" align="center"/>
  8. <el-table-column prop="title" label="职务" min-width="70" align="center"/>
  9. <el-table-column prop="remark" label="备注" min-width="150" align="center"/>
  10. <el-table-column prop="creatorName" label="创建者" min-width="70" align="center" />
  11. <el-table-column prop="creationTime" label="创建时间" min-width="120" align="center">
  12. <template slot-scope="scope">
  13. <div v-if="scope.row.creationTime">
  14. {{ moment(scope.row.creationTime).format('yyyy-MM-DD HH:mm:ss') }}
  15. </div>
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="lastModifierName" label="修改者" min-width="70" align="center"/>
  19. <el-table-column prop="lastModificationTime" label="修改时间" min-width="120" align="center">
  20. <template slot-scope="scope">
  21. <div v-if="scope.row.lastModificationTime">
  22. {{ moment(scope.row.lastModificationTime).format('yyyy-MM-DD HH:mm:ss') }}
  23. </div>
  24. </template>
  25. </el-table-column>
  26. </el-table>
  27. <el-table :data="customerOrg.contactMethodList" border :height="(window.pageHeight < 600 ? 100:window.pageHeight - 400)/2"
  28. size="small" highlight-current-row @row-click="rowClickMethod" ref="customerOrg.contactMethodList">
  29. <el-table-column prop="contactMethodType" label="类型" width="60" align="center">
  30. <template slot-scope="scope">
  31. <div>
  32. {{ scope.row.contactMethodType === "0" ? "手机" : "邮箱" }}
  33. </div>
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="contactMethodValue" label="联系方式" min-width="120" align="center"/>
  37. <el-table-column prop="creatorName" label="创建者" min-width="70" align="center" />
  38. <el-table-column prop="creationTime" label="创建时间" min-width="120" align="center">
  39. <template slot-scope="scope">
  40. <div v-if="scope.row.creationTime">
  41. {{ moment(scope.row.creationTime).format('yyyy-MM-DD HH:mm:ss') }}
  42. </div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column prop="lastModifierName" label="修改者" min-width="70" align="center"/>
  46. <el-table-column prop="lastModificationTime" label="修改时间" min-width="120" align="center">
  47. <template slot-scope="scope">
  48. <div v-if="scope.row.lastModificationTime">
  49. {{ moment(scope.row.lastModificationTime).format('yyyy-MM-DD HH:mm:ss') }}
  50. </div>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. </div>
  55. <div style="margin-left: 10px; margin-top: 20px">
  56. <div v-show="checkPagePriv(pagePriv.privs,'新增联系人')" style="margin-top: 10px">
  57. <el-button type="primary" @click="add" class="commonbutton">新增联系人</el-button>
  58. </div>
  59. <div v-show="checkPagePriv(pagePriv.privs,'编辑联系人')" style="margin-top: 10px">
  60. <el-button type="success" @click="edit" class="commonbutton">编辑联系人</el-button>
  61. </div>
  62. <div v-show="checkPagePriv(pagePriv.privs,'删除联系人')" style="margin-top: 10px">
  63. <el-button type="danger" @click="del" class="commonbutton">删除联系人</el-button>
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 联系人 -->
  68. <el-dialog :title="formTitle" :visible.sync="dialogContactPerson" width="800px" @close="closeDialogPerson">
  69. <el-form :model="form" ref="form" label-width="70px" :rules="rules" style="margin-top: -30px;">
  70. <el-row>
  71. <el-col :span="12">
  72. <el-form-item prop="displayName" label="联系人">
  73. <el-input v-model="form.displayName" size="small"></el-input>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="12">
  77. <el-form-item label="职务">
  78. <el-input v-model="form.title" size="small"></el-input>
  79. </el-form-item>
  80. </el-col>
  81. <el-col :span="24">
  82. <el-form-item label="备注">
  83. <el-input type="textarea" v-model="form.remark" size="small" maxlength="50" show-word-limit></el-input>
  84. </el-form-item>
  85. </el-col>
  86. </el-row>
  87. <el-row>
  88. <el-col :span="5">
  89. <el-form-item label="创建者">
  90. <el-input v-model="form.creatorName" disabled size="small"></el-input>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="7">
  94. <el-form-item label="创建时间" label-width="80px" style="margin-left:-10px;">
  95. <el-date-picker v-model="form.creationTime" type="datetime" size="small" style="width: 100%" disabled />
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="5">
  99. <el-form-item label="修改者" >
  100. <el-input v-model="form.creatorName" disabled size="small"></el-input>
  101. </el-form-item>
  102. </el-col>
  103. <el-col :span="7">
  104. <el-form-item label="修改时间" label-width="80px" style="margin-left:-10px;">
  105. <el-date-picker v-model="form.lastModificationTime" type="datetime" size="small" style="width: 100%"
  106. disabled />
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. <el-table :data="contactMethodListEdit" border height="300" row-key="id" size="small"
  111. highlight-current-row ref="contactMethod" style="margin-top: 20px;">
  112. <el-table-column prop="contactMethodType" label="类型" width="200">
  113. <template slot-scope="scope">
  114. <el-select v-model="scope.row.contactMethodType" size="small">
  115. <el-option v-for="item in Methodtypes" :key="item.value" :label="item.label" :value="item.value" />
  116. </el-select>
  117. </template>
  118. </el-table-column>
  119. <el-table-column prop="contactMethodValue" label="联系方式">
  120. <template slot-scope="scope">
  121. <el-input v-model="scope.row.contactMethodValue" required size="small" />
  122. </template>
  123. </el-table-column>
  124. <el-table-column fixed="right" label="操作" width="60" align="center">
  125. <template slot-scope="scope">
  126. <i class="el-icon-delete" @click="deleteRow(scope.$index)"
  127. style="font-size: 24px;color: red;cursor:pointer;"></i>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. </el-form>
  132. <span slot="footer" class="dialog-footer">
  133. <el-button class="commonbutton" @click="dialogContactPerson = false"> </el-button>
  134. <el-button type="success" class="commonbutton" @click="addMethod">新增联系方式</el-button>
  135. <el-button type="primary" class="commonbutton" @click="submit('form')"> </el-button>
  136. </span>
  137. </el-dialog>
  138. </div>
  139. </template>
  140. <script>
  141. import moment from "moment";
  142. import { mapState } from "vuex";
  143. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  144. import { getPagePriv,checkPagePriv,objCopy, deepCopy, arrayExistObj } from "../../utlis/proFunc";
  145. export default {
  146. components: {},
  147. props:["customerOrgId"],
  148. data() {
  149. return {
  150. pagePriv:{
  151. routeUrlorPageName:'customerOrg', //当前页面归属路由或归属页面权限名称
  152. privs:[] // 页面权限
  153. },
  154. personId: "",
  155. form: {}, //联系人表单信息
  156. contactMethodListEdit:[], //联系方式(可修改)
  157. formTitle: "新增",
  158. dialogContactPerson: false, //联系人弹窗 显示控制
  159. Methodtypes: [
  160. //{ value: '',label: '所有订单状态' },
  161. { value: "0", label: "电话" },
  162. { value: "1", label: "邮箱" },
  163. ],
  164. rules: {
  165. displayName: [
  166. { required: true, message: "请输入名称", trigger: "blur" },
  167. ],
  168. },
  169. };
  170. },
  171. created() {
  172. //获取用户当前页面的权限
  173. let userPriv = window.sessionStorage.getItem('userPriv')
  174. if(userPriv) this.pagePriv.privs = deepCopy(getPagePriv(this.pagePriv.routeUrlorPageName))
  175. },
  176. //挂载完成
  177. mounted() {
  178. this.getContactPersonList(this.dataTransOpts.tableS.customer_org.id)
  179. },
  180. computed: {
  181. ...mapState(["window", "customerOrg","dataTransOpts"]),
  182. },
  183. methods: {
  184. moment,checkPagePriv,
  185. //获取联系人列表
  186. getContactPersonList(customerOrgId) {
  187. if(!customerOrgId){
  188. this.customerOrg.contactPersonList = [];
  189. this.customerOrg.contactMethodList = []
  190. return
  191. }
  192. getapi(
  193. `/api/app/contact-person/in-customer-org-id/${customerOrgId}`
  194. ).then((res) => {
  195. if(res.code != -1){
  196. this.customerOrg.contactPersonList = res.data;
  197. if (res.data.length > 0) {
  198. this.getContactMethodList(res.data[0].id);
  199. } else {
  200. this.customerOrg.contactMethodList = [];
  201. }
  202. }
  203. });
  204. },
  205. //获取联系方式列表
  206. //api/app/contact-method/in-contact-person-id?ContactPersonId=3a0c08ad-4304-138b-d9e6-a7338739dfc4' \
  207. getContactMethodList(ContactPersonId) {
  208. getapi("/api/app/contact-method/in-contact-person-id", {
  209. ContactPersonId,
  210. }).then((res) => {
  211. //console.log('res.data',res.data)
  212. this.customerOrg.contactMethodList = res.data;
  213. this.contactMethodListEdit = deepCopy(res.data);
  214. });
  215. },
  216. //联系人 相关操作
  217. add() {
  218. //console.log("新增 addContactPerson");
  219. if (!this.customerOrgId) {
  220. this.$message.warning("没有体检单位信息");
  221. return;
  222. }
  223. this.form = { customerOrgId: this.customerOrgId };
  224. this.dialogContactPerson = true;
  225. this.formTitle = "新增";
  226. this.personId = "";
  227. this.customerOrg.contactMethodList = [];
  228. this.contactMethodListEdit = [];
  229. },
  230. edit() {
  231. //console.log("编辑 editContactPerson");
  232. console.log('this.customerOrgId',this.customerOrgId)
  233. if (!this.customerOrgId) {
  234. this.$message.warning("没有体检单位信息");
  235. return;
  236. } else if (!this.personId) {
  237. this.$message.warning("请先选择要编辑的联系人");
  238. return;
  239. }
  240. this.dialogContactPerson = true;
  241. this.formTitle = "编辑";
  242. },
  243. //删除联系人行
  244. del() {
  245. //console.log("删除 delContactPerson");
  246. if (!this.personId) {
  247. this.$message.warning("请先选择要编辑的联系人");
  248. return;
  249. }
  250. this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
  251. confirmButtonText: "是",
  252. cancelButtonText: "否",
  253. type: "warning",
  254. }).then(() => {
  255. //console.log('{patientRegisterIds}',{patientRegisterIds})
  256. return deletapi(`/api/app/contact-person/${this.personId}`);
  257. }).then((res) => {
  258. if(res.code != -1) {
  259. this.personId = "";
  260. this.getContactPersonList(this.customerOrg.customerOrgId);
  261. this.customerOrg.contactMethodList = [];
  262. console.log("操作成功!");
  263. }
  264. }).catch((err) => {
  265. if (err == "cancel") {
  266. this.$message.info("已取消删除");
  267. }
  268. });
  269. },
  270. //删除联系方式行
  271. deleteRow(index) {
  272. this.$confirm("此操作确定后将永久删除该记录, 是否继续?", "提示", {
  273. confirmButtonText: "是",
  274. cancelButtonText: "否",
  275. type: "warning",
  276. }).then(() => {
  277. this.contactMethodListEdit.splice(index, 1);
  278. //this.submit('form');
  279. }).catch((err) => {
  280. if(err == 'cancel'){
  281. this.$message.info("已取消删除");
  282. }
  283. });
  284. },
  285. //联系人信息提交
  286. submit(formName) {
  287. let body = {
  288. customerOrgId: "",
  289. displayName: "",
  290. title: "",
  291. remark: "",
  292. };
  293. this.$refs[formName].validate((valid, fields) => {
  294. if (!valid){
  295. this.$message.warning(fields[Object.keys(fields)[0]][0].message);
  296. return false;
  297. }
  298. objCopy(this.form, body);
  299. console.log("body", body);
  300. if (this.formTitle == "新增") {
  301. postapi("/api/app/contact-person", body)
  302. .then((res) => {
  303. //console.log('api/app/contact-person')
  304. if(res.code != -1){
  305. this.form.id = res.data.id;
  306. this.personId = res.data.id;
  307. this.formTitle = "编辑";
  308. return deletapi(`/api/app/contact-method/many/${this.personId}`);
  309. }
  310. })
  311. .then((res) => {
  312. //console.log(`deletapi api/app/contact-method/${this.personId}`)
  313. if(res.code != -1){
  314. let contactMethod = []; //联系方式form表单数据
  315. this.contactMethodListEdit.forEach( item => {
  316. contactMethod.push({
  317. contactMethodValue: item.contactMethodValue,
  318. contactMethodType: item.contactMethodType,
  319. contactPersonId: this.personId,
  320. });
  321. });
  322. if(contactMethod.length > 0){
  323. return postapi("/api/app/contact-method/many", contactMethod);
  324. }else{
  325. this.dialogContactPerson = false
  326. }
  327. }
  328. })
  329. .then((res) => {
  330. //console.log('api/app/contact-method/many')
  331. //this.getContactPersonList(this.customerOrgId); //改成局部刷新
  332. if(res.code != -1){
  333. this.getContactMethodList(this.form.id)
  334. console.log("操作成功!");
  335. this.dialogContactPerson = false
  336. }
  337. });
  338. } else {
  339. putapi(`/api/app/contact-person/${this.personId}`, body)
  340. .then((res) => {
  341. //console.log(`/api/app/contact-person/${this.personId}`)
  342. if(res.code != -1){
  343. return deletapi(`/api/app/contact-method/many/${this.personId}`);
  344. }
  345. })
  346. .then((res) => {
  347. console.log(`deletapi api/app/contact-method/${this.personId}`);
  348. if(res.code != -1){
  349. let contactMethod = []; //联系方式form表单数据
  350. this.contactMethodListEdit.forEach((item, index) => {
  351. contactMethod.push({
  352. contactMethodValue: item.contactMethodValue,
  353. contactMethodType: item.contactMethodType,
  354. contactPersonId: this.personId,
  355. });
  356. });
  357. if(contactMethod.length > 0){
  358. return postapi("/api/app/contact-method/many", contactMethod);
  359. }else{
  360. this.dialogContactPerson = false
  361. }
  362. }
  363. })
  364. .then((res) => {
  365. //console.log('api/app/contact-method/many')
  366. //this.getContactPersonList(this.customerOrgId); //改成局部刷新
  367. if(res.code != -1){
  368. this.getContactMethodList(this.form.id)
  369. console.log("操作成功!");
  370. this.dialogContactPerson = false
  371. }
  372. });
  373. }
  374. })
  375. },
  376. //新增或编辑后选中记录
  377. closeDialogPerson(){
  378. let currentRow = {}
  379. let lfind = arrayExistObj(this.customerOrg.contactPersonList,'id',this.form.id)
  380. if(lfind > -1){
  381. objCopy(this.form,this.customerOrg.contactPersonList[lfind])
  382. currentRow = this.customerOrg.contactPersonList[lfind]
  383. }else if(this.form.id){
  384. currentRow = deepCopy(this.form)
  385. lfind = this.customerOrg.contactPersonList.length
  386. this.customerOrg.contactPersonList.push(currentRow)
  387. }
  388. if(lfind > -1){
  389. setTimeout(() => {
  390. this.$refs['customerOrg.contactPersonList'].setCurrentRow(currentRow)
  391. }, 100)
  392. }
  393. },
  394. //新增联系方式
  395. addMethod() {
  396. this.contactMethodListEdit.push({
  397. contactMethodValue: "",
  398. contactMethodType: "0",
  399. contactPersonId: this.personId,
  400. });
  401. },
  402. rowClick(row) {
  403. console.log("row", row);
  404. // console.log("rowClick");
  405. this.form = deepCopy(row);
  406. this.personId = row.id;
  407. this.getContactMethodList(row.id);
  408. },
  409. rowClickMethod(row) {
  410. //console.log("rowClickMethod");
  411. },
  412. },
  413. watch: {
  414. // 单位id未变时,强制刷新
  415. "dataTransOpts.refresh.contact_person.M": {
  416. // immediate: true,
  417. handler(newVal, oldVal) {
  418. console.log(`watch 联系人 newVal:${newVal} oldVal:${oldVal} customerOrgId: ${this.dataTransOpts.tableS.customer_org.id}`);
  419. this.getContactPersonList(this.dataTransOpts.tableS.customer_org.id)
  420. }
  421. },
  422. // 'customerOrgId' (newVal,oldVal){
  423. // console.log('watch customerOrgId',newVal,oldVal)
  424. // if(newVal != oldVal){
  425. // this.personId = ''
  426. // }
  427. // }
  428. },
  429. };
  430. </script>
  431. <style scoped>
  432. @import '../../assets/css/global_table.css';
  433. @import '../../assets/css/global_input.css';
  434. @import '../../assets/css/global_form.css';
  435. .btnClass {
  436. width: 110px;
  437. }
  438. </style>