<template>
  <div class="testdiv">
    <div class="divborder newSearchDiv" style="margin:0px;">
      <div>
        <div class="filter">
          <label>
            {{$t('1950491')}}：
          </label>
          <Cascader
            :data="datalevel"
            :value="leveldata"
            v-model="sectionid"
            trigger="click"
            change-on-select
            @on-change="handlelevelchange"
            class="searchSelect"
          ></Cascader>
        </div>
        <div class="filter">
          <label>{{$t('100307')}}：</label>
          <Select v-model="productid" label-in-value clearable filterable class="searchSelect">
            <Option
              v-for="(item,index) in products"
              :value="item.id"
              :key="index"
            >{{ item.name + "【" + item.code + "】" }}</Option>
          </Select>
        </div>
      </div>
      <div class="searchBtn">
        <Button type="primary" class="twoWord" icon="ios-search" @click="search(1,pagesize)">{{$t('1001')}}</Button>
        <Button type="success" class="twoWord" icon="md-add-circle" @click="add()">{{$t('1002')}}</Button>
        <Button type="warning" class="twoWord" icon="ios-create-outline" @click="edit()">{{$t('1003')}}</Button>
        <Button type="error" class="twoWord intervalRight" icon="md-close-circle" @click="dele()">{{$t('1004')}}</Button>
        <Button type="primary" class="fourWord" icon="md-download" @click="loadexcel()">{{$t('1005')}}</Button>
        <Upload
          style="display:inline-block"
          ref="upload"
          :action="axios.publicPath+'qms/upload/Submit?templateName=InspectionStandardList'"
          name="excel-file"
          :headers="headers"
          :show-upload-list="false"
          :on-format-error="handleFormatError"
          :on-success="handleSuccess"
          :on-error="handleError"
          :format="['xlsx']"
        >
          <Button type="primary" class="fourWord" icon="md-cloud-upload">{{$t('1006')}}</Button>
        </Upload>
        <Button type="primary" class="fourWord" icon="ios-cloud-download" @click="downexcel()">{{$t('1007')}}</Button>
      </div>
    </div>
    <div class="divborder newTableDiv">
      <Table
        class="tableClass"
        width="100%"
        @on-current-change="handleRowChange"
        @on-selection-change="handleSelectRow"
        highlight-row
        :data="tableData1"
        :columns="tableColumns1"
      ></Table>
      <div class="pageDiv">
        <div class="pageDirection">
          <Page
            :total="total"
            :current="page"
            @on-change="changePage"
            show-elevator
            show-sizer
            show-total
            @on-page-size-change="handlePageSize"
            :page-size-opts="[10,20,30,40,100]"
          ></Page>
        </div>
      </div>
    </div>

    <Modal class="newModalClass" :title="title1" v-model="editmodal" :styles="{width:'700px'}">
      <div class="modal_body">
        <div>
          <div class="filter">
            <label>
              <i>*</i>{{$t('1950491')}}：
            </label>
            <Cascader
              :data="datalevel1"
              :value="leveldata1"
              v-model="editsectionid"
              trigger="click"
              change-on-select
              class="searchSelect"
            ></Cascader>
          </div>
          <div class="filter">
            <label>
              <i>*</i>{{$t('100089')}}：
            </label>
            <Select v-model="editobj.productid" label-in-value clearable filterable class="searchSelect">
              <Option
                v-for="(item,index) in editproducts"
                :value="item.id"
                :key="index"
              >{{ item.name + "【" + item.code + "】" }}</Option>
            </Select>
          </div>
          <div class="filter">
            <label>
               <i>*</i>{{$t('1950531')}}：
            </label>
            <Select
              v-model="editobj.unhealthy_category_id"
              label-in-value
              @on-change="unhealthycodechange"
              clearable
              class="searchSelect"
            >
              <Option
                v-for="(item,index) in unhealthycategorys"
                :value="item.id"
                :key="index"
              >{{ item.name }}</Option>
            </Select>
          </div>
          <div class="filter">
            <label>
              <i>*</i>{{$t('1950532')}}：
            </label>
            <Select v-model="editobj.unhealthy_id" label-in-value clearable class="searchSelect">
              <Option v-for="(item,index) in unhealthycodes" :value="item.id" :key="index">{{ item.code }}</Option>
            </Select>
          </div>
          <div class="filter">
            <label><i>*</i>{{$t('1950538')}}：</label>
            <InputNumber
              type="text"
              v-model="editobj.seq"
              class="searchInput"
            />
          </div>
          <div class="filter">
            <label><i>*</i>{{$t('1950616')}}：</label>
            <RadioGroup v-model="editobj.standard_type" style="width:160px;">
              <Radio :label="1" style="width:70px;">{{$t('1950617')}}</Radio>
              <Radio :label="2" style="width:70px;">{{$t('1950618')}}</Radio>
            </RadioGroup>
          </div>
          <div class="filter">
            <label><i>*</i>{{this.$t('1950496')}}：<span></span></label>
            <Select v-model="editobj.checktype" label-in-value :max-tag-count="5" clearable multiple class="searchSelect nowropStyle" >
              <Option v-for="(item,index) in checktypeList" :value="item.type_code" :key="index">{{ item.type_name }}</Option>
            </Select>
          </div>
          <div class="filter">
            <label><i>*</i>{{$t('901048')}}：</label>
            <Input class="searchInput" type="text" v-model="editobj.item"  />
          </div>
          <div class="filter">
            <label><i>*</i>{{$t('1950533')}}：</label>
            <Input class="searchInput" type="text" v-model="editobj.standard"  />
          </div>
          <div class="filter">
            <label><i>*</i>{{$t('1950534')}}：</label>
            <RadioGroup v-model="valuetype" style="width:220px;">
              <Radio :label="1">{{$t('1950535')}}</Radio>
              <Radio :label="2">{{$t('1950536')}}</Radio>
              <Radio :label="3">{{$t('5500235')}}</Radio>
            </RadioGroup>
          </div>
          <div class="filter dataRang" v-if="valuetype==='3' || valuetype === 3">
            <div class="searchDataRang" v-for="(item,index) in searchDataRang" :key="index">
              <label>{{$t('5500236')}}：</label>
              <Input
                type="text"
                v-model="item.option"
                class="searchInput"
              />&nbsp;&nbsp;&nbsp;&nbsp;
              <label>{{$t('800195')}}：</label>
              <RadioGroup v-model="item.option_type" style="width:140px;">
                <Radio :label="1">OK</Radio>
                <Radio :label="0">NG</Radio>
              </RadioGroup>
              <span v-if="index===0" class="spanbtn" @click="addbtn13()">+</span>
              <span v-else class="spanbtn" @click="delbtn13(index)">-</span>
            </div>
          </div>
          <div class="filter" v-if="valuetype==='2' || valuetype === 2">
            <label><i>*</i> {{$t('1950612')}}：</label>
            <RadioGroup v-model="editobj.value_category" style="width:160px;">
              <Radio :label="1">{{$t('1950610')}}</Radio>
              <Radio :label="2">{{$t('1950611')}}</Radio>
            </RadioGroup>
          </div>
          <div v-if="valuetype==='2' || valuetype === 2">
            <div class="filter">
              <label>{{$t('200017')}}：</label>
              <Input class="searchInput" type="text" v-model="editobj.unit" />
            </div>
            <div class="filter">
              <label><i>*</i>{{$t('1950537')}}：</label>
              <InputNumber
                class="searchInput minWidth"
                type="text"
                v-model="editobj.min_value"
              />~
              <InputNumber
                class="searchInput minWidth"
                type="text"
                v-model="editobj.max_value"
              />
            </div>
          </div>
          <div class="filter" v-if="(valuetype==='2' || valuetype === 2) && (editobj.value_category==='2' || editobj.value_category === 2)">
            <label><i>*</i>{{$t('8000032')}}：</label>
            <InputNumber
              class="searchInput"
              type="text"
              v-model="editobj.range"
            />
          </div>
          <div class="filter">
            <div class="filter" v-if="valuetype==='2' || valuetype === 2">
              <label>
                {{$t('1950622')}}：
              </label>
              <Input class="searchInput" type="text" v-model="editobj.lcl" />
            </div>
            <div class="filter" v-if="valuetype==='2' || valuetype === 2">
              <label>
                {{$t('1950623')}}：
              </label>
              <Input class="searchInput" type="text" v-model="editobj.ucl"/>
            </div>
          </div>
          <div class="filter">
            <label>
              <i>*</i>{{$t('1950530')}}：
            </label>
            <RadioGroup v-model="editobj.trigger_andon" style="width:160px;">
              <Radio :label="0" style="width:50px;">{{$t('1000021')}}</Radio>
              <Radio :label="1" style="width:50px;">{{$t('1000020')}}</Radio>
            </RadioGroup>
          </div>
        </div>
      </div>
      <div slot="footer">
        <Button type="text" size="large" @click="cancle">{{$t('1033')}}</Button>
        <Button type="primary" size="large" v-if="type===1" :loading="loading1" @click="adddata">
            <span v-if="!loading1">{{$t('1002')}}</span>
            <span v-else>{{$t('1002')}}</span>
        </Button>
        <Button type="primary" size="large" v-if="type===2" :loading="loading2" @click="editdata">
            <span v-if="!loading2">{{$t('1003')}}</span>
            <span v-else>{{$t('1003')}}</span>
        </Button>
        <!--<Button type="primary" v-if="type===1" size="large" @click="adddata">{{$t('1002')}}</Button>
        <Button type="primary" v-if="type===2" size="large" @click="editdata">{{$t('1003')}}</Button>-->
      </div>
    </Modal>
  </div>
</template>

<script>
import axios from '@/libs/api.request'

export default {
    data () {
        return {
            headers: {
                token: localStorage.getItem('token'),
                timestamp: localStorage.getItem('timestamp'),
                nonce: localStorage.getItem('nonce'),
                sign: localStorage.getItem('sign')
            },
            title1: this.$t('1002'),
            tableData1: [],
            editmodal: false,
            page: 1,
            pagesize: 10,
            total: 0,
            // 值选项
            searchDataRang: [
                {
                    option: '',
                    option_type: 1
                }
            ],
            tableColumns1: [
                {
                    type: 'selection',
                    width: 50,
                    align: 'center'
                },
                {
                    title: this.$t('1008'),
                    key: 'xuhao',
                    render: (h, params) => {
                        return h(
                            'span',
                            params.index + (this.page - 1) * this.pagesize + 1
                        )
                    },
                    width: 70
                },
                {
                    title: this.$t('100089'),
                    key: 'productcode',
                    minWidth: 150
                },
                {
                    title: this.$t('100088'),
                    key: 'productname',
                    minWidth: 150
                },
                {
                    title: this.$t('1950491'),
                    key: 'section_value',
                    minWidth: 150
                },
                {
                    title: this.$t('1950538'),
                    key: 'seq',
                    minWidth: 70
                },
                {
                    title: this.$t('901048'),
                    key: 'item',
                    minWidth: 150
                },
                {
                    title: this.$t('1950539'),
                    key: 'standard',
                    minWidth: 150
                },
                {
                    title: this.$t('1950534'),
                    key: 'value_type_value',
                    minWidth: 100
                },
                {
                    title: this.$t('1950612'),
                    key: 'value_category_value',
                    minWidth: 100
                },
                {
                    title: this.$t('200017'),
                    key: 'unit',
                    minWidth: 100
                },
                {
                    title: this.$t('500082'),
                    key: 'min_value',
                    minWidth: 80
                },
                {
                    title: this.$t('500081'),
                    key: 'max_value',
                    minWidth: 80
                },
                {
                    title: this.$t('8000032'),
                    key: 'range',
                    minWidth: 80
                },
                {
                    title: this.$t('1950624'),
                    key: 'trigger_andon_value',
                    minWidth: 80
                },
                {
                    title: this.$t('1950622'),
                    key: 'lcl',
                    minWidth: 80
                },
                {
                    title: this.$t('1950623'),
                    key: 'ucl',
                    minWidth: 80
                },
                {
                    title: this.$t('1950531'),
                    key: 'unhealthy_category_name',
                    minWidth: 150
                },
                {
                    title: this.$t('1950540'),
                    key: 'unhealthy_name',
                    minWidth: 150
                },
                {
                    title: this.$t('1950532'),
                    key: 'unhealthy_code',
                    minWidth: 100
                },
                {
                    title: this.$t('920139'),
                    key: 'update_mid',
                    minWidth: 100
                },
                {
                    title: this.$t('920138'),
                    key: 'update_time',
                    minWidth: 150
                },
                {
                    title: this.$t('1950616'),
                    key: 'isspect',
                    minWidth: 150
                },
                {
                    title: this.$t('1950496'),
                    key: 'check_type',
                    minWidth: 150
                }
            ],
            editobj: {},
            sections: [],
            editsections: [],
            products: [],
            categorys: [],
            type: 0,
            valuetype: 1,
            unhealthycategorys: [],
            unhealthycodes: [],
            leveldata: [],
            datalevel: [],
            leveldata1: [],
            datalevel1: [],
            sectionid: [],
            editsectionid: [],
            productid: 0,
            editproducts: [],
            loading1: false,
            loading2: false,
            selectids: [],
            checktypeList: [
                // { id: 5, name: this.$t(930033) },
                // { id: 2, name: this.$t(930034) },
                // { id: 3, name: this.$t(930035) },
                // { id: 6, name: this.$t(930036) },
                // { id: 1, name: this.$t(950367) },
                // { id: 4, name: this.$t(930037) },
                // { id: 7, name: this.$t(600233) }
            ]
        }
    },
    created () {
        this.search(1, 10)
        this.initlevel()
        this.initunhealthycategorys()
        this.initeditproducts()
        this.getChecktypeList()
        // 格式化表格样式
        this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1)
    },
    methods: {
    // 获取检验类型
        getChecktypeList () {
            axios.request({
                url: '/qms/TypeCount/GetTypeCounts?page=1&pagesize=10000',
                method: 'get'
            }).then(res => {
                this.checktypeList = res.data.data;
            })
        },
        // 添加按钮
        addbtn13 () {
            this.searchDataRang.push({
                option: '',
                option_type: 1
            });
        },
        // 删除按钮
        delbtn13 (index) {
            this.searchDataRang.splice(index, 1);
        },
        initeditproducts () {
            axios.request({
                url: '/config/projectproduct/GetProducts',
                method: 'get'
            }).then(res => {
                this.editproducts = res.data.data
            })
        },
        handlelevelchange (value) {
            this.leveldata = value
            var sectionid = value[value.length - 1]
            this.initproducts(sectionid)
        },
        initlevel () {
            axios
                .request({
                    url: '/qms/InspectStandard/GetSectionTree',
                    method: 'get'
                })
                .then(res => {
                    const arr = []
                    this.datalevel = res.data.data
                    if(Array.isArray(res.data.data)&&res.data.data.length){
                        arr.push(res.data.data[0].value)
                    }
                    this.leveldata = arr
                })
        },
        initlevel1 () {
            axios
                .request({
                    url: '/config/ProjectLevelSection/GetSectionTree',
                    method: 'get'
                })
                .then(res => {
                    const arr = []
                    this.datalevel1 = res.data.data
                    arr.push(res.data.data[0].value)
                    this.leveldata1 = arr
                })
        },
        search (page, pagesize) {
            var params = {
                page: page,
                pagesize: pagesize,
                productid: this.productid,
                sectionid: this.sectionid[this.sectionid.length - 1]
            }
            axios
                .request({
                    url: '/qms/InspectStandard/GetPageList',
                    params,
                    method: 'get'
                })
                .then(res => {
                    this.page = page
                    this.pagesize = pagesize
                    this.total = res.data.total
                    this.mockTableData1(res.data.data)
                })

            this.obj = {}
        },
        cancle () {
            this.editobj = {}
            this.editmodal = false
            this.type = 0
            this.valuetype = 1
            this.search(this.page, this.pagesize)
        },
        add () {
            this.title1 = this.$t('1002')
            this.type = 1
            this.editobj = {}
            this.editobj.min_value = 0
            this.editobj.max_value = 0
            this.editmodal = true
            this.editsectionid = []
            this.editobj.sectionid = 0
            this.editobj.range = '';
            this.editobj.seq = 0;
            this.editobj.standard_type = 1;
            this.editobj.ucl = null;
            this.editobj.lcl = null;
            this.editobj.trigger_andon = 0;
            this.valuetype = 1
            this.searchDataRang = [
                {
                    option: '',
                    option_type: 1
                }
            ]
            this.initlevel1()
            this.initunhealthycategorys()
        },
        edit () {
            if (
                JSON.stringify(this.obj) === '{}' ||
        this.obj === null ||
        this.obj === undefined
            ) {
                this.$Message.error(this.$t('1043'))
                return false
            }
            this.title1 = this.$t('1003')
            this.type = 2
            this.editsectionid = []
            this.editobj = []
            this.getdata()
            this.editmodal = true
        },
        getdata () {
            axios
                .request({
                    url: '/qms/InspectStandard/GetStandard?id=' + this.obj.id,
                    method: 'get'
                })
                .then(res => {
                    this.editobj = res.data.data
                    this.editobj.max_value =
            this.editobj.max_value === 999999999
                ? null
                : this.editobj.max_value
                    this.editobj.min_value =
            this.editobj.min_value === -999999999
                ? null
                : this.editobj.min_value
                    this.valuetype = this.editobj.value_type
                    this.editsectionid = this.editobj.sectionids
                    this.initlevel1()
                    this.initeditunhealthycategorys()
                })
        },
        adddata () {
            var data = this.editobj
            data.value_type = this.valuetype
            data.sectionid = this.editsectionid[this.editsectionid.length - 1]
            if (this.valuetype != 3) {
                this.searchDataRang = []
            }
            data.data = this.searchDataRang
            if (this.valuetype === 3 && this.searchDataRang.length === 0) {
                this.$Message.error(this.$t('5500237'))
                return false
            }
            if (this.valuetype === 3 && this.searchDataRang.length > 0) {
                let code = 1
                this.searchDataRang.forEach((item, index) => {
                    if (item.option === '') {
                        code = 2
                    }
                })
                if (code === 2) {
                    this.$Message.error(this.$t('5500237'))
                    return false
                }
            }
            this.loading1 = true
            axios
                .request({
                    url: '/qms/InspectStandard/AddStandard',
                    data,
                    method: 'post'
                })
                .then(res => {
                    this.loading1 = false
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t('1055'))
                        this.search(this.page, this.pagesize)
                        this.editmodal = false
                    } else {
                        this.$Message.error(this.$t(res.data.msg))
                    }
                }).catch(() => {
                    this.loading1 = false
                })
        },
        editdata () {
            let data = this.editobj
            data.id = this.obj.id
            data.value_type = this.valuetype
            data.sectionid = this.editsectionid[this.editsectionid.length - 1]
            if (this.valuetype != 3) {
                this.searchDataRang = []
            }
            data.data = this.searchDataRang
            if (this.valuetype === 3 && this.searchDataRang.length === 0) {
                this.$Message.error(this.$t('5500237'))
                return false
            }
            if (this.valuetype === 3 && this.searchDataRang.length > 0) {
                let code = 1
                this.searchDataRang.forEach((item, index) => {
                    if (item.option === '') {
                        code = 2
                    }
                })
                if (code === 2) {
                    this.$Message.error(this.$t('5500237'))
                    return false
                }
            }
            this.loading2 = true
            axios
                .request({
                    url: '/qms/InspectStandard/EditStandard',
                    data,
                    method: 'post'
                })
                .then(res => {
                    this.loading2 = false
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t('1060'))
                        this.search(this.page, this.pagesize)
                        this.editmodal = false
                    } else {
                        this.$Message.error(this.$t(res.data.msg))
                    }
                }).catch(() => {
                    this.loading2 = false
                })
        },
        dele () {
            if (this.selectids === undefined || this.selectids === null || this.selectids === [] || this.selectids.length <= 0) {
                this.$Message.error((this.$t('1017')))
                return false
            } else {
                this.$Modal.confirm({
                    title: this.$t('1018'),
                    content: '',
                    width: '290px',
                    closable: true,
                    okText: this.$t('1004'),
                    onOk: () => {
                        let parameter = {
                            ids: this.selectids
                        }
                        axios
                            .request({
                                url: '/qms/InspectStandard/Delete',
                                data: parameter,
                                method: 'post'
                            })
                            .then(res => {
                                if (res.data.ret === 1) {
                                    this.page = 1
                                    this.selectids = []
                                    this.search(this.page, this.pagesize)
                                    this.$Message.success(this.$t('1058'))
                                } else {
                                    this.$Message.error(this.$t(res.data.msg))
                                }
                            })
                    }
                })
            }
        },
        initeditunhealthycategorys () {
            axios
                .request({
                    url: '/qms/InspectCategory/GetNameList',
                    method: 'get'
                })
                .then(res => {
                    this.unhealthycategorys = res.data.data
                    this.unhealthycodechange()
                })
        },
        initunhealthycategorys () {
            axios
                .request({
                    url: '/qms/InspectCategory/GetNameList',
                    method: 'get'
                })
                .then(res => {
                    this.unhealthycategorys = res.data.data
                })
        },
        unhealthycodechange () {
            axios
                .request({
                    url:
            '/qms/InspectCategory/GetUnhealthyNameList?categoryid=' +
            this.editobj.unhealthy_category_id,
                    method: 'get'
                })
                .then(res => {
                    this.unhealthycodes = res.data.data
                })
        },
        initproducts (sectionid) {
            this.products = [{ id: 0, name: '', code: '' }]
            axios.request({
                url: '/qms/InspectStandard/GetProductsBySectionId?reverselevel=2&sectionid=' + sectionid,
                method: 'get'
            }).then(res => {
                this.products = res.data.data
            })
            this.productid = ''
        },
        mockTableData1 (tablelist) {
            let data = []
            tablelist.forEach(item => {
                if (item) {
                    data.push({
                        id: item.id,
                        productid: item.productid,
                        productcode: item.productcode,
                        productname: item.productname,
                        sectionid: item.sectionid,
                        section_value: item.section_value,
                        seq: item.seq,
                        category: item.category,
                        category_value: item.category_value,
                        item: item.item,
                        standard: item.standard,
                        unit: item.value_type === 2 ? item.unit : '',
                        max_value:
              item.value_type === 2
                  ? item.max_value == 999999999
                      ? ''
                      : item.max_value
                  : '',
                        min_value:
              item.value_type === 2
                  ? item.min_value == -999999999
                      ? ''
                      : item.min_value
                  : '',
                        unhealthy_code: item.unhealthy_code,
                        unhealthy_desc: item.unhealthy_desc,
                        update_mid: item.update_mid,
                        update_time: item.update_time,
                        value_type: item.value_type,
                        value_type_value: item.value_type === 1 ? '√' : (item.value_type === 2 ? this.$t('1950536') : this.$t('5500235')),
                        unhealthy_id: item.unhealthy_id,
                        unhealthy_name: item.unhealthy_name,
                        unhealthy_category_id: item.unhealthy_category_id,
                        unhealthy_category_name: item.unhealthy_category_name,
                        value_category: item.value_category,
                        value_category_value: item.value_category === 1 ? this.$t('1950610') : (item.value_category === 2 ? this.$t('1950611') : ''),
                        range: item.value_category === 2 ? item.range : '',
                        isspect: item.standard_type === 1 ? this.$t('1950617') : this.$t('1950618'),
                        check_type: item.check_type,
                        ucl: item.value_type === 2 ? (item.ucl === null ? '' : item.ucl) : '',
                        lcl: item.value_type === 2 ? (item.lcl === null ? '' : item.lcl) : '',
                        trigger_andon: item.trigger_andon,
                        trigger_andon_value: item.trigger_andon === 1 ? this.$t('1000020') : (item.trigger_andon === 0 ? this.$t('1000021') : ''),
                        data: item.data
                    })
                }
            })
            this.tableData1 = data
        },
        loadexcel () {
            axios
                .request({
                    url: '/qms/InspectStandard/GetTemplate',
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        window.location.href = axios.publicPath + '' + res.data.data
                    } else {
                        this.$Message.error(this.$t(res.data.msg))
                    }
                })
        },
        downexcel () {
            var params = {
                productid: this.productid === '' || this.productid === null || this.productid === undefined ? 0 : this.productid,
                sectionid: this.sectionid.length === 0 ? 0 : this.sectionid[this.sectionid.length - 1]
            }
            axios
                .request({
                    url: '/qms/InspectStandard/ExportExcelStandard',
                    params,
                    method: 'get'
                })
                .then(res => {
                    if (res.data.ret === 1) {
                        window.location.href = axios.publicPath + '' + res.data.data
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                })
        },
        changecondition () {
            this.morecondition = !this.morecondition
        },
        handlePageSize (value) {
            this.pagesize = value
            this.tableData1 = this.search(1, this.pagesize)
        },
        changePage (value) {
            this.page = value
            this.tableData1 = this.search(this.page, this.pagesize)
        },
        handleRowChange (currentRow, oldCurrentRow) {
            this.obj = currentRow
            if (currentRow.data!=''&&currentRow.data != null &&currentRow.data!=undefined&&currentRow.data.length > 0) {
                this.searchDataRang = currentRow.data
            } else {
                this.searchDataRang = [
                    {
                        option: '',
                        option_type: 1
                    }
                ]
            }
        },
        handleSelectRow: function (data) {
            this.selectids = []
            for (var i in data) {
                if (this.selectids.indexOf(data[i].id) < 0) {
                    this.selectids.push(data[i].id)
                }
            }
        },
        handleFormatError (file) {
            this.$Message.error(this.$t('950396') + ' ' + file.name + ' ' + this.$t('950397'))
        },
        handleSuccess (res, file) {
            if (res.ret === 1) {
                this.$Message.success(this.$t('950398'))
                this.search(this.page, this.pagesize)
            } else {
                if (('' + res.msg).indexOf(',') != -1) {
                    inittip(res.msg)
                } else {
                    this.$Message.error(this.$t('' + res.msg))
                }
            }
        },
        handleError () {
            this.$Message.error(this.$t('950399'))
        }
    }
}
</script>
<style lang="less" scoped>
.dataRang{
  max-height: 200px;
  overflow-y: auto;
  height: 200px;
  margin: 10px 0px;
  border: 1px solid #ddd;
  display: block;
  margin-right: 80px;
  .searchDataRang{
    margin:10px 20px 10px 0px;
    .spanbtn {
      width: 32px;
      height: 32px;
      background: rgb(87, 163, 243);
      color: rgb(255, 255, 255);
      display: inline-block;
      vertical-align: top;
      font-size: 20px;
      text-align: center;
      border-radius: 3px;
      margin-left: 5px;
      width: 30px;
      height: 30px;
      background: #57a3f3;
      color: #fff;
      cursor:pointer;
    }
  }
}

</style>
