<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" :model="searchData" @keyup.enter.native="getDataList()">
      <el-form-item :label="'BM模块名称'">
        <el-input v-model="searchData.codeDesc" style="width: 120px"></el-input>
      </el-form-item>
      <el-form-item :label="'BU编码'">
        <el-select filterable v-model="searchData.buNo" clearable style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option :label="item.buNo+'-'+item.buDesc" :value="item.buNo" v-for="(item,index) in buList "
                     :key="index"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'是否启用'">
<!--        <el-select clearable v-model="searchData.active" style="width: 120px">-->
<!--          <el-option label="Y" value="Y"></el-option>-->
<!--          <el-option label="N" value="N"></el-option>-->
<!--          <el-option label="全部" value=""></el-option>-->
<!--        </el-select>-->
        <dict-data-select v-model="searchData.active" clearable dict-type="sys_status"
                          :use-default-value="false" style="width: 120px"></dict-data-select>
      </el-form-item>
      <el-form-item :label="'是否可配置'">
        <el-select clearable v-model="searchData.editFlag" style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option label="Y" value="Y"></el-option>
          <el-option label="N" value="N"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="' '">
        <el-button @click="getDataList()">查询</el-button>
        <download-excel
          :fields="fields()"
          :data="exportData"
          type="xls"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{ "导出" }}
        </download-excel>
      </el-form-item>
    </el-form>
    <el-table
      :height="height"
      :data="dataList"
      border
      v-loading="dataListLoading"
      style="width: 100%;">
      <el-table-column
        v-for="(item,index) in columnList" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="{row,$index}">
          <div v-if="item.columnProp !== 'active' ">
            <span v-if="!item.columnHidden">{{ row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </div>
          <span v-else
                :style="{color:row.active === 'Y'?'#67C23A':'red'}">{{ row.active === 'Y' ? '启用' : '停用' }}</span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="120"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="editModal(scope.row)">编辑</a>
          <a type="text" size="small" v-if="scope.row.editFlag==='Y'" @click="detailModal(scope.row)">属性项目</a>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100, 200, 500]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

    <el-dialog title="属性项目清单" :close-on-click-modal="false" v-drag :visible.sync="detailModelFlag" width="830px">
      <el-form :inline="true" label-position="top" @keyup.enter.native="getDataList()">
        <el-form-item :label="'BU编码'">
          <el-input v-model="detailData.buNo" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'BM模块名称'">
          <el-input v-model="detailData.codeDesc" readonly style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'属性模板'">
          <el-input v-model="detailData.propertiesCodeNo" readonly style="width: 120px"></el-input>
        </el-form-item>
      </el-form>
      <el-table
        :height="300"
        :data="detailList"
        border
        v-loading="dataListLoading"
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in columnDetailList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="110"
          label="操作">
          <template slot-scope="scope">
            <a type="text" size="small" v-if="scope.row.valueChooseFlag === 'Y'" @click="chooseModal(scope.row)">可选值</a>
          </template>
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 20px;text-align:center">
        <el-button type="primary" @click="detailModelFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

        <el-dialog title="编辑BM模块" :close-on-click-modal="false" v-drag :visible.sync="editModalFlag" width="440px">
          <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
            <el-form-item label="BU编码:">
              <el-input v-model="editData.buNo" readonly style="width: 120px"></el-input>
            </el-form-item>
            <el-form-item label="BM模块名称:">
              <el-input v-model="editData.codeDesc" readonly style="width: 120px"></el-input>
            </el-form-item>
            <el-form-item label="是否可配置:">
              <el-input v-model="editData.editFlag" readonly style="width: 120px"></el-input>
            </el-form-item>
          </el-form>
          <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
            <el-form-item label="是否启用:">
              <el-select clearable v-model="editData.active"  style="width: 120px">
                <el-option label="Y" value="Y"></el-option>
                <el-option label="N" value="N"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item >
              <span slot="label" style="" @click="getBaseList(21)"><a herf="#">属性模板编码</a></span>
              <el-input v-model="editData.propertiesCodeNo" :disabled="editData.editFlag==='N'" style="width: 120px"></el-input>
            </el-form-item>
          </el-form>
          <el-footer style="height:40px;margin-top: 10px;text-align:center">
            <el-button type="primary" @click="updateBMModal()">保存</el-button>
            <el-button type="primary" @click="editModalFlag = false">关闭</el-button>
          </el-footer>
        </el-dialog>


    <el-dialog title="可选值" :close-on-click-modal="false" v-drag :visible.sync="chooseModalFlag" width="350px">
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item label="属性项目名称:">
          <el-input v-model="chooseModalData.itemDesc"  disabled style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'属性值类型'">
          <el-select filterable v-model="chooseModalData.valueTypeDb" disabled style="width: 120px">
            <el-option label="文本" value="T"></el-option>
            <el-option label="数字" value="N"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-table
        :height="300"
        :data="chooseTableData"
        border
        style="width: 100%">
        <el-table-column
          prop="availableValue"
          header-align="center"
          align="left"
          min-width="200"
          label="属性值">
        </el-table-column>
      </el-table>
      <el-footer style="height:40px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="chooseModalFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>
    <Chooselist ref="baseList"  @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
  import {
    propertiesModelSearchForBM,
    searchItemAvailable,
    searchModalDetailsForBM,
    saveModalDetailsForBM,
    deleteModalDetailsForBM, // 多选删除
    getItemListsForBM,
    updateBMModal,
  } from "@/api/base/properties.js"
  import Chooselist from '@/views/modules/common/Chooselist'
  import {
    getBUList,
  } from "@/api/base/site.js"
  import DictDataSelect from "../../sys/dict-data-select.vue";
  export default {
    components: {
      DictDataSelect,
      Chooselist
    },
    watch: {
      searchData: {
        deep: true,
        handler: function (newV, oldV) {
          this.searchData.codeNo = this.searchData.codeNo.toUpperCase()
        }
      },

      itemData: {
        deep: true,
        handler: function (newV, oldV) {
          this.itemData.itemNo = this.itemData.itemNo.toUpperCase()
        }
      },

      detailData: {
        deep: true,
        handler: function (newV, oldV) {
          this.detailData.codeNo = this.detailData.codeNo.toUpperCase()
          this.detailData.itemNo = this.detailData.itemNo.toUpperCase()
        }
      }
    },
    data () {
      return {
        // 是否收藏
        favorite: false,
        // 导出 start
        exportData: [],
        exportName: "BM模板" + this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["BM模板"],
        exportFooter: [],
        exportList:[],
        // 导出 end
        tagNo:'',
        searchData: {
          site: this.$store.state.user.site,
          codeNo: '',
          codeDesc: '',
          buNo:'',
          active:'Y',
          functionType:'',
          editFlag:'',
          page: 1,
          limit: 10,
        },
        height: 200,
        pageIndex: 1,
        pageSize: 50,
        totalPage: 0,
        modalDisableFlag:false,
        detailData:{
          site: this.$store.state.user.site,
          buNo:'',
          codeNo:'',
          codeDesc:'',
          functionType:'',
          itemNo:'',
          itemDesc:'',
          itemType:'',
          propertiesCodeNo:'',
          userId:this.$store.state.user.name
        },
        columnList: [
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TableBuNo',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'buNo',
            headerAlign: "center",
            align: "center",
            columnLabel: 'BU编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 50
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TableBuDesc',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'buDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: 'BU名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 70
          },
          // {
          //   userId: this.$store.state.user.name,
          //   functionId: 100003001,
          //   serialNumber: '100003001TableCodeNo',
          //   tableId: "100003001Table",
          //   tableName: "BM模板表",
          //   columnProp: 'codeNo',
          //   headerAlign: "center",
          //   align: "center",
          //   columnLabel: 'BM模块编码',
          //   columnHidden: false,
          //   columnImage: false,
          //   columnSortable: false,
          //   sortLv: 0,
          //   status: true,
          //   fixed: '',
          //   columnWidth: 90
          // },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TableCodeDesc',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'codeDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: 'BM模块名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TablePropertiesCodeNo',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'propertiesCodeNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性模板',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TablePropertiesCodeDesc',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'propertiesCodeDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性模板名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TableActive',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'active',
            headerAlign: "center",
            align: "center",
            columnLabel: '是否启用',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          }, {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TableEditFlag',
            tableId: "100003001Table",
            tableName: "BM模板表",
            columnProp: 'editFlag',
            headerAlign: "center",
            align: "center",
            columnLabel: '是否可配置',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },

        ],
        detailModelFlag:false,
        detailList: [],
        chooseTableData:[],
        dataListLoading: false,
        dataListSelections: [],
        // modalDisableFlag:false,
        chooseModalFlag:false,
        itemFlag:'text',
        itemData:{
          itemNo:'',
          valueNo:'',
          availableValue:'',
          itemType:'',
          createdBy: this.$store.state.user.name
        },
        dataList:[],
        departmentList:[],
        // 展示列集
        columnDetailList: [
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001Table2PropertiesItemID',
            tableId: "100003001Table2",
            tableName: "BM模板表",
            columnProp: 'itemNo',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性项目编码',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001Table2PropertiesItemDesc',
            tableId: "100003001Table2",
            tableName: "BM模板表",
            columnProp: 'itemDesc',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性项目名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001Table2ValueType',
            tableId: "100003001Table2",
            tableName: "BM模板表",
            columnProp: 'valueType',
            headerAlign: "center",
            align: "center",
            columnLabel: '属性值类型',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001Table2DefaultValue',
            tableId: "100003001Table2",
            tableName: "BM模板表",
            columnProp: 'defaultValue',
            headerAlign: "center",
            align: "center",
            columnLabel: '参照值',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 100003001,
            serialNumber: '100003001TableValueChooseFlag',
            tableId: "100003001Table",
            tableName: "common",
            columnProp: 'valueChooseFlag',
            headerAlign: "center",
            align: "center",
            columnLabel: '是否值可选',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
        ],
        levelList:[],
        chooseModalData:{
          site: '',
          itemNo: '',
          itemDesc: '',
          itemType:'',
          valueTypeDb:'',
        },
        editData:{
          site:'',
          buNo:'',
          codeNo:'',
          codeDesc:'',
          editFlag:'',
          active:'',
          propertiesCodeNo:'',
        },
        buList:[],
        editModalFlag:false,
        //---------快速添加----------
        fastAddFlag:false,
        itemList1:[],
        itemList2:[],
        itemListRow1:{},
        itemListRow2:{},
        itemSelections1: [],
        itemSelections2: [],
        rules:{
          codeNoType:[
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          codeDescType:[
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
          activeType:[
            {
              required: true,
              message: ' ',
              trigger: 'change'
            }
          ],
        }
      }
    },
    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 210
      })
    },
    created () {
      this.getDataList();
      this.searchBU()
    },
    methods: {

      // 获取基础数据列表S
      getBaseList (val,type) {
        this.tagNo = val
        this.$nextTick(() => {
          let strVal = ''
          if (val === 21 ) {
            if(this.editData.editFlag==='N'){
              return false;
            }
            strVal = this.editData.propertiesCodeNo
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 21) {
          this.editData.propertiesCodeNo = val.Code_no
        }
      },
      //导出excel
      async createExportData() {
        this.searchData.limit = -1
        this.searchData.page = 1
        await propertiesModelSearchForBM(this.searchData).then(({data}) => {
          this.exportList= data.page.list;
        })
        return this.exportList;
      },
      startDownload() {

      },
      finishDownload() {

      },
      fields() {
        let json = "{"
        this.columnList.forEach((item, index) => {
          if (index == this.columnList.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")
        return s
      },
      // 导出 end
      // 获取数据列表
      getDataList () {
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        propertiesModelSearchForBM(this.searchData).then(({data}) => {
          if (data.code == 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
          }
          this.dataListLoading = false
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      },



      //打开属性清单
      detailModal(row){
        this.detailData.buNo = row.buNo
        this.detailData.codeNo = row.codeNo
        this.detailData.propertiesCodeNo = row.propertiesCodeNo
        this.detailData.codeDesc = row.codeDesc
        this.detailData.functionType = row.functionType
        searchModalDetailsForBM(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
        this.detailModelFlag = true;
      },


      chooseModal(row){
        this.chooseModalData.site = row.site;
        this.chooseModalData.itemNo = row.itemNo;
        this.chooseModalData.itemDesc = row.itemDesc;
        this.chooseModalData.valueTypeDb = row.valueTypeDb;
        this.chooseModalData.itemType=row.functionType;
        searchItemAvailable(this.chooseModalData).then(({data}) => {
          this.chooseTableData = data.rows
        })
        this.chooseModalFlag = true;
      },
      //---------快速添加----------

      queryTemplateItem(){
        getItemListsForBM(this.detailData).then(({data}) => {
          this.itemList1 = data.row1;
          this.itemList2 = data.row2;
        })
      },

      addFastModal(){
        this.itemSelections1 = null
        this.itemSelections2 = null
        getItemListsForBM(this.detailData).then(({data}) => {
          this.itemList1 = data.row1;
          this.itemList2 = data.row2;
        })
        this.fastAddFlag = true;
      },
      // 可选属性
      itemClickRow1(row){
        this.$refs.itemTable1.toggleRowSelection(row);
      },
      // 已有属性
      itemClickRow2(row){
        this.$refs.itemTable2.toggleRowSelection(row);
      },
      selectFlag(){
        return true;
      },
      selectionItem1(val){
        this.itemSelections1 = val
      },
      selectionItem2(val){
        this.itemSelections2 = val
      },
      addItem(){
        if(this.itemSelections1 == null || this.itemSelections1.length == 0){
          this.$alert("请选择可选属性！", '提示', {
            confirmButtonText: '确定'
          })
          return false;
        }
        let inData = {
          site: this.$store.state.user.site,
          buNo: this.detailData.buNo,
          codeNo: this.detailData.codeNo,
          codeDesc: this.detailData.codeDesc,
          functionType: this.detailData.functionType,
          // itemNo: this.itemListRow1.itemNo,
          // itemDesc: this.itemListRow1.itemDesc,
          itemList: this.itemSelections1,
          itemType: this.detailData.itemType,
          userId: this.$store.state.user.name
        }
        saveModalDetailsForBM(inData).then(({data}) => {
          if (data && data.code == 0) {
            getItemListsForBM(this.detailData).then(({data}) => {
              this.itemList1 = data.row1;
              this.itemList2 = data.row2;
            })
            this.itemSelections1 = []
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      deleteItem(){
        if(this.itemSelections2 == null || this.itemSelections2.length == 0){
          this.$alert("请选择已有属性！", '提示', {
            confirmButtonText: '确定'
          })
          return false;
        }
        let inData = {
          site: this.$store.state.user.site,
          buNo: this.detailData.buNo,
          codeNo:this.detailData.codeNo,
          codeDesc:this.detailData.codeDesc,
          functionType:this.detailData.functionType,
          // itemNo: this.itemListRow2.itemNo,
          // itemDesc:this.itemListRow2.itemDesc,
          itemList: this.itemSelections2,
          itemType:this.detailData.itemType,
          userId:this.$store.state.user.name
        }
        deleteModalDetailsForBM(inData).then(({data}) => {
          if (data && data.code === 0) {
            getItemListsForBM(this.detailData).then(({data}) => {
              this.itemList1 = data.row1;
              this.itemList2 = data.row2;
            })
            this.itemSelections2 = []
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      searchBU(){
        let searchData={
          site:this.$store.state.user.site
        }
        getBUList(searchData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code == 0) {
            this.buList = data.rows;
          } else {
            this.buList = [];
          }
        });
      },
      refreshDetailList(){
        searchModalDetailsForBM(this.detailData).then(({data}) => {
          this.detailList = data.rows
        })
      },
      editModal(row){
        this.editData={
          site:row.site,
          buNo:row.buNo,
          codeDesc:row.codeDesc,
          codeNo:row.codeNo,
          editFlag:row.editFlag,
          active:row.active,
          propertiesCodeNo:row.propertiesCodeNo,
        }
        this.editModalFlag=true;
      },
      updateBMModal(){
        updateBMModal(this.editData).then(({data}) => {
          if (data && data.code == 0) {
            this.getDataList()
            this.editModalFlag=false
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {}
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        }).catch(() => {
          return
        })
        // this.$confirm("是否保存信息？", '保存提示', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        // }).then(() => {
        // updateBMModal(this.editData).then(({data}) => {
        //   if (data && data.code == 0) {
        //     this.getDataList()
        //     this.editModalFlag=false
        //     this.$message({
        //       message: '操作成功',
        //       type: 'success',
        //       duration: 1500,
        //       onClose: () => {}
        //     })
        //   } else {
        //     this.$alert(data.msg, '错误', {
        //       confirmButtonText: '确定'
        //     })
        //   }
        // }).catch(() => {
        //   return
        // })
        // })
      },
    }
  }
</script>
