| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <uni-data-picker class="uni_item" placeholder="请选择工单类别" :showSearch= "showSearch" :readonly="readonly" :localdata="dataOrderType" v-model="WorkOrderCategory" @change="changeType" @nodeclick="nodeclick" @popupclosed="popupclosed" @searchTrue="searchTrue">
- </uni-data-picker>
- </template>
- <script>
- import pageData from "@/pages/myTask/repairList/addRepair/pageData.js"
- import {filterTreeDatas} from '@/utils/dataTreating.js'
- export default {
- data() {
- return {
- order: '',
- WorkOrderCategory: '',
- orderList: [],
- identification: '',
- dataOrderType: [],
- autoData:[],
- showSearch:true
- }
- },
- props: {
- orderType: {},
- typeid: '',
- readonly:false,
- ignore: {
- type: Array,
- },
- },
- watch: {
- typeid(newVal) {
- console.log('orderSelect',newVal)
- if(newVal){
- this.getDpartment()
- }
-
- }
- },
- created() {
- console.log(this.props,'created')
- if(this.typeid){
- this.getDpartment()
- }
- },
- methods: {
- getDpartment() {
- pageData.getGongDanType(this.typeid,(res, data) => {
- this.orderList = data
- console.log(this.ignore, 'this.props')
- this.dataOrderType = this.ignore?.length ? res.filter((o) => {
- return !this.ignore.includes(o.value);
- }) : res;
- console.log(res, 'getGongDanType')
- if(this.orderType) {
- this.getOrder(res, data, this.orderType)
- }
- })
- },
- getOrder(data, tree, id) {
- let newtext = ''
- for (const i in tree) {
- if (tree[i].id == id) {
- this.getTree(data, tree[i].text)
- } else if (tree[i].children) {
- this.getOrder(data, tree[i].children, id)
- }
- }
-
- },
- getTree(tree, text) {
- for (const i in tree) {
- if (tree[i].text == text) {
- this.WorkOrderCategory = tree[i].value
- } else if (tree[i].children) {
- this.getTree(tree[i].children, text)
- }
- }
- },
- clearOrderCategory(){
- this.WorkOrderCategory = ''
- this.$emit('post-select-data','','','','', '')
- },
- changeType(e,f,g){
- const valueData = e.detail.value
- console.log(valueData, 'valueData')
- if(valueData && valueData.length > 0){
- this.WorkOrderCategory = valueData[valueData.length-1].value
- }else{
- this.WorkOrderCategory = ''
- this.$emit('post-select-data','','','','', '')
- }
- },
- searchTrue(e){
- this.WorkOrderCategory = e.value
- },
- nodeclick(data) {
- if (data.hasChild === 0) {
- this.order = data.value
- this.identification = this.$mHelper.getIdentification(this.orderList,data.value)
- this.$emit('post-select-data',data.value,data.id,data.orderType,this.identification, data.text)
- }
- },
- popupclosed(data) {
- // this.WorkOrderCategory = this.order
- }
- }
- }
- </script>
- <style>
- </style>
|