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.

312 lines
11 KiB

2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 months 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 year ago
2 months 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 months ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 months ago
2 months ago
2 years ago
2 months ago
2 years ago
1 year ago
2 months ago
1 year ago
2 months ago
2 years ago
2 months ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 months ago
2 years ago
1 year ago
2 years ago
2 months ago
2 years ago
2 years ago
2 months ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 months ago
2 years ago
2 years ago
2 years ago
2 months ago
2 years ago
2 months 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 style="width:208px">
  3. <div style="margin:2px 2px 2px 2px;display: flex;">
  4. <el-tooltip content="勾选时,可对子单位进行查询" placement="top">
  5. <el-checkbox style="margin-top: 6px;" v-model="cusQuery.haveSunCus" true-label="Y" false-label="N" size="small">
  6. 含子单位
  7. </el-checkbox>
  8. </el-tooltip>
  9. <el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small" />
  10. </div>
  11. <div>
  12. <el-tree
  13. :style="'overflow: scroll;height:' + (window.pageHeight < 600 ? 465 : window.pageHeight - 135) + 'px;width:200px;'"
  14. :data="customerOrgTreeAll" :props="treeprops" node-key="id" @node-contextmenu="nodeContextmenu"
  15. :filter-node-method="filterNode"
  16. @node-click="treeclick" highlight-current ref="customerOrgTree" :load="loadNode" lazy>
  17. <span class="custom-tree-node" slot-scope="{ node, data }">
  18. <div>
  19. <span class="treeicons">
  20. <!-- <i
  21. class="el-icon-document-remove"
  22. v-if="data.parentId == null"
  23. ></i> -->
  24. <img style="width:20px;height:20px;vertical-align: sub;" src="@/assets/images/order.png"
  25. v-if="!data.parentId" />
  26. </span>
  27. <span :class="!data.parentId ? 'maxtitle' : 'mintitle'">{{ node.label }}
  28. </span>
  29. </div>
  30. </span>
  31. </el-tree>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { mapState } from "vuex";
  37. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  38. import { tcdate, deepCopy, reMadeOrgTree, arrayExistObj } from "../../utlis/proFunc";
  39. import { madeTree, getTreeAllChildIdsById, getTreeNode } from "@/utlis/tree";
  40. export default {
  41. components: {},
  42. data() {
  43. return {
  44. filterText: '',
  45. treeprops: {
  46. label: "label",
  47. value: "id",
  48. id: "id",
  49. children: "treeChildren",
  50. isLeaf: "isLeaf"
  51. }, //树形组件的数据结构
  52. LocalConfig: {
  53. patientRegister: {
  54. dispCustomerOrgCode: 'N', // 人员登记列表--单位树是否显示 customerOrgCode
  55. }
  56. },
  57. customerOrgTreeAll: [],
  58. //作用于子单位查询
  59. cusQuery: {
  60. treeDataAll: [], //所有单位节点数据
  61. treeDataTop1: [], // 顶级单位
  62. haveSunCus: 'Y', // 默认查询不包含子单位
  63. times: 0, // 如果 times > 0 之后,来回勾选(含子单位查询时,不在查全部单位)
  64. }
  65. };
  66. },
  67. //<el-tree :data="$store.state.customerOrg.customerOrgTree" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree>
  68. computed: {
  69. ...mapState(["window", "dict", "dataTransOpts", "customerOrg", "patientRegister"]),
  70. },
  71. //创建组件后
  72. created() {
  73. this.patientRegister.customerOrgs = []
  74. try {
  75. let LocalConfig = JSON.parse(window.localStorage.getItem('LocalConfig'))
  76. if (LocalConfig && LocalConfig.patientRegister) {
  77. if (LocalConfig.patientRegister.dispCustomerOrgCode) this.LocalConfig.patientRegister.dispCustomerOrgCode = LocalConfig.patientRegister.dispCustomerOrgCode
  78. }
  79. } catch (error) {
  80. console.log("window.localStorage.getItem('LocalConfig')", error)
  81. }
  82. },
  83. //挂载组件完成
  84. mounted() {
  85. //获取体检单位列表树信息 (Y:查所有单位,N:仅查顶级单位)
  86. //从性能考滤 默认只查顶级单位
  87. if (this.cusQuery.haveSunCus == 'Y') {
  88. this.getCustomerOrgAll()
  89. .then(res => {
  90. this.customerOrgTreeAll = res
  91. this.patientRegister.customerOrgTreeAll = res
  92. // console.log('this.customerOrgTreeAll', this.customerOrgTreeAll)
  93. })
  94. } else {
  95. this.getCustomerOrgChild(null)
  96. .then(res => {
  97. this.customerOrgTreeAll = res
  98. this.patientRegister.customerOrgTreeAll = res
  99. // console.log('this.customerOrgTreeAll', this.customerOrgTreeAll)
  100. })
  101. }
  102. },
  103. methods: {
  104. // 查所有单位
  105. getCustomerOrgAll() {
  106. return new Promise((resolve, reject) => {
  107. getapi("/api/app/customerorg/getbycodeall")
  108. .then((res) => {
  109. if (res.code > -1) {
  110. let treeData = reMadeOrgTree(deepCopy(res.data), this.LocalConfig.patientRegister.dispCustomerOrgCode);
  111. this.cusQuery.times += 1
  112. //console.log('getCustomerOrgAll.treeData', treeData)
  113. //console.log('getTreeNode', getTreeNode(treeData, "treeChildren", 'id', '3a1d3736-d7c6-a9fb-c165-675335dc0e9b').treeChildren)
  114. this.cusQuery.treeDataAll = treeData
  115. resolve(treeData)
  116. } else {
  117. reject(res.message)
  118. }
  119. })
  120. .catch(err => {
  121. reject(err)
  122. })
  123. })
  124. },
  125. // 只查顶级单位
  126. getCustomerOrgChild(parentId) {
  127. return new Promise((resolve, reject) => {
  128. postapi('/api/app/CustomerOrg/GetCustomerOrgByParentId', { parentId })
  129. .then(res => {
  130. if (res.code > -1) {
  131. res.data.forEach(e => {
  132. e.isLeaf = e.isChild == 'Y' ? false : true
  133. });
  134. let treeData = reMadeOrgTree(deepCopy(res.data), this.LocalConfig.patientRegister.dispCustomerOrgCode);
  135. treeData.forEach(e => {
  136. if (arrayExistObj(this.patientRegister.customerOrgs, 'id', e.id) == -1) {
  137. this.patientRegister.customerOrgs.push(e)
  138. }
  139. });
  140. //this.patientRegister.customerOrgTreeAll = madeTree(this.patientRegister.customerOrgs, 'treeChildren', 'parentId', 'id', null)
  141. // console.log('this.patientRegister.customerOrgTreeAll', this.patientRegister.customerOrgTreeAll)
  142. if (!parentId) this.cusQuery.treeDataTop1 = treeData
  143. resolve(treeData)
  144. }
  145. })
  146. .catch(err => {
  147. reject(err)
  148. })
  149. })
  150. },
  151. // 树节点懒加载
  152. loadNode(node, resolve) {
  153. // console.log('node', node)
  154. // console.log('this.cusQuery.treeDataAll', this.cusQuery.treeDataAll)
  155. // console.log('this.patientRegister.customerOrgTreeAll1', this.patientRegister.customerOrgTreeAll)
  156. // 只显示顶级单
  157. if (node?.data?.id) {
  158. if (this.cusQuery.times == 0) {
  159. this.getCustomerOrgChild(node.data.id).then(res => {
  160. console.log('res', res)
  161. resolve(res)
  162. }).catch(err => {
  163. resolve([])
  164. })
  165. } else {
  166. let ret = getTreeNode(this.cusQuery.treeDataAll, this.treeprops.children, this.treeprops.children.id, node.data.id)[this.treeprops.children]
  167. ret = ret || []
  168. ret.forEach(e => {
  169. if (!e[this.treeprops.children]) e.isLeaf = true
  170. });
  171. //console.log('ret',ret)
  172. resolve(ret)
  173. }
  174. }
  175. },
  176. // 节点右击事件
  177. nodeContextmenu(event, data, node, ids) {
  178. console.log('event,data,node,ids', event, data, node, ids)
  179. if (data.id == this.dict.personOrgId) return
  180. let items = [
  181. {
  182. label: "置顶",
  183. onClick: () => {
  184. this.treeSort(data, 1);
  185. },
  186. },
  187. {
  188. label: "置底",
  189. onClick: () => {
  190. this.treeSort(data, 2);
  191. },
  192. }
  193. ] //菜单项
  194. this.$contextmenu({
  195. items,
  196. event,
  197. //x: event.clientX,
  198. //y: event.clientY,
  199. customClass: "custom-class",
  200. zIndex: 3,
  201. minWidth: 80,
  202. });
  203. return false;
  204. },
  205. // 树节点排序
  206. treeSort(data, sortType) {
  207. console.log('data', data)
  208. // if (data.parentId) {
  209. // this.$message.warning({ showClose: true, message: "请选择一级单位" })
  210. // return
  211. // }
  212. // console.log('data,sortType',data,sortType)
  213. putapi(`/api/app/customerorg/updatemanysort?id=${data.id}&SortType=${sortType}`).then(res => {
  214. if (res.code > -1) {
  215. //如果选的是子级排序,则只更新子级数据
  216. this.getCustomerOrgChild(data.parentId).then(res => {
  217. data.treeChildren = res
  218. if (data.parentId == null) {
  219. this.customerOrgTreeAll = res
  220. this.patientRegister.customerOrgTreeAll = deepCopy(res)
  221. }
  222. })
  223. }
  224. })
  225. },
  226. //顶级单位树过滤
  227. filterParentNode(value) {
  228. console.log('filterParentNode', value)
  229. // if (!value) return true;
  230. // return data['displayName'].indexOf(value) > -1 || data['simpleCode'].indexOf(value.toUpperCase()) > -1 || data['shortName'].indexOf(value) > -1 || data['customerOrgCode'].indexOf(value) > -1;
  231. this.customerOrgTreeAll = this.cusQuery.treeDataTop1.filter(e => {
  232. return e.label.indexOf(value) > -1 || e.simpleCode.indexOf(value.toUpperCase()) > -1 || e.shortName.indexOf(value) > -1
  233. })
  234. },
  235. //全树过滤
  236. filterNode(value, data) {
  237. console.log('filterNode', value, data)
  238. if (!value) return true;
  239. return data['displayName'].indexOf(value) !== -1 || data['simpleCode'].indexOf(value.toUpperCase()) !== -1;
  240. },
  241. //点击树节点
  242. treeclick(data) {
  243. // console.log('data',data)
  244. this.patientRegister.query.customerOrgId = data.id;
  245. this.patientRegister.query.customerOrgName = data.displayName;
  246. this.dataTransOpts.plus.PatientRegisterEditQuery++
  247. //获取体检单位父级ID
  248. // this.getCustomerOrgParentId(data.id);
  249. // this.patientRegister.query.times++; //用于触发查询条件
  250. },
  251. },
  252. watch: {
  253. "filterText": {
  254. // immediate: true,
  255. handler(newVal, oldVal) {
  256. // console.log(`watch 人员登记 newVal:${newVal} oldVal:${oldVal} registerCheckId: ${this.dataTransOpts.tableS.patient_register.id}`);
  257. if (newVal != oldVal) {
  258. if (this.cusQuery.haveSunCus == 'Y') {
  259. //this.customerOrgTreeAll = deepCopy(this.cusQuery.treeDataAll)
  260. this.$refs['customerOrgTree'].filter(newVal);
  261. } else {
  262. this.filterParentNode(newVal)
  263. }
  264. }
  265. }
  266. },
  267. // 勾选含子单位 查询所有单位
  268. "cusQuery.haveSunCus": {
  269. // immediate: true,
  270. handler(newVal, oldVal) {
  271. // console.log(`watch 人员登记 newVal:${newVal} oldVal:${oldVal} registerCheckId: ${this.dataTransOpts.tableS.patient_register.id}`);
  272. if (newVal != oldVal && newVal == 'Y' && this.cusQuery.times == 0) this.getCustomerOrgAll()
  273. }
  274. },
  275. },
  276. };
  277. </script>
  278. <style scoped>
  279. @import "../../assets/css/global_tree.css";
  280. .treeicons {
  281. font-size: 20px;
  282. margin-right: 5px;
  283. }
  284. :deep .el-tree-node>.el-tree-node__children {
  285. overflow: visible;
  286. }
  287. </style>