<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="订单编号" prop="orderNumber">
        <el-input
          v-model="queryParams.orderNumber"
          placeholder="请输入订单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="菜单编号" prop="menuNumber">
        <el-input
          v-model="queryParams.menuNumber"
          placeholder="请输入菜单编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备编号" prop="deviceNumber">
        <el-input
          v-model="queryParams.deviceNumber"
          placeholder="请输入设备编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户姓名" prop="nickName">
        <el-input
          v-model="queryParams.nickName"
          placeholder="请输入用户姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备名称" prop="deviceName">
        <el-input
          v-model="queryParams.deviceName"
          placeholder="请输入设备名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="时段" prop="periodId">-->
      <!--        <el-select v-model="queryParams.periodId" placeholder="请选择时段" clearable size="small">-->
      <!--          <el-option-->
      <!--            v-for="dict in dict.type.consumption_period"-->
      <!--            :key="dict.value"-->
      <!--            :label="dict.label"-->
      <!--            :value="dict.value"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->
      <el-form-item label="消费模式" prop="patternId">
        <el-select v-model="queryParams.patternId" placeholder="请选择消费模式" clearable size="small">
          <el-option
            v-for="dict in dict.type.consumption_pattern"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!--      <el-form-item label="消费人员类型" prop="consumerType">-->
      <!--        <el-select v-model="queryParams.consumerType" placeholder="请选择消费人员类型" clearable size="small">-->
      <!--          <el-option-->
      <!--            v-for="dict in dict.type.consumption_period"-->
      <!--            :key="dict.value"-->
      <!--            :label="dict.label"-->
      <!--            :value="dict.value"-->
      <!--          />-->
      <!--        </el-select>-->
      <!--      </el-form-item>-->
      <el-form-item label="付款时间">
        <el-date-picker
          v-model="daterangePaytime"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd HH:mm:ss"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="订单状态" prop="zfbz">
        <el-select v-model="queryParams.zfbz" placeholder="请选择订单状态" clearable size="small">
          <el-option
            v-for="dict in dict.type.order_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="就餐地" prop="jcd">
        <el-select v-model="queryParams.placeNumber" placeholder="请选择就餐地" clearable size="small">
          <el-option
            v-for="dict in jcd"
            :key="dict.placeNumber"
            :label="dict.placeName"
            :value="dict.placeNumber"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['canteen:order:add']"
        >后台点餐
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['canteen:order:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="10">
        <div style="padding: 0 20px"></div>
      </el-col>
      <el-col :span="1.5">
        <el-select v-model="tjdc.tjdcMenuCode" placeholder="请选择菜单" @change="changeMenu">
          <el-option
            v-for="item in menus"
            :key="item.menuNumber"
            :label="item.menuName"
            :value="item.menuNumber"
          />
        </el-select>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="clickTjdc"
        >统计导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-data-line"
          size="mini"
          @click="clickJctj"
        >菜单统计
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-data-line"
          size="mini"
          @click="clickMonthJctj"
        >月度统计
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="消费订单id" align="center" prop="orderId" v-if="false"/>
      <el-table-column label="订单编号" align="center" prop="orderNumber">
        <template slot-scope="scope">
          <router-link :to="{path:'/canteen/consume/detail',
          query:{'number':scope.row.orderNumber
                 }}" class="link-type">
            <span>{{ scope.row.orderNumber }}</span>
          </router-link>
        </template>
      </el-table-column>
      <el-table-column label="交易时间" align="center" prop="paytime" width="95">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.paytime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="机构代码" align="center" prop="jgid">
        <template slot-scope="scope">
          {{ orgFormatter(scope.row.jgid) }}
        </template>
      </el-table-column>
      <el-table-column label="消费模式" align="center" prop="patternId">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.consumption_pattern" :value="scope.row.patternId"/>
          <div v-if="!scope.row.menuNumber">
            现场消费
          </div>
        </template>
      </el-table-column>
      <el-table-column label="订单总额" align="center" prop="orderTotal"/>
      <el-table-column label="用户名称" align="center" prop="nickName"/>
      <el-table-column label="用户编码" align="center" prop="userNumber"/>
      <el-table-column label="手机号" align="center" prop="phonenumber"/>
      <el-table-column label="卡号" align="center" prop="cardCode"/>
      <el-table-column label="就餐地" align="center" prop="placeName"/>
      <el-table-column label="设备编号" align="center" prop="deviceNumber"/>
      <el-table-column label="设备名称" align="center" prop="deviceName"/>
      <el-table-column label="菜单编号" align="center" prop="menuNumber"/>
      <el-table-column label="是否记账" align="center" prop="consumeSign">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yes_or_no" :value="scope.row.consumeSign"/>
        </template>
      </el-table-column>
      <el-table-column label="订单状态" align="center" prop="zfbz" width="72">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.order_type" :value="scope.row.zfbz"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="scope.row.zfbz!==3"
                     size="mini"
                     type="text"
                     icon="el-icon-circle-close"
                     @click="handleBack(scope.row)"
                     v-hasPermi="['canteen:order:back']"
          >退单
          </el-button>
          <el-button size="mini" type="text" icon="el-icon-close" @click="handlePartBack(scope.row)"
                     v-if="scope.row.zfbz!==3"
                     v-hasPermi="['canteen:order:back']">因错退还
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改食堂订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <div style="display: flex;align-items: center;justify-content: center;flex-direction:column">
        <div style="width: 90%;">
          <el-form :model="form" ref="queryForm" :inline="true" v-show="showSearch">
            <el-form-item label="菜单" prop="menuNumber">
              <el-select v-model="form.menuNumber" placeholder="请选择菜单" clearable size="small"
                         @change="miwp()">
                <el-option
                  v-for="item in menus"
                  :key="item.menuNumber"
                  :label="item.menuName"
                  :value="item.menuNumber"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="消费人员" prop="loginName">
              <el-select filterable v-model="form.loginName" placeholder="请选择消费人员" multiple clearable
                         size="small" @change="userChang($event)">
                <el-option
                  v-for="item in userList"
                  :key="item.userName"
                  :label="item.phonenumber + '  ' + item.nickName"
                  :value="item.userName + ',' + item.nickName"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="就餐地" prop="jcd">
              <el-select v-model="form.placeNumber" placeholder="请选择就餐地" clearable size="small"
                         @change="jcdChang($event)">
                <el-option
                  v-for="dict in jcd"
                  :key="dict.placeNumber"
                  :label="dict.placeName"
                  :value="dict.placeNumber"
                />
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <div style="width: 90%">
          <el-table border highlight-current-row :data="dataList" :height="tableHeight"
                    @selection-change="cuisineSelectionChange">
            <el-table-column type="selection" width="55" align="center"/>
            <el-table-column label="菜品id" align="center" prop="cuisineId" v-if="false"/>
            <el-table-column label="菜品编号" align="center" prop="cuisineNumber" v-if="false"/>
            <el-table-column label="菜品名称" align="center" prop="cuisineName"/>
            <el-table-column label="菜品图片" align="center" prop="cuisinePictrue">
              <template slot-scope="scope">
                <img style="width:80px;height:80px;border:none;" :src="baseUrl + scope.row.cuisinePictrue">
              </template>
            </el-table-column>
            <el-table-column label="菜品价格" align="center" prop="cuisinePrice">
              <template slot-scope="{row}">
                <div v-if="row.cuisinePrice!==undefined">
                  {{ '￥' + row.cuisinePrice }}
                </div>
                <div v-else>
                  {{ '￥' + 0 }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="启用标志" align="center" prop="qybz" v-if="false">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.qybz"/>
              </template>
            </el-table-column>
            <el-table-column label="是否删除" align="center" prop="isDelete" v-if="false"/>
            <el-table-column label="备注" align="center" prop="remark"/>
          </el-table>
        </div>
        <div style="width: 90%;margin-top: 15px">
          <el-form :model="form" ref="form" :inline="true" v-show="showSearch">
            <el-form-item label="订单总额" prop="orderTotal">
              <div>
                {{ '￥' + form.orderTotal }}
              </div>
            </el-form-item>
          </el-form>
        </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定 下 单</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 因错退还 -->
    <el-dialog :title="title" :visible.sync="wrong" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules">
        <el-row>
          <el-col :span="12">
            <el-form-item label="订单编号" prop="orderNumber" style="width:200px">
              <el-input v-model="form.orderNumber" placeholder="请输入订单编号" disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="菜单编号" prop="menuNumber" style="width:220px">
              <el-input v-model="form.menuNumber" placeholder="请输入菜单编号" disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="订单总额" prop="orderTotal" style="width:200px">
              <el-input v-model="form.orderTotal" placeholder="请输入订单总额" disabled="true"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款时间" prop="paytime" style="width:200px">
              <el-date-picker clearable size="small"
                              v-model="form.paytime"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="选择付款时间" disabled="true">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="line-left-right">
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="退还金额" prop="backTotal" style="width:200px ">
              <el-input v-model="form.backTotal" placeholder="请输入退还金额" @input="search($event)"/>
            </el-form-item>
          </el-col>
          <!--<el-col :span="12">
      <el-form-item label="剩余金额" prop="leftTotal" style="width:200px">
        <el-input v-model="form.leftTotal"  disabled="true"  />
      </el-form-item>
        </el-col>-->
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm2">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="tjdc.tjdcTiele" :visible.sync="tjdcOpen" append-to-body v-dialogDrag>
      <el-row>
        <el-col>
          <el-button type="warning"
                     plain
                     icon="el-icon-download"
                     size="mini"
                     :loading="exportLoading"
                     @click="clickTjdcjdcExport()">导出
          </el-button>
        </el-col>
      </el-row>
      <el-table :data="tjdcList" v-loading="loading" style="padding: 15px">
        <el-table-column width="155" align="center" label="用户编号" prop="ucode"></el-table-column>
        <el-table-column width="155" align="center" label="姓名" prop="uname"></el-table-column>
        <el-table-column width="155" align="center" label="就餐地" prop="jcd"></el-table-column>
        <el-table-column align="center" label="菜品信息" prop="foodInformation"></el-table-column>
      </el-table>
    </el-dialog>


    <el-dialog title="就餐统计" :visible.sync="jctj" width="900px" append-to-body>
      <jcdStat ref="jcdStat" :menuNumber="tjdc.tjdcMenuCode"></jcdStat>
    </el-dialog>

    <el-dialog title="月度统计" :visible.sync="monthJctj" :fullscreen="true" append-to-body>
      <jcdMonthlyStat ref="jcdStat" :menuNumber="tjdc.tjdcMenuCode"></jcdMonthlyStat>
    </el-dialog>
  </div>
</template>

<script>


import {
  listOrder,
  getOrder,
  delOrder,
  addOrder,
  updateOrder,
  exportOrder,
  tjdcExport,
  backOrder,
  partbackOrder,
  getPlace,
  tjdcList,
  payMiwp
} from '@/api/canteen/order'
import user from '@/store/modules/user'
import {addCuisineforMenu, miwp, listRegister, menus} from '@/api/canteen/register'
import {queryUser} from '@/api/system/user'
import jcdStat from "@/views/canteen/order/jcdStat";
import jcdMonthlyStat from "@/views/canteen/order/jcdMonthlyStat";

export default {
  name: 'Order',
  components: {
    jcdStat: jcdStat,
    jcdMonthlyStat: jcdMonthlyStat
  },
  dicts: ['consumption_period', 'consumption_pattern', 'consumption_period', 'yes_or_no', 'order_type', 'sys_normal_disable'],
  data() {
    return {
      tableHeight: document.documentElement.scrollHeight - 345 + 'px',
      tjdcOpen: false,
      tjdc: {
        tjdcMenuCode: '',
        tjdcTiele: ''
      },
      userList: [],
      tjdcList: [],
      menus: [],
      wrong: false,
      jctj: false,
      monthJctj: false,
      search: '',
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 食堂订单表格数据
      orderList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 作废标志时间范围
      daterangePaytime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNumber: null,
        menuNumber: null,
        deviceNumber: null,
        deviceName: null,
        nickName: null,
        placeNumber: null,
        // periodId: null,
        // patternId: null,
        // consumerType: null,
        paytime: new Date(),
        zfbz: null,
        jgid: null
      },
      jcd: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      dataList: [],
      baseUrl: process.env.VUE_APP_BASE_API,
      registerList: [],
      cuisine_ids: []
    }
  },
  created() {
    this.getList()
    this.getPlaceList()
    this.getMenuList()
    this.miwp()
    this.queryNickName()
  },
  methods: {
    jcdChang(val) {
      this.form.placeName = val.placeName
    },
    userChang(val) {
      this.form.nickName = val.nickName
    },
    queryNickName() {
      queryUser().then(response => {
        if (response.code === 200) {
          this.userList = response.data
          // this.userList.forEach(item =>{
          //   item.value = item.phonenumber + '  ' + item.nickName;
          // })
        }
      })
    },
    cuisineSelectionChange(selection) {
      this.cuisine_ids = selection
      let ls = 0
      for (let i = 0; i < selection.length; i++) {
        if (selection[i].cuisinePrice) {
          ls += selection[i].cuisinePrice
        }
      }
      this.form.list = selection
      this.form.orderTotal = ls
    },
    miwp() {
      this.form.jgid = user.state.organ
      miwp(this.form).then((response) => {
        this.dataList = response.data
      })
    },
    clickTjdcjdcExport() {
      this.$modal.confirm('是否确认导出菜单统计信息？').then(() => {
        this.exportLoading = true
        return tjdcExport(this.tjdc)
      }).then(response => {
        this.$download.name(response.msg)
        this.exportLoading = false
      }).catch(() => {
      })
    },
    clickTjdc() {
      this.tjdcList = []
      this.tjdcOpen = true
      this.loading = true
      tjdcList(this.tjdc).then(re => {
        this.tjdcList = re.data
        this.loading = false
      })
    },
    clickJctj() {
      this.jctj = true
      console.log(this.$refs);
      setTimeout(() => {
        this.$refs.jcdStat.getJcdTj()
      }, 100)
    },
    clickMonthJctj() {
      this.monthJctj = true
      // console.log(this.$refs);
      // setTimeout(() => {
      //   this.$refs.jcdStat.getJcdTj()
      // }, 100)
    },
    changeMenu(val) {
      console.dir(val)
      if (val !== '') {
        this.menus.map(item => {
          if (item.menuNumber === val) {
            this.tjdc.tjdcTiele = item.menuName
          }
        })
      }
    },
    getMenuList() {
      const queryJgxx = {
        jgid: user.state.organ
      }
      menus(queryJgxx).then((response) => {
        this.menus = response.rows
      })
    },
    getPlaceList() {
      var data = {
        organizationCode: user.state.organ
      }
      getPlace(data).then(re => {
        this.jcd = re.data
        console.log(re.data)
      })
    },
    /** 查询食堂订单列表 */
    getList() {
      this.queryParams.jgid = user.state.organ
      this.loading = true
      this.queryParams.params = {}
      if (null != this.daterangePaytime && '' !== this.daterangePaytime) {
        this.queryParams.params['beginPaytime'] = this.daterangePaytime[0]
        this.queryParams.params['endPaytime'] = this.daterangePaytime[1]
      }
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.wrong = false
      this.reset()
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        orderNumber: null,
        menuNumber: null,
        orderTotal: 0,
        backTotal: null,
        deviceNumber: null,
        deviceName: null,
        // periodId: null,
        // patternId: null,
        // consumerType: null,
        paytime: null,
        zfbz: null,
        isDelete: null,
        jgid: null
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangePaytime = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '后台手动批量点餐'
      this.form.jgid = user.state.organ
      this.miwp()
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const orderId = row.orderId || this.ids
      getOrder(orderId).then(response => {
        this.form = response.data
        this.open = true
        this.title = '修改食堂订单'
      })
    },

    handlePartBack(row) {
      this.reset()
      const orderId = row.orderId || this.ids
      getOrder(orderId).then(response => {
        this.form = response.data
        this.wrong = true
        this.title = '退还订单详情'
      })
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          payMiwp(this.form).then(response => {
            this.$modal.msgSuccess('成功')
            this.open = false
            this.getList()
          })
        }
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids
      this.$modal.confirm('是否确认删除食堂订单编号为"' + orderIds + '"的数据项？').then(function () {
        return delOrder(orderIds)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    /** 作废按钮操作 */
    handleBack(row) {
      const orderIds = row.orderId || this.ids
      this.$modal.confirm('是否作废食堂订单编号为"' + orderIds + '"的数据项？').then(function () {
        return backOrder(row)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('作废成功')
      }).catch(() => {
      })
    },
    search: function (event) {
      //方法一：直接通过event.data可以获得文本内容
      if (event.data != null) {
        this.form.leftTotal = parseFloat(this.form.orderTotal) - parseFloat(event.data)
      }
    },
    submitForm2() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.orderId != null) {
            if (this.form.zfbz === 2) {
              this.form.orderTotal = this.form.backTotal
              partbackOrder(this.form).then(response => {
                this.$modal.msgSuccess('退还成功')
                this.open = false
                this.wrong = false
                this.getList()
              })
            } else {
              this.$modal.msgError('订单未取餐，不可因错退还')
            }
          } else {
            this.wrong = false
            this.getList()
          }
        }
      })
    },

    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams
      this.$modal.confirm('是否确认导出所有食堂订单数据项？').then(() => {
        this.exportLoading = true
        return exportOrder(queryParams)
      }).then(response => {
        this.$download.name(response.msg)
        this.exportLoading = false
      }).catch(() => {
      })
    },
    orgFormatter(val) {
      let name = ''
      user.state.organDicts.forEach(item => {
        if (item.deptCode == val) {
          name = item.deptName
        }
      })
      return name
    }
  }
}
</script>

<style>
.line-left-right {
  line-height: 1px;
  border-left: 510px solid rgb(221, 221, 221);
  text-align: center;
  height: 2px;
}

.redItem {
  color: #fff;
}
</style>
