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.

365 lines
12 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
1 month 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 weeks ago
2 months ago
1 month 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 weeks ago
2 months ago
2 weeks ago
2 months ago
2 years ago
2 weeks ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 weeks ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
1 month ago
2 months ago
2 weeks ago
2 months ago
1 month ago
2 weeks ago
1 month ago
1 month ago
2 weeks ago
1 month ago
2 weeks ago
2 months ago
2 weeks ago
1 month ago
2 months ago
2 years ago
1 month ago
1 month ago
2 weeks ago
1 month ago
2 years ago
1 month 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 weeks 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
1 month 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" @node-click="treeclick" highlight-current ref="customerOrgTree"
  16. :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, updateDBCom, getDBCom } from "../../utlis/proFunc";
  39. import { madeTree, getTreeAllChildIdsById, getTreeNode } from "@/utlis/tree";
  40. import { now } from "moment";
  41. export default {
  42. components: {},
  43. data() {
  44. return {
  45. filterText: '',
  46. treeprops: {
  47. label: "label",
  48. value: "id",
  49. id: "id",
  50. children: "treeChildren",
  51. isLeaf: "isLeaf"
  52. }, //树形组件的数据结构
  53. LocalConfig: {
  54. patientRegister: {
  55. dispCustomerOrgCode: 'N', // 人员登记列表--单位树是否显示 customerOrgCode
  56. }
  57. },
  58. customerOrgTreeAll: [], //显示的
  59. orgDatas: [], // 最初获取的
  60. //作用于子单位查询
  61. cusQuery: {
  62. treeDataAll: [], //所有单位节点数据
  63. treeDataTop1: [], // 顶级单位
  64. haveSunCus: 'Y', // 默认查询不包含子单位
  65. times: 0, // 如果 times > 0 之后,来回勾选(含子单位查询时,不在查全部单位)
  66. }
  67. };
  68. },
  69. computed: {
  70. ...mapState(["window", "dict", "dataTransOpts", "customerOrg", "patientRegister"]),
  71. },
  72. //创建组件后
  73. created() {
  74. this.patientRegister.customerOrgs = []
  75. try {
  76. let LocalConfig = JSON.parse(window.localStorage.getItem('LocalConfig'))
  77. if (LocalConfig && LocalConfig.patientRegister) {
  78. if (LocalConfig.patientRegister.dispCustomerOrgCode) this.LocalConfig.patientRegister.dispCustomerOrgCode = LocalConfig.patientRegister.dispCustomerOrgCode
  79. }
  80. } catch (error) {
  81. console.log("window.localStorage.getItem('LocalConfig')", error)
  82. }
  83. },
  84. //挂载组件完成
  85. mounted() {
  86. //获取体检单位列表树信息 (Y:查所有单位,N:仅查顶级单位)
  87. //从性能考滤 默认只查顶级单位
  88. if (this.cusQuery.haveSunCus == 'Y') {
  89. this.getCustomerOrgAll()
  90. .then(res => {
  91. this.customerOrgTreeAll = res
  92. this.patientRegister.customerOrgTreeAll = res
  93. // console.log('this.customerOrgTreeAll', this.customerOrgTreeAll)
  94. })
  95. } else {
  96. //console.log('new Date()1', now())
  97. this.getCustomerOrgChild(null)
  98. .then(res => {
  99. this.customerOrgTreeAll = res //.slice(0,3)
  100. this.patientRegister.customerOrgTreeAll = res
  101. // console.log('this.customerOrgTreeAll', this.customerOrgTreeAll)
  102. //console.log('new Date()2', now())
  103. })
  104. }
  105. },
  106. methods: {
  107. // 后续代完善
  108. getOrgDatas() {
  109. return new Promise((resolve, reject) => {
  110. let url = '/api/app/CustomerOrg/GetSimpleByCodeAll'
  111. if (this.LocalConfig.patientRegister.dispCustomerOrgCode == 'Y') {
  112. url = "/api/app/customerorg/getbycodeall"
  113. getapi(url)
  114. .then((res) => {
  115. if (res.code > -1) {
  116. this.orgDatas = res.data
  117. updateDBCom('orgDatas',res.data) //存本地
  118. resolve()
  119. } else {
  120. reject(res.message)
  121. }
  122. })
  123. .catch(err => {
  124. reject(err)
  125. })
  126. } else {
  127. postapi(url)
  128. .then((res) => {
  129. if (res.code > -1) {
  130. this.orgDatas = res.data
  131. updateDBCom('orgDatas',res.data)
  132. resolve()
  133. } else {
  134. reject(res.message)
  135. }
  136. })
  137. .catch(err => {
  138. reject(err)
  139. })
  140. }
  141. })
  142. },
  143. // 查所有单位
  144. getCustomerOrgAll() {
  145. return new Promise((resolve, reject) => {
  146. if (this.dataTransOpts.orgDatas.length > 0) {
  147. let treeData = reMadeOrgTree(deepCopy(this.dataTransOpts.orgDatas), this.LocalConfig.patientRegister.dispCustomerOrgCode);
  148. this.cusQuery.times += 1
  149. //console.log('getCustomerOrgAll.treeData', treeData)
  150. //console.log('getTreeNode', getTreeNode(treeData, "treeChildren", 'id', '3a1d3736-d7c6-a9fb-c165-675335dc0e9b').treeChildren)
  151. this.cusQuery.treeDataAll = treeData
  152. resolve(treeData)
  153. } else {
  154. this.getOrgDatas()
  155. .then(() => {
  156. let treeData = reMadeOrgTree(deepCopy(this.dataTransOpts.orgDatas), this.LocalConfig.patientRegister.dispCustomerOrgCode);
  157. this.cusQuery.times += 1
  158. //console.log('getCustomerOrgAll.treeData', treeData)
  159. //console.log('getTreeNode', getTreeNode(treeData, "treeChildren", 'id', '3a1d3736-d7c6-a9fb-c165-675335dc0e9b').treeChildren)
  160. this.cusQuery.treeDataAll = treeData
  161. resolve(treeData)
  162. })
  163. .catch(err => {
  164. reject(err)
  165. })
  166. }
  167. })
  168. },
  169. // 只查顶级单位
  170. getCustomerOrgChild(parentId) {
  171. return new Promise((resolve, reject) => {
  172. console.log('new Date()3', now())
  173. let url = '/api/app/CustomerOrg/GetCustomerOrgSimpleByParentId'
  174. if (this.LocalConfig.patientRegister.dispCustomerOrgCode == 'Y') {
  175. url = '/api/app/CustomerOrg/GetCustomerOrgByParentId'
  176. }
  177. postapi(url, { parentId })
  178. .then(res => {
  179. if (res.code > -1) {
  180. console.log('new Date()4', now())
  181. res.data.forEach(e => {
  182. e.isLeaf = e.isChild == 'Y' ? false : true
  183. });
  184. let treeData = reMadeOrgTree(deepCopy(res.data), this.LocalConfig.patientRegister.dispCustomerOrgCode);
  185. treeData.forEach(e => {
  186. if (arrayExistObj(this.patientRegister.customerOrgs, 'id', e.id) == -1) {
  187. this.patientRegister.customerOrgs.push(e)
  188. }
  189. });
  190. //this.patientRegister.customerOrgTreeAll = madeTree(this.patientRegister.customerOrgs, 'treeChildren', 'parentId', 'id', null)
  191. // console.log('this.patientRegister.customerOrgTreeAll', this.patientRegister.customerOrgTreeAll)
  192. if (!parentId) this.cusQuery.treeDataTop1 = treeData
  193. resolve(treeData)
  194. }
  195. })
  196. .catch(err => {
  197. reject(err)
  198. })
  199. })
  200. },
  201. // 树节点懒加载
  202. loadNode(node, resolve) {
  203. // console.log('node', node)
  204. // console.log('this.cusQuery.treeDataAll', this.cusQuery.treeDataAll)
  205. // console.log('this.patientRegister.customerOrgTreeAll1', this.patientRegister.customerOrgTreeAll)
  206. // 只显示顶级单
  207. if (node?.data?.id) {
  208. if (this.cusQuery.times == 0) {
  209. this.getCustomerOrgChild(node.data.id).then(res => {
  210. console.log('res', res)
  211. resolve(res)
  212. }).catch(err => {
  213. resolve([])
  214. })
  215. } else {
  216. let ret = getTreeNode(this.cusQuery.treeDataAll, this.treeprops.children, this.treeprops.children.id, node.data.id)[this.treeprops.children]
  217. ret = ret || []
  218. ret.forEach(e => {
  219. if (!e[this.treeprops.children]) e.isLeaf = true
  220. });
  221. //console.log('ret',ret)
  222. resolve(ret)
  223. }
  224. }
  225. },
  226. // 节点右击事件
  227. nodeContextmenu(event, data, node, ids) {
  228. console.log('event,data,node,ids', event, data, node, ids)
  229. if (data.id == this.dict.personOrgId) return
  230. let items = [
  231. {
  232. label: "置顶",
  233. onClick: () => {
  234. this.treeSort(data, 1);
  235. },
  236. },
  237. {
  238. label: "置底",
  239. onClick: () => {
  240. this.treeSort(data, 2);
  241. },
  242. }
  243. ] //菜单项
  244. this.$contextmenu({
  245. items,
  246. event,
  247. //x: event.clientX,
  248. //y: event.clientY,
  249. customClass: "custom-class",
  250. zIndex: 3,
  251. minWidth: 80,
  252. });
  253. return false;
  254. },
  255. // 树节点排序
  256. treeSort(data, sortType) {
  257. console.log('data', data)
  258. // if (data.parentId) {
  259. // this.$message.warning({ showClose: true, message: "请选择一级单位" })
  260. // return
  261. // }
  262. // console.log('data,sortType',data,sortType)
  263. putapi(`/api/app/customerorg/updatemanysort?id=${data.id}&SortType=${sortType}`).then(res => {
  264. if (res.code > -1) {
  265. //如果选的是子级排序,则只更新子级数据
  266. this.getCustomerOrgChild(data.parentId).then(res => {
  267. data.treeChildren = res
  268. if (data.parentId == null) {
  269. this.customerOrgTreeAll = res
  270. this.patientRegister.customerOrgTreeAll = deepCopy(res)
  271. }
  272. })
  273. }
  274. })
  275. },
  276. //顶级单位树过滤
  277. filterParentNode(value) {
  278. console.log('filterParentNode', value)
  279. // if (!value) return true;
  280. // return data['displayName'].indexOf(value) > -1 || data['simpleCode'].indexOf(value.toUpperCase()) > -1 || data['shortName'].indexOf(value) > -1 || data['customerOrgCode'].indexOf(value) > -1;
  281. this.customerOrgTreeAll = this.cusQuery.treeDataTop1.filter(e => {
  282. return e.label.indexOf(value) > -1 || e.simpleCode.indexOf(value.toUpperCase()) > -1
  283. })
  284. },
  285. //全树过滤
  286. filterNode(value, data) {
  287. console.log('filterNode', value, data)
  288. if (!value) return true;
  289. return data['displayName'].indexOf(value) !== -1 || data['simpleCode'].indexOf(value.toUpperCase()) !== -1;
  290. },
  291. //点击树节点
  292. treeclick(data) {
  293. // console.log('data',data)
  294. this.patientRegister.query.customerOrgId = data.id;
  295. this.patientRegister.query.customerOrgName = data.displayName;
  296. this.dataTransOpts.plus.PatientRegisterEditQuery++
  297. //获取体检单位父级ID
  298. // this.getCustomerOrgParentId(data.id);
  299. // this.patientRegister.query.times++; //用于触发查询条件
  300. },
  301. },
  302. watch: {
  303. "filterText": {
  304. // immediate: true,
  305. handler(newVal, oldVal) {
  306. // console.log(`watch 人员登记 newVal:${newVal} oldVal:${oldVal} registerCheckId: ${this.dataTransOpts.tableS.patient_register.id}`);
  307. if (newVal != oldVal) {
  308. if (this.cusQuery.haveSunCus == 'Y') {
  309. //this.customerOrgTreeAll = deepCopy(this.cusQuery.treeDataAll)
  310. this.$refs['customerOrgTree'].filter(newVal);
  311. } else {
  312. this.filterParentNode(newVal)
  313. }
  314. }
  315. }
  316. },
  317. // 勾选含子单位 查询所有单位
  318. "cusQuery.haveSunCus": {
  319. // immediate: true,
  320. handler(newVal, oldVal) {
  321. // console.log(`watch 人员登记 newVal:${newVal} oldVal:${oldVal} registerCheckId: ${this.dataTransOpts.tableS.patient_register.id}`);
  322. if (newVal != oldVal && newVal == 'Y' && this.cusQuery.times == 0) this.getCustomerOrgAll()
  323. }
  324. },
  325. },
  326. };
  327. </script>
  328. <style scoped>
  329. @import "../../assets/css/global_tree.css";
  330. .treeicons {
  331. font-size: 20px;
  332. margin-right: 5px;
  333. }
  334. :deep .el-tree-node>.el-tree-node__children {
  335. overflow: visible;
  336. }
  337. </style>