<template>
  <div class="app-container">
    <el-row>
      <el-col :span="22">
        <el-card style="margin: 5px;height: 200px">
          <div style="text-align: center">
            <span class="tv-title">生产时段(整线)</span>
            <el-button type="warning" size="small" icon="el-icon-circle-plus" style="float: right;padding: 5px 8px"
              @click="addPeriod()">添加</el-button>
          </div>
          <el-table :data="periodData" :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
            element-loading-text="数据加载中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.2)" class="main" tooltip-effect="dark" style="width: 100%;"
            height="140px" border size="mini">
            <el-table-column align="center" label="开始时间">
              <template slot-scope="scope">
                {{ scope.row.开始时间 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="结束时间">
              <template slot-scope="scope">
                {{ scope.row.结束时间 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit" @click="setPeriod(scope.row)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" style="color: #ff0000"
                  @click="deletePeriod(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="11">
        <el-card style="margin: 5px;height: 200px">
          <div style="text-align: center">
            <span class="tv-title">TOP问题维护（模组）</span>
            <el-button type="warning" size="small" icon="el-icon-circle-plus" style="float: right;padding: 5px 8px"
              @click="addTopProblem(1)">添加</el-button>
          </div>
          <el-table :data="topProblem_m" :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
            element-loading-text="数据加载中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.2)" class="main" tooltip-effect="dark" style="width: 100%;"
            height="150px" border size="mini">
            <el-table-column align="center" label="内容">
              <template slot-scope="scope">
                {{ scope.row.内容 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit"
                  @click="setTopProblem(scope.row, 1)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" style="color: #ff0000"
                  @click="deleteTopProblem(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
      <el-col :span="11">
        <el-card style="margin: 5px;height: 200px">
          <div style="text-align: center">
            <span class="tv-title">TOP问题维护（PACK）</span>
            <el-button type="warning" size="small" icon="el-icon-circle-plus" style="float: right;padding: 5px 8px"
              @click="addTopProblem(2)">添加</el-button>
          </div>
          <el-table :data="topProblem_p" :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
            element-loading-text="数据加载中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.2)" class="main" tooltip-effect="dark" style="width: 100%;"
            height="150px" border size="mini">
            <el-table-column align="center" label="内容">
              <template slot-scope="scope">
                {{ scope.row.内容 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit"
                  @click="setTopProblem(scope.row, 2)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" style="color: #ff0000"
                  @click="deleteTopProblem(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="11">
        <el-card style="margin: 5px;height: 300px">
          <div style="text-align: center">
            <span class="tv-title">临时问题维护（模组）</span>
            <el-button type="warning" size="small" icon="el-icon-circle-plus" style="float: right;padding: 5px 8px"
              @click="addTempProblem(1)">添加</el-button>
          </div>
          <el-table :data="tempProblem_m" :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
            element-loading-text="数据加载中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.2)" class="main" tooltip-effect="dark" style="width: 100%;"
            height="250px" border size="mini">
            <el-table-column align="center" label="内容">
              <template slot-scope="scope">
                {{ scope.row.内容 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit"
                  @click="setTempProblem(scope.row, 1)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" style="color: #ff0000"
                  @click="deleteTempProblem(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
      <el-col :span="11">
        <el-card style="margin: 5px;height: 300px">
          <div style="text-align: center">
            <span class="tv-title">临时问题维护(PACK)</span>
            <el-button type="warning" size="small" icon="el-icon-circle-plus" style="float: right;padding: 5px 8px"
              @click="addTempProblem(2)">添加</el-button>
          </div>
          <el-table :data="tempProblem_p" :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
            element-loading-text="数据加载中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.2)" class="main" tooltip-effect="dark" style="width: 100%;"
            height="250px" border size="mini">
            <el-table-column align="center" label="内容">
              <template slot-scope="scope">
                {{ scope.row.内容 }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit"
                  @click="setTempProblem(scope.row, 2)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" style="color: #ff0000"
                  @click="deleteTempProblem(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="11">
        <el-card style="margin: 5px;height: 300px">
          <div style="text-align: center">
            <span class="tv-title">底部文字维护</span>
            <el-button type="warning" size="small" icon="el-icon-circle-plus" style="float: right;padding: 5px 8px"
              @click="addSlogan()">添加</el-button>
          </div>
          <el-table :data="slogan" :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
            element-loading-text="数据加载中" element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.2)" class="main" tooltip-effect="dark" style="width: 100%;"
            height="250px" border size="mini">
            <el-table-column align="center" label="内容">
              <template slot-scope="scope">
                {{ scope.row.slogan }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="启用" width="100">
              <template slot-scope="scope">
                <el-checkbox v-model="scope.row.enable" @change="enableSlogan(scope.row)" />
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="150">
              <template slot-scope="scope">
                <el-button size="mini" type="text" icon="el-icon-edit" @click="setSlogan(scope.row)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" style="color: #ff0000"
                  @click="deleteSlogan(scope.row)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
      <el-col :span="11">
        <el-card style="margin: 5px;height: 300px">
          <div style="text-align: center">
            <span class="tv-title">其他参数维护</span>
          </div>
          <div style="max-height: 250px; overflow-y: auto;">
            <el-form label-position="right" label-width="180px">
              <el-row>
                <el-col :span="12">
                  <div v-for="(param, index) in leftParams" :key="'left-' + index" style="margin-bottom: 10px;">
                    <el-form-item :label="param.参数名称" style="margin-bottom: 5px;">
                      <el-input-number v-model="param.参数值" :min="1" :step="1" size="small" style="width: 140px"
                        @change="editOtherParams(param.ID, param.参数值)" />
                    </el-form-item>
                  </div>
                </el-col>
                <el-col :span="12">
                  <div v-for="(param, index) in rightParams" :key="'right-' + index" style="margin-bottom: 10px;">
                    <el-form-item :label="param.参数名称" style="margin-bottom: 5px;">
                      <el-input-number v-model="param.参数值" :min="1" :step="1" size="small" style="width: 140px"
                        @change="editOtherParams(param.ID, param.参数值)" />
                    </el-form-item>
                  </div>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </el-card>
      </el-col>
    </el-row>


    <el-dialog :visible.sync="dialogFormVisible_slogan" :title="title_slogan" center style="min-height: 200px;"
      width="400px">
      <el-form ref="form_slogan" :model="form_slogan" :rules="rules_slogan" label-position="right" label-width="60px">
        <el-form-item label="内容" prop="slogan" style="display: inline-block">
          <el-input v-model="form_slogan.slogan" placeholder="请输入内容" style="width: 250px" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOffSlogan()">取消</el-button>
        <el-button v-if="title_slogan === '添加'" type="primary" size="small" @click="submitAddSlogan()">确定</el-button>
        <el-button v-if="title_slogan === '修改'" type="primary" size="small" @click="submitEditSlogan()">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible_topProblem" :title="title_topProblem" center style="min-height: 200px;"
      width="400px">
      <el-form ref="form_slogan" :model="form_topProblem" :rules="rules_topProblem" label-position="right"
        label-width="80px">
        <el-form-item label="TOP问题" prop="content" style="display: inline-block">
          <el-input v-model="form_topProblem.content" placeholder="请输入TOP问题" style="width: 250px" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOffTopProblem()">取消</el-button>
        <el-button v-if="title_topProblem === '添加'" type="primary" size="small"
          @click="submitAddTopProblem()">确定</el-button>
        <el-button v-if="title_topProblem === '修改'" type="primary" size="small"
          @click="submitEditTopProblem()">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible_tempProblem" :title="title_tempProblem" center
      style="min-height: 200px;" width="400px">
      <el-form ref="form_tempProblem" :model="form_tempProblem" :rules="rules_tempProblem" label-position="right"
        label-width="80px">
        <el-form-item label="临时问题" prop="content" style="display: inline-block">
          <el-input v-model="form_tempProblem.content" placeholder="请输入临时问题" style="width: 250px" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOffTempProblem()">取消</el-button>
        <el-button v-if="title_tempProblem === '添加'" type="primary" size="small"
          @click="submitAddTempProblem()">确定</el-button>
        <el-button v-if="title_tempProblem === '修改'" type="primary" size="small"
          @click="submitEditTempProblem()">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormVisible_period" :title="title_period" center style="min-height: 200px;"
      width="500px">
      <el-form ref="form_period" :model="form_period" :rules="rules_period" label-position="right" label-width="100px">
        <el-form-item label="开始时间" prop="startTime">
          <el-time-picker v-model="form_period.startTime" value-format="HH:mm:ss" placeholder="选择开始时间"
            style="width: 250px" />
        </el-form-item>
        <el-form-item label="结束时间" prop="endTime">
          <el-time-picker v-model="form_period.endTime" value-format="HH:mm:ss" placeholder="选择结束时间"
            style="width: 250px" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="callOffPeriod()">取消</el-button>
        <el-button v-if="title_period === '添加'" type="primary" size="small" @click="submitAddPeriod()">确定</el-button>
        <el-button v-if="title_period === '修改'" type="primary" size="small" @click="submitEditPeriod()">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogFormVisible_slogan: false,
      dialogFormVisible_topProblem: false,
      dialogFormVisible_tempProblem: false,
      dialogFormVisible_period: false,
      title_slogan: '',
      title_topProblem: '',
      title_tempProblem: '',
      title_period: '',
      loading_slogan: false,
      loading_topProblem: false,
      loading_tempProblem: false,
      slogan: [],
      topProblem_m: [],
      topProblem_p: [],
      tempProblem_m: [],
      tempProblem_p: [],
      periodData: [],
      otherParams: [],
      form_slogan: {
        ID: '',
        slogan: ''
      },
      rules_slogan: {
        slogan: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ]
      },
      type: 1, // 1: 模组，2: PACK
      form_topProblem: {
        ID: '',
        content: ''
      },
      rules_topProblem: {
        content: [
          { required: true, message: '请输入TOP问题', trigger: 'blur' }
        ]
      },
      form_tempProblem: {
        ID: '',
        content: ''
      },
      rules_tempProblem: {
        content: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ]
      },
      form_period: {
        ID: '',
        startTime: '',
        endTime: ''
      },
      rules_period: {
        startTime: [
          { required: true, message: '请选择开始时间', trigger: 'change' }
        ],
        endTime: [
          { required: true, message: '请选择结束时间', trigger: 'change' }
        ]
      }
    }
  },
  computed: {
    leftParams() {
      return this.otherParams.filter((param, index) => index % 2 === 0)
    },
    rightParams() {
      return this.otherParams.filter((param, index) => index % 2 === 1)
    }
  },
  watch: {
  },
  created() {
    this.getSlogan()
    this.getTopProblem_m()
    this.getTopProblem_p()
    this.getTempProblem_m()
    this.getTempProblem_p()
    this.getOtherParams()
    this.getPeriod()
  },
  methods: {
    getSlogan() {
      const param = []
      const Data = this.CreateData('11', '基础数据_TV_slogan_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.slogan = []
        for (let i = 0; i < response.data.length; i++) {
          this.slogan.push({ ...response.data[i], enable: response.data[i]['是否启用'] === 1 })
        }
        console.log(this.slogan)
      })
    },
    addSlogan() {
      this.dialogFormVisible_slogan = true
      this.title_slogan = '添加'
      this.form_slogan = {
        ID: '',
        slogan: ''
      }
    },
    setSlogan(row) {
      this.dialogFormVisible_slogan = true
      this.title_slogan = '修改'
      this.form_slogan = {
        ID: row.ID,
        slogan: row.slogan
      }
    },
    enableSlogan(row) {
      const param = []
      param[0] = ['ID', row.ID]
      const Data = this.CreateData('12', '基础数据_TV_slogan_编辑_是否启用', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
        } else {
          this.$message.error('操作失败！')
        }
        this.getSlogan()
      })
    },
    callOffSlogan() {
      this.dialogFormVisible_slogan = false
      this.form_slogan = {
        ID: '',
        slogan: ''
      }
    },
    submitAddSlogan() {
      if (this.form_slogan.slogan === '') {
        this.$message.error('请输入消息内容！')
        return
      }
      const param = []
      param[0] = ['slogan', this.form_slogan.slogan]
      const Data = this.CreateData('12', '基础数据_TV_slogan_增加', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '增加成功',
            type: 'success'
          })
          this.dialogFormVisible_slogan = false
          this.getSlogan()
        } else {
          this.$message.error('增加失败！')
        }
      })
    },
    submitEditSlogan() {
      const param = []
      param[0] = ['ID', this.form_slogan.ID]
      param[1] = ['slogan', this.form_slogan.slogan]
      const Data = this.CreateData('12', '基础数据_TV_slogan_编辑', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.dialogFormVisible_slogan = false
          this.getSlogan()
        } else {
          this.$message.error('编辑失败！')
        }
      })
    },
    deleteSlogan(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['ID', row.ID]
        var Data = this.CreateData('12', '基础数据_TV_slogan_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.getSlogan()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    /** ******************************************************************************************/
    getTopProblem_m() {
      const param = []
      param[0] = ['type', 1]
      const Data = this.CreateData('11', '基础数据_TV_TOP问题_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.topProblem_m = response.data
      })
    },
    getTopProblem_p() {
      const param = []
      param[0] = ['type', 2]
      const Data = this.CreateData('11', '基础数据_TV_TOP问题_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.topProblem_p = response.data
      })
    },
    addTopProblem(type) {
      this.type = type
      this.dialogFormVisible_topProblem = true
      this.title_topProblem = '添加'
      this.form_topProblem = {
        ID: '',
        content: ''
      }
    },
    setTopProblem(row, type) {
      this.type = type
      this.dialogFormVisible_topProblem = true
      this.title_topProblem = '修改'
      this.form_topProblem = {
        ID: row.ID,
        content: row.内容
      }
    },
    callOffTopProblem() {
      this.dialogFormVisible_topProblem = false
      this.form_topProblem = {
        ID: '',
        content: ''
      }
    },
    submitAddTopProblem(formName) {
      if (this.type === 1 && this.topProblem_m.length >= 3) {
        this.$message.error('TOP问题限制三条！')
        return
      }
      if (this.type === 2 && this.topProblem_p.length >= 3) {
        this.$message.error('TOP问题限制三条！')
        return
      }
      if (this.form_topProblem.content === '') {
        this.$message.error('请输入TOP问题内容！')
        return
      }

      const param = []
      param[0] = ['内容', this.form_topProblem.content]
      param[1] = ['type', this.type]
      const Data = this.CreateData('12', '基础数据_TV_TOP问题_增加', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '增加成功',
            type: 'success'
          })
          this.dialogFormVisible_topProblem = false
          this.getTopProblem_m()
          this.getTopProblem_p()
        } else {
          this.$message.error('增加失败！')
        }
      })
    },
    submitEditTopProblem() {
      const param = []
      param[0] = ['ID', this.form_topProblem.ID]
      param[1] = ['内容', this.form_topProblem.content]
      const Data = this.CreateData('12', '基础数据_TV_TOP问题_编辑', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.dialogFormVisible_topProblem = false
          this.getTopProblem_m()
          this.getTopProblem_p()
        } else {
          this.$message.error('编辑失败！')
        }
      })
    },
    deleteTopProblem(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['ID', row.ID]
        var Data = this.CreateData('12', '基础数据_TV_TOP问题_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.getTopProblem_m()
            this.getTopProblem_p()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    /** ******************************************************************************************/
    getTempProblem_m() {
      const param = []
      param[0] = ['type', 1]
      const Data = this.CreateData('11', '基础数据_TV_临时问题_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.tempProblem_m = response.data
      })
    },
    getTempProblem_p() {
      const param = []
      param[0] = ['type', 2]
      const Data = this.CreateData('11', '基础数据_TV_临时问题_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.tempProblem_p = response.data
      })
    },
    addTempProblem(type) {
      this.type = type
      this.dialogFormVisible_tempProblem = true
      this.title_tempProblem = '添加'
      this.form_tempProblem = {
        ID: '',
        content: ''
      }
    },
    setTempProblem(row, type) {
      this.type = type
      this.dialogFormVisible_tempProblem = true
      this.title_tempProblem = '修改'
      this.form_tempProblem = {
        ID: row.ID,
        content: row.内容
      }
    },
    callOffTempProblem() {
      this.dialogFormVisible_tempProblem = false
      this.form_tempProblem = {
        ID: '',
        content: ''
      }
    },
    submitAddTempProblem() {
      if (this.form_tempProblem.content === '') {
        this.$message.error('请输入TOP临时问题内容！')
        return
      }

      const param = []
      param[0] = ['内容', this.form_tempProblem.content]
      param[1] = ['type', this.type]
      const Data = this.CreateData('12', '基础数据_TV_临时问题_增加', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '增加成功',
            type: 'success'
          })
          this.dialogFormVisible_tempProblem = false
          this.getTempProblem_m()
          this.getTempProblem_p()
        } else {
          this.$message.error('增加失败！')
        }
      })
    },
    submitEditTempProblem() {
      const param = []
      param[0] = ['ID', this.form_tempProblem.ID]
      param[1] = ['内容', this.form_tempProblem.content]
      const Data = this.CreateData('12', '基础数据_TV_临时问题_编辑', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.dialogFormVisible_tempProblem = false
          this.getTempProblem_m()
          this.getTempProblem_p()
        } else {
          this.$message.error('编辑失败！')
        }
      })
    },
    deleteTempProblem(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        var param = []
        param[0] = ['ID', row.ID]
        var Data = this.CreateData('12', '基础数据_TV_临时问题_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.getTempProblem_m()
            this.getTempProblem_p()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    /** ******************************************************************************************/
    getOtherParams() {
      const param = []
      const Data = this.CreateData('11', '基础数据_TV_其他参数_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.otherParams = response.data
      })
    },
    editOtherParams(ID, VALUE) {
      const param = []
      param[0] = ['ID', ID]
      param[1] = ['参数值', VALUE]
      const Data = this.CreateData('12', '基础数据_TV_其他参数_编辑', param)
      this.ExecDatabase(Data).then(response => {
        if (response.data[0].result === '1') {
          this.$message({
            message: '编辑成功',
            type: 'success'
          })
          this.getOtherParams()
        } else {
          this.$message.error('编辑失败！')
        }
      })
    },
    /** ******************************************************************************************/
    getPeriod() {
      const param = []
      const Data = this.CreateData('11', '基础数据_TV_生产时段_查询', param)
      this.ExecDatabase(Data).then(response => {
        this.periodData = response.data
      })
    },
    addPeriod() {
      this.dialogFormVisible_period = true
      this.title_period = '添加'
      this.form_period = {
        ID: '',
        startTime: '',
        endTime: ''
      }
      this.$nextTick(() => {
        this.$refs.form_period.clearValidate()
      })
    },
    setPeriod(row) {
      this.dialogFormVisible_period = true
      this.title_period = '修改'
      this.form_period = {
        ID: row.ID,
        startTime: row.开始时间,
        endTime: row.结束时间
      }
      this.$nextTick(() => {
        this.$refs.form_period.clearValidate()
      })
    },
    callOffPeriod() {
      this.dialogFormVisible_period = false
      this.form_period = {
        ID: '',
        startTime: '',
        endTime: ''
      }
    },
    submitAddPeriod() {
      this.$refs.form_period.validate(valid => {
        if (valid) {
          const param = []
          param[0] = ['开始时间', this.form_period.startTime]
          param[1] = ['结束时间', this.form_period.endTime]
          const Data = this.CreateData('12', '基础数据_TV_生产时段_增加', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '增加成功',
                type: 'success'
              })
              this.dialogFormVisible_period = false
              this.getPeriod()
            } else {
              this.$message.error('增加失败！')
            }
          })
        }
      })
    },
    submitEditPeriod() {
      this.$refs.form_period.validate(valid => {
        if (valid) {
          const param = []
          param[0] = ['ID', this.form_period.ID]
          param[1] = ['开始时间', this.form_period.startTime]
          param[2] = ['结束时间', this.form_period.endTime]
          const Data = this.CreateData('12', '基础数据_TV_生产时段_编辑', param)
          this.ExecDatabase(Data).then(response => {
            if (response.data[0].result === '1') {
              this.$message({
                message: '编辑成功',
                type: 'success'
              })
              this.dialogFormVisible_period = false
              this.getPeriod()
            } else {
              this.$message.error('编辑失败！')
            }
          })
        }
      })
    },
    deletePeriod(row) {
      this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const param = []
        param[0] = ['ID', row.ID]
        const Data = this.CreateData('12', '基础数据_TV_生产时段_删除', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data[0].result === '1') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.getPeriod()
          } else {
            this.$message.error('删除失败！')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style scoped>
.tv-title {
  font-size: 20px;
  color: #409eff;
  font-weight: bold;
}
</style>
