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.

289 lines
11 KiB

3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 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
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
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
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 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
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
3 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
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 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="contactPersonList" border :height="(window.pageHeight < 600 ? 100 : window.pageHeight - 400) / 2"
  6. size="small" highlight-current-row @row-click="rowClick" ref="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="contactMethodList" border :height="(window.pageHeight < 600 ? 100 : window.pageHeight - 400) / 2"
  28. size="small" highlight-current-row ref="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="btnAdd" class="commonbutton">新增联系人</el-button>
  58. </div>
  59. <div v-show="checkPagePriv(pagePriv.privs, '编辑联系人')" style="margin-top: 10px">
  60. <el-button type="success" @click="btnEdit" class="commonbutton">编辑联系人</el-button>
  61. </div>
  62. <div v-show="checkPagePriv(pagePriv.privs, '删除联系人')" style="margin-top: 10px">
  63. <el-button type="danger" @click="btnDel" class="deleteButton">删除联系人</el-button>
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 联系人 -->
  68. <el-dialog :title="`${dataTransOpts.tableS.contact_person.id ? '编辑' : '新增'}联系人`"
  69. :visible.sync="dialogWin.ContactPersonEdit" width="800px" @close="close_dialogWin_ContactPersonEdit">
  70. <ContactPersonEdit :refFunc="setData" />
  71. </el-dialog>
  72. </div>
  73. </template>
  74. <script>
  75. import moment from "moment";
  76. import { mapState } from "vuex";
  77. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  78. import { getPagePriv, checkPagePriv, objCopy, deepCopy, arrayExistObj, setData } from "../../utlis/proFunc";
  79. import ContactPersonEdit from '../../components/customerOrg/ContactPersonEdit.vue'
  80. export default {
  81. components: {
  82. ContactPersonEdit
  83. },
  84. props: ["customerOrgId"],
  85. data() {
  86. return {
  87. pagePriv: {
  88. routeUrlorPageName: 'customerOrg', //当前页面归属路由或归属页面权限名称
  89. privs: [] // 页面权限
  90. },
  91. curChooseRow: { id: "" }, // 当前选择联系人信息
  92. contactPersonList: [], // 联系人列表
  93. contactMethodList: [], // 联系方式列表
  94. };
  95. },
  96. created() {
  97. //获取用户当前页面的权限
  98. let userPriv = window.sessionStorage.getItem('userPriv')
  99. if (userPriv) this.pagePriv.privs = deepCopy(getPagePriv(this.pagePriv.routeUrlorPageName))
  100. },
  101. //挂载完成
  102. mounted() {
  103. this.getContactPersonList(this.dataTransOpts.tableS.customer_org.id)
  104. },
  105. computed: {
  106. ...mapState(["window", "customerOrg", "dialogWin", "dataTransOpts"]),
  107. },
  108. methods: {
  109. moment, checkPagePriv,
  110. //获取联系人列表
  111. getContactPersonList(customerOrgId) {
  112. if (!customerOrgId) {
  113. this.contactPersonList = [];
  114. this.contactMethodList = []
  115. return
  116. }
  117. getapi(
  118. `/api/app/contact-person/in-customer-org-id/${customerOrgId}`
  119. ).then((res) => {
  120. if (res.code != -1) {
  121. this.contactPersonList = res.data;
  122. if (res.data.length > 0) {
  123. this.getContactMethodList(res.data[0].id);
  124. } else {
  125. this.contactMethodList = [];
  126. }
  127. }
  128. });
  129. },
  130. //获取联系方式列表
  131. //api/app/contact-method/in-contact-person-id?ContactPersonId=3a0c08ad-4304-138b-d9e6-a7338739dfc4' \
  132. getContactMethodList(ContactPersonId) {
  133. if (!ContactPersonId) {
  134. this.contactMethodList = []
  135. return
  136. }
  137. getapi("/api/app/contact-method/in-contact-person-id", {
  138. ContactPersonId,
  139. }).then((res) => {
  140. //console.log('res.data',res.data)
  141. this.contactMethodList = res.data;
  142. });
  143. },
  144. //联系人 相关操作
  145. btnAdd() {
  146. //console.log("新增 addContactPerson");
  147. if (!this.dataTransOpts.tableS.customer_org.id) {
  148. this.$message.warning({ showClose: true, message: "没有体检单位信息"});
  149. return;
  150. }
  151. this.dataTransOpts.tableS.contact_person.id = ''
  152. this.dialogWin.ContactPersonEdit = true;
  153. setTimeout(() => {
  154. this.dataTransOpts.refresh.contact_person.S++
  155. }, 10);
  156. },
  157. btnEdit() {
  158. //console.log("编辑 editContactPerson");
  159. // console.log('this.customerOrgId',this.customerOrgId)
  160. if (!this.dataTransOpts.tableS.customer_org.id) {
  161. this.$message.warning({ showClose: true, message: "没有体检单位信息"});
  162. return;
  163. } else if (!this.dataTransOpts.tableS.contact_person.id) {
  164. this.$message.warning({ showClose: true, message: "请先选择要编辑的联系人"});
  165. return;
  166. }
  167. this.dialogWin.ContactPersonEdit = true;
  168. this.dataTransOpts.refresh.contact_person.S++
  169. },
  170. //删除联系人行
  171. btnDel() {
  172. //console.log("删除 delContactPerson");
  173. if (!this.dataTransOpts.tableS.contact_person.id) {
  174. this.$message.warning({ showClose: true, message: "请先选择要编辑的联系人"});
  175. return;
  176. }
  177. this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
  178. confirmButtonText: "是",
  179. cancelButtonText: "否",
  180. type: "warning",
  181. }).then(() => {
  182. //console.log('{patientRegisterIds}',{patientRegisterIds})
  183. return deletapi(`/api/app/contact-person/${this.dataTransOpts.tableS.contact_person.id}`);
  184. }).then((res) => {
  185. if (res.code != -1) {
  186. let lfind = arrayExistObj(this.contactPersonList, 'id', this.dataTransOpts.tableS.contact_person.id)
  187. if (lfind > -1) this.contactPersonList.splice(lfind, 1)
  188. this.dataTransOpts.tableS.contact_person.id = "";
  189. setTimeout(() => {
  190. this.dataTransOpts.refresh.contact_method.M++
  191. }, 10);
  192. console.log("操作成功!");
  193. }
  194. }).catch((err) => {
  195. if (err == "cancel") console.log("已取消删除");
  196. });
  197. },
  198. // 设置 data 对象的值(暂时支持到7级),供子组件调用
  199. setData(item, v) {
  200. setData(this, item, v)
  201. console.log('父函数 this.curChooseRow,v', this.curChooseRow, item, v)
  202. },
  203. //新增或编辑后选中记录
  204. close_dialogWin_ContactPersonEdit() {
  205. let personId = this.curChooseRow.id
  206. if (this.dataTransOpts.tableS.contact_person.id) personId = this.dataTransOpts.tableS.contact_person.id
  207. console.log('close_dialogWin_ContactPersonEdit',personId,this.dataTransOpts.tableS.contact_person.id)
  208. if (personId) {
  209. let currentRow = {}
  210. let lfind = arrayExistObj(this.contactPersonList, 'id', personId)
  211. if (lfind > -1) {
  212. objCopy(this.curChooseRow, this.contactPersonList[lfind])
  213. currentRow = this.contactPersonList[lfind]
  214. } else{
  215. currentRow = deepCopy(this.curChooseRow)
  216. this.contactPersonList.push(currentRow)
  217. }
  218. setTimeout(() => {
  219. this.dataTransOpts.refresh.contact_method.M++
  220. this.$refs['contactPersonList'].setCurrentRow()
  221. this.$refs['contactPersonList'].setCurrentRow(currentRow)
  222. }, 10)
  223. }
  224. },
  225. rowClick(row) {
  226. this.curChooseRow = deepCopy(row)
  227. this.dataTransOpts.tableS.contact_person.id = row.id
  228. setTimeout(() => {
  229. this.dataTransOpts.refresh.contact_method.M++
  230. }, 20);
  231. },
  232. },
  233. watch: {
  234. // 单位id未变时,强制刷新
  235. "dataTransOpts.refresh.contact_person.M": {
  236. // immediate: true,
  237. handler(newVal, oldVal) {
  238. console.log(`watch 联系人 newVal:${newVal} oldVal:${oldVal} customerOrgId: ${this.dataTransOpts.tableS.customer_org.id}`);
  239. this.getContactPersonList(this.dataTransOpts.tableS.customer_org.id)
  240. }
  241. },
  242. // 单位id未变时,强制刷新
  243. "dataTransOpts.refresh.contact_method.M": {
  244. // immediate: true,
  245. handler(newVal, oldVal) {
  246. console.log(`watch 联系方式 newVal:${newVal} oldVal:${oldVal} contactPersonId: ${this.dataTransOpts.tableS.contact_person.id}`);
  247. // this.getContactPersonList(this.dataTransOpts.tableS.contact_person.id)
  248. this.getContactMethodList(this.dataTransOpts.tableS.contact_person.id);
  249. }
  250. },
  251. // 'customerOrgId' (newVal,oldVal){
  252. // console.log('watch customerOrgId',newVal,oldVal)
  253. // if(newVal != oldVal){
  254. // this.personId = ''
  255. // }
  256. // }
  257. },
  258. };
  259. </script>
  260. <style scoped>
  261. @import '../../assets/css/global_table.css';
  262. @import '../../assets/css/global_input.css';
  263. @import '../../assets/css/global_form.css';
  264. .btnClass {
  265. width: 110px;
  266. }
  267. </style>