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.

212 lines
6.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year 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 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
1 year ago
1 year 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 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
  1. <template>
  2. <div style="width:208px">
  3. <div style="margin:2px 2px 2px 2px;">
  4. <el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small" />
  5. </div>
  6. <div>
  7. <el-tree
  8. :style="'overflow: scroll;height:' + (window.pageHeight < 600 ? 465 : window.pageHeight - 135) + 'px;width:200px;'"
  9. :data="customerOrgTreeAll" :props="treeprops" node-key="id" @node-contextmenu="nodeContextmenu"
  10. @node-click="treeclick" highlight-current ref="customerOrgTree" :load="loadNode" lazy>
  11. <span class="custom-tree-node" slot-scope="{ node, data }">
  12. <div>
  13. <span class="treeicons">
  14. <!-- <i
  15. class="el-icon-document-remove"
  16. v-if="data.parentId == null"
  17. ></i> -->
  18. <img style="width:20px;height:20px;vertical-align: sub;" src="@/assets/images/order.png"
  19. v-if="!data.parentId" />
  20. </span>
  21. <span :class="!data.parentId ? 'maxtitle' : 'mintitle'">{{ node.label }}
  22. </span>
  23. </div>
  24. </span>
  25. </el-tree>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { mapState } from "vuex";
  31. import { getapi, postapi, putapi, deletapi } from "@/api/api";
  32. import { tcdate, deepCopy, reMadeOrgTree } from "../../utlis/proFunc";
  33. export default {
  34. components: {},
  35. data() {
  36. return {
  37. filterText: '',
  38. treeprops: {
  39. label: "label",
  40. value: "id",
  41. id: "id",
  42. children: "treeChildren",
  43. isLeaf: "isLeaf"
  44. }, //树形组件的数据结构
  45. LocalConfig: {
  46. patientRegister: {
  47. dispCustomerOrgCode: 'N', // 人员登记列表--单位树是否显示 customerOrgCode
  48. }
  49. },
  50. customerOrgTreeAll: []
  51. };
  52. },
  53. //<el-tree :data="$store.state.customerOrg.customerOrgTree" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree>
  54. computed: {
  55. ...mapState(["window", "dict", "dataTransOpts", "customerOrg", "patientRegister"]),
  56. },
  57. //创建组件后
  58. created() {
  59. try {
  60. let LocalConfig = JSON.parse(window.localStorage.getItem('LocalConfig'))
  61. if (LocalConfig && LocalConfig.patientRegister) {
  62. if (LocalConfig.patientRegister.dispCustomerOrgCode) this.LocalConfig.patientRegister.dispCustomerOrgCode = LocalConfig.patientRegister.dispCustomerOrgCode
  63. }
  64. } catch (error) {
  65. console.log("window.localStorage.getItem('LocalConfig')", error)
  66. }
  67. },
  68. //挂载组件完成
  69. mounted() {
  70. //获取体检单位列表树信息
  71. this.getCustomerOrgChild(null)
  72. .then(res => {
  73. this.customerOrgTreeAll = res
  74. this.patientRegister.customerOrgTreeAll = res
  75. // console.log('this.customerOrgTreeAll', this.customerOrgTreeAll)
  76. })
  77. },
  78. methods: {
  79. getCustomerOrgChild(parentId) {
  80. return new Promise((resolve, reject) => {
  81. postapi('/api/app/CustomerOrg/GetCustomerOrgByParentId', { parentId })
  82. .then(res => {
  83. if (res.code > -1) {
  84. res.data.forEach(e => {
  85. e.isLeaf = e.isChild == 'Y' ? false : true
  86. });
  87. let treeData = reMadeOrgTree(deepCopy(res.data), this.LocalConfig.patientRegister.dispCustomerOrgCode);
  88. resolve(treeData)
  89. }
  90. })
  91. .catch(err => {
  92. reject(err)
  93. })
  94. })
  95. },
  96. loadNode(node, resolve) {
  97. // console.log('node', node)
  98. if (node && node.data && node.data.id) {
  99. this.getCustomerOrgChild(node.data.id).then(res => {
  100. resolve(res)
  101. }).catch(err => {
  102. resolve([])
  103. })
  104. }
  105. },
  106. // 节点右击事件
  107. nodeContextmenu(event, data, node, ids) {
  108. console.log('event,data,node,ids', event, data, node, ids)
  109. if (data.id == this.dict.personOrgId) return
  110. let items = [
  111. {
  112. label: "置顶",
  113. onClick: () => {
  114. this.treeSort(data, 1);
  115. },
  116. },
  117. {
  118. label: "置底",
  119. onClick: () => {
  120. this.treeSort(data, 2);
  121. },
  122. }
  123. ] //菜单项
  124. this.$contextmenu({
  125. items,
  126. event,
  127. //x: event.clientX,
  128. //y: event.clientY,
  129. customClass: "custom-class",
  130. zIndex: 3,
  131. minWidth: 80,
  132. });
  133. return false;
  134. },
  135. // 树节点排序
  136. treeSort(data, sortType) {
  137. console.log('data', data)
  138. // if (data.parentId) {
  139. // this.$message.warning({ showClose: true, message: "请选择一级单位" })
  140. // return
  141. // }
  142. // console.log('data,sortType',data,sortType)
  143. putapi(`/api/app/customerorg/updatemanysort?id=${data.id}&SortType=${sortType}`).then(res => {
  144. if (res.code > -1) {
  145. this.getCustomerOrgChild(data.parentId).then(res => {
  146. data.treeChildren = res
  147. if(data.parentId == null){
  148. this.customerOrgTreeAll = res
  149. this.patientRegister.customerOrgTreeAll = res
  150. }
  151. })
  152. }
  153. })
  154. },
  155. //树过滤
  156. filterNode(value, data) {
  157. // console.log(value, data)
  158. // if (!value) return true;
  159. // return data['displayName'].indexOf(value) > -1 || data['simpleCode'].indexOf(value.toUpperCase()) > -1 || data['shortName'].indexOf(value) > -1 || data['customerOrgCode'].indexOf(value) > -1;
  160. this.customerOrgTreeAll = this.patientRegister.customerOrgTreeAll.filter(e => {
  161. return e.label.indexOf(value) > -1 || e.simpleCode.indexOf(value.toUpperCase()) > -1 || e.shortName.indexOf(value) > -1
  162. })
  163. },
  164. //点击树节点
  165. treeclick(data) {
  166. // console.log('data',data)
  167. this.patientRegister.query.customerOrgId = data.id;
  168. this.patientRegister.query.customerOrgName = data.displayName;
  169. this.dataTransOpts.plus.PatientRegisterEditQuery++
  170. //获取体检单位父级ID
  171. // this.getCustomerOrgParentId(data.id);
  172. // this.patientRegister.query.times++; //用于触发查询条件
  173. },
  174. },
  175. watch: {
  176. "filterText": {
  177. // immediate: true,
  178. handler(newVal, oldVal) {
  179. // console.log(`watch 人员登记 newVal:${newVal} oldVal:${oldVal} registerCheckId: ${this.dataTransOpts.tableS.patient_register.id}`);
  180. if (newVal != oldVal) this.filterNode(newVal)
  181. }
  182. },
  183. },
  184. };
  185. </script>
  186. <style scoped>
  187. @import "../../assets/css/global_tree.css";
  188. .treeicons {
  189. font-size: 20px;
  190. margin-right: 5px;
  191. }
  192. :deep .el-tree-node>.el-tree-node__children {
  193. overflow: visible;
  194. }
  195. </style>