人民医院前端

orderSelect.vue 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <uni-data-picker class="uni_item" placeholder="请选择工单类别" :showSearch= "showSearch" :readonly="readonly" :localdata="dataOrderType" v-model="WorkOrderCategory" @change="changeType" @nodeclick="nodeclick" @popupclosed="popupclosed" @searchTrue="searchTrue">
  3. </uni-data-picker>
  4. </template>
  5. <script>
  6. import pageData from "@/pages/myTask/repairList/addRepair/pageData.js"
  7. import {filterTreeDatas} from '@/utils/dataTreating.js'
  8. export default {
  9. data() {
  10. return {
  11. order: '',
  12. WorkOrderCategory: '',
  13. orderList: [],
  14. identification: '',
  15. dataOrderType: [],
  16. autoData:[],
  17. showSearch:true
  18. }
  19. },
  20. props: {
  21. orderType: {},
  22. typeid: '',
  23. readonly:false,
  24. ignore: {
  25. type: Array,
  26. },
  27. },
  28. watch: {
  29. typeid(newVal) {
  30. console.log('orderSelect',newVal)
  31. if(newVal){
  32. this.getDpartment()
  33. }
  34. }
  35. },
  36. created() {
  37. console.log(this.props,'created')
  38. if(this.typeid){
  39. this.getDpartment()
  40. }
  41. },
  42. methods: {
  43. getDpartment() {
  44. pageData.getGongDanType(this.typeid,(res, data) => {
  45. this.orderList = data
  46. console.log(this.ignore, 'this.props')
  47. this.dataOrderType = this.ignore?.length ? res.filter((o) => {
  48. return !this.ignore.includes(o.value);
  49. }) : res;
  50. console.log(res, 'getGongDanType')
  51. if(this.orderType) {
  52. this.getOrder(res, data, this.orderType)
  53. }
  54. })
  55. },
  56. getOrder(data, tree, id) {
  57. let newtext = ''
  58. for (const i in tree) {
  59. if (tree[i].id == id) {
  60. this.getTree(data, tree[i].text)
  61. } else if (tree[i].children) {
  62. this.getOrder(data, tree[i].children, id)
  63. }
  64. }
  65. },
  66. getTree(tree, text) {
  67. for (const i in tree) {
  68. if (tree[i].text == text) {
  69. this.WorkOrderCategory = tree[i].value
  70. } else if (tree[i].children) {
  71. this.getTree(tree[i].children, text)
  72. }
  73. }
  74. },
  75. clearOrderCategory(){
  76. this.WorkOrderCategory = ''
  77. this.$emit('post-select-data','','','','', '')
  78. },
  79. changeType(e,f,g){
  80. const valueData = e.detail.value
  81. console.log(valueData, 'valueData')
  82. if(valueData && valueData.length > 0){
  83. this.WorkOrderCategory = valueData[valueData.length-1].value
  84. }else{
  85. this.WorkOrderCategory = ''
  86. this.$emit('post-select-data','','','','', '')
  87. }
  88. },
  89. searchTrue(e){
  90. this.WorkOrderCategory = e.value
  91. },
  92. nodeclick(data) {
  93. if (data.hasChild === 0) {
  94. this.order = data.value
  95. this.identification = this.$mHelper.getIdentification(this.orderList,data.value)
  96. this.$emit('post-select-data',data.value,data.id,data.orderType,this.identification, data.text)
  97. }
  98. },
  99. popupclosed(data) {
  100. // this.WorkOrderCategory = this.order
  101. }
  102. }
  103. }
  104. </script>
  105. <style>
  106. </style>