<template>
  <div>
    <div class="d-flex flex-between">
      <div></div>

      <el-form label-width="100px" :inline="true">
        <el-form-item prop="state_value">
          <el-select class="mr10" v-model="state_value" placeholder="请选择类别">
            <el-option v-for="item in type_list" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="keyword">
          <el-input placeholder="请输入搜索关键字" v-model="keyword" clearable @clear="getListData">
          </el-input>
        </el-form-item>
        <el-button type="primary" class="ml5" @click="getListData">搜索</el-button>
      </el-form>
    </div>

    <el-table :data="applyTable" tooltip-effect="dark" v-loading="loading" style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" width="55"></el-table-column>
      <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
      <el-table-column label="类型" show-overflow-tooltip prop="lb_name" width="auto"></el-table-column>
      <el-table-column label="标题" show-overflow-tooltip prop="gw_title"></el-table-column>
      <el-table-column label="发文字号" show-overflow-tooltip >
        <template slot-scope="scope">
          {{scope.row.gw_zh}}
        </template>
      </el-table-column>
      <el-table-column label="发起人" show-overflow-tooltip prop="gw_fqr_name"></el-table-column>
      <el-table-column label="发起科室" show-overflow-tooltip prop="gw_fqks_name"></el-table-column>
      <el-table-column label="发起时间" show-overflow-tooltip prop="create_dateline"></el-table-column>
      <el-table-column label="当前步骤" >
        <template slot-scope="scope">
          {{scope.row.gw_bz!='' ? scope.row.gw_bz : '--'}}
        </template>
      </el-table-column>
      <el-table-column label="当前审核人" >
        <template slot-scope="scope">
          {{scope.row.gw_shr!='' ? scope.row.gw_shr : '--'}}
        </template>
      </el-table-column>
      <el-table-column label="状态">
        <template slot-scope="scope">
          <div>
            {{scope.row.gw_status}}
          </div>
          <!-- <div :class="scope.row.xm_status_option_k=='4' ? 'red' : (scope.row.xm_status_option_k=='3' ? 'blue' : ' ') ">
                {{scope.row.xm_status}}
              </div> -->
        </template>
      </el-table-column>
      <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-popover placement="left" width="185" trigger="click" v-if="scope.row.gw_status_option_k=='1'">
            <!--待提交-->
            <el-button type="text" @click="reviewShow(scope.row)">预览</el-button>
            <el-button type="text" @click="editShow(scope.row,'edit')">编辑</el-button>
            <el-button type="text" @click="applyCheck(scope.row)">提交</el-button>
            <el-button type="text" @click="delData(scope.row)">删除</el-button>
            <div slot="reference" class="optionMore" style="padding-left:10%;">
              <img src="../../../assets/icon/optionIcon.png" style="width:3%;" alt="">
            </div>
          </el-popover>

          <el-popover placement="left" width="240" trigger="click" v-if="scope.row.gw_status_option_k=='2'">
            <el-button type="text" @click="reviewShow(scope.row)">详情</el-button>
            <el-button type="text" @click="editShow(scope.row,'edit')">编辑</el-button>
            <!-- <el-button type="text" @click="applyCheck(scope.row)">重新提交</el-button> -->
            <el-button type="text" @click="higSpeed(scope.row)">催办</el-button>
            <el-button type="text" @click="delData(scope.row)">删除</el-button>
            <div slot="reference" class="optionMore" style="padding-left:10%;">
              <img src="../../../assets/icon/optionIcon.png" style="width:3%;" alt="">
            </div>
          </el-popover>

          <el-popover placement="left" width="185" trigger="click" v-if="scope.row.gw_status_option_k=='3'">
            <el-button type="text" @click="reviewShow(scope.row)">详情</el-button>
            <el-button type="text" @click="checkRecord(scope.row)">审批记录</el-button>
            <el-button type="text" @click="higSpeed(scope.row)">催办</el-button>
            <div slot="reference" class="optionMore" style="padding-left:10%;">
              <img src="../../../assets/icon/optionIcon.png" style="width:3%;" alt="">
            </div>
          </el-popover>

          <el-popover placement="left" width="240" trigger="click" v-if="scope.row.gw_status_option_k=='4'">
            <el-button type="text" @click="reviewShow(scope.row)">详情</el-button>
            <el-button type="text" @click="checkRecord(scope.row)">审批记录</el-button>
            <el-button type="text" @click="editShow(scope.row,'reEdit')">重新进行拟稿</el-button>
            <div slot="reference" class="optionMore" style="padding-left:10%;">
              <img src="../../../assets/icon/optionIcon.png" style="width:3%;" alt="">
            </div>
          </el-popover>

          <el-popover placement="left" width="45" trigger="click" v-if="scope.row.gw_status_option_k=='5'">
            <el-button type="text" @click="reviewShow(scope.row)">详情</el-button>
            <el-button type="text" @click="checkRecord(scope.row)">审批记录</el-button>
            <div slot="reference" class="optionMore" style="padding-left:10%;">
              <img src="../../../assets/icon/optionIcon.png" style="width:3%;" alt="">
            </div>
          </el-popover>

        </template>
      </el-table-column>
    </el-table>

    <footer class="flex-item-none" style="display: flex; justify-content: flex-end; margin-top: 30px">
      <el-pagination background layout="total,prev, pager, next" :page-size="limit" :total="total"
        :current-page.sync="cur_page" @current-change="handleCurrentChange"></el-pagination>
    </footer>




    <!-- diglog-详情框 -->
    <el-dialog title="预览/详情" :visible.sync="dialogVisible_detail" width="210mm">
      <div>
        <div class="onlineShow" v-if="singleData.gw_ylfj_pdf">
           <iframe  :src="prefixPDFUrl+singleData.gw_ylfj_pdf" v-if="singleData.gw_ylfj_pdf" style="width:100%;min-height:600px;border:0;"  name="ifrmname" id="ifrmid" ></iframe>
        </div>
        <div class="posiR webDialogReview"  v-else>
          <div class="titleHeader" >
            <div style="text-align:center;">
              <img src="../../../assets/images/fileTitle1.png" alt="" v-if="singleData.lb_id==1">
              <img src="../../../assets/images/fileTitle2.png" alt="" v-else-if="singleData.lb_id==2">
              <img src="../../../assets/images/fileTitle3.png" alt="" v-else-if="singleData.lb_id==3">
              <img src="../../../assets/images/fileTitle4.png" alt="" v-else-if="singleData.lb_id==4">
              <img src="../../../assets/images/fileTitle5.png" alt="" v-else-if="singleData.lb_id==5">
              <img src="../../../assets/images/fileTitle6.png" alt="" v-else>
            </div>

            <div class="secPart">{{singleData.gw_zh}}</div>
            <h3>{{singleData.gw_title}}</h3>
            <p class="GWDetail" v-html="singleData.gw_content"></p>
          </div>
          <div class="footerInfo">
            <p>景宁畲族自治县教育局</p>
            <p>{{singleData.fb_dateline}}</p>
          </div>
          <div class="reaFooter">
            <div class="reaFooter_left">{{singleData.gw_fqks_name}}</div>
            <div class="reaFooter_right">{{singleData.fb_dateline}}印发</div>
          </div>


        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible_detail = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible_detail = false">确 定</el-button>
      </span>
    </el-dialog>

    <!-- dialog-审批记录 -->
    <el-dialog title="审批记录" :visible.sync="dialogTableVisible_record">
      <el-table :data="gridData">
        <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
        <el-table-column property="sh_dept_name" label="步骤名称"  show-overflow-tooltip></el-table-column>
        <el-table-column property="sh_user_name" label="审核人" ></el-table-column>
        <el-table-column property="modify_dateline" label="审核时间" show-overflow-tooltip></el-table-column>
        <el-table-column property="cz" label="操作" show-overflow-tooltip>
          <template slot-scope="scope">
            <div>
              {{scope.row.sh_status=='2' ? '通过' : (scope.row.sh_status=='1' ? '待处理' : '不通过')}}
            </div>
          </template>
        </el-table-column>
        <el-table-column property="sh_reason" label="处理意见"></el-table-column>
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogTableVisible_record = false">取 消</el-button>
        <el-button type="primary" @click="dialogTableVisible_record = false">确 定</el-button>
      </div>
    </el-dialog>

    <!-- dialog-编辑发文拟稿 -->
    <el-dialog title="编辑发文拟稿" :visible.sync="dialogFormVisible_fwng" width="50%">
      <el-form :model="dialogForm_fwng" label-width="120px" label-position="left"  ref="addForm_fwng" :rules="rules_check_fwng">
        <el-form-item label="类型" prop="lxObj">
          <el-select v-model="dialogForm_fwng.lxObj" placeholder="请选择类型" @change="switchLBData" style="width:100%;" filterable>
             <el-option v-for="item in lxLIST " :key="item.value+ Math.random()" :label="item.label"
              :value="item" >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="标题" prop="bt">
          <el-input v-model="dialogForm_fwng.bt" placeholder="请输入标题"></el-input>
        </el-form-item>
        <el-form-item label="发文字号" prop="fwzh">
          <el-input v-model="dialogForm_fwng.fwzh" placeholder="发文字号自动填充：例如：景教函〔2022〕001号" disabled>
          </el-input>
        </el-form-item>
        <el-form-item label="发起人" prop="fqrObj">
          <el-select v-model="dialogForm_fwng.fqrObj" placeholder="请选择发起人" style="width:100%;" filterable>
            <el-option v-for="item in userLIST " :key="item.value+ Math.random()" :label="item.label"
              :value="item" >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发起科室" prop="fqksObj">
          <el-select v-model="dialogForm_fwng.fqksObj" placeholder="请选择发起科室" style="width:100%;" filterable  @change="KsLinkLc">
            <el-option v-for="item in orgLIST " :key="item.value+ Math.random()" :label="item.label"
              :value="item" >
            </el-option>
          </el-select>
        </el-form-item>
         <el-form-item label="关联流程" prop="gllcObj">
          <el-select style="width: 100%" v-model="dialogForm_fwng.gllcObj" placeholder="请选择关联流程" filterable >
            <el-option v-for="item in lcglLIST " :key="item.value+ Math.random()" :label="item.label"
              :value="{value:item.value,label:item.label}">
            </el-option>
          </el-select>
        </el-form-item>
         <el-form-item label="正文" prop="zw">
          <!-- <el-input type="textarea" v-model="dialogForm_fwng.zw" placeholder="请输入正文" :rows="3"></el-input> -->
          <Tinymce v-if="dialogFormVisible_fwng" v-model="dialogForm_fwng.zw" :height="300" :key="timestamp"></Tinymce>
        </el-form-item>
        <el-form-item label="附件"  >
          <FileUpload :limit="1" v-if="dialogFormVisible_fwng" :full.sync="dialogForm_fwng.fj" :key="timestamp" >
            <div slot="tip" class="el-upload__tip">
              支持文件类型:doc(.docx)、.ppt(.pptx)、.xls(.xlsx)、.pps、.wps、.pdf、.txt文件格式。
            </div>
          </FileUpload>
        </el-form-item>

      </el-form>
      <div slot="footer">
        <el-button @click="dialogFormVisible_fwng=false;">取 消</el-button>
        <el-button type="primary" @click="formSubmit_fwng('addForm_fwng')">确 定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { wdfw_list, wdfw_add, wdfw_edit, wdfw_del, wdfw_detail, xmlb_list,fwng_add, gwglLcgl_List,fwng_lb_list,get_gwzh,org_list, org_users } from "./itemApi";
import { useUserStore } from "@/stores/user";
const { real_name, user_id, dept_ids } = useUserStore();
import Tinymce from "@/components/TinymceVue/index.vue";
import FileUpload from "@/components/FileUpload/index.vue";
export default {
  name: "xmsq",
  components: {
    Tinymce,
    FileUpload
  },
  data() {
    return {
      state_value: "",
      keyword: "",
      /**
       * 1待提交 2已提交 3审核中 4不通过5已通过
      */
      type_list: [
        {
          label: '全部',
          value: '0'
        },{
          label: '待提交',
          value: '1'
        },{
          label: '已提交',
          value: '2'
        },{
          label: '审核中',
          value: '3'
        },{
          label: '不通过',
          value: '4'
        },{
          label: '已通过',
          value: '5'
        }
      ],
      applyTable: [],
      limit: 10,
      total: 0,
      cur_page: 1,
      xmlbLIST: [],
      orgLIST: [],
      lxLIST:[],
      userLIST:[],
      lcglLIST:[],
      dialogForm: {
        xmmc: '',
        xmlb: '',
        xmlb_id: '',
        xmly: '',
        sqks: '',
        xmys: '',
        sbsj: '',
        xmnr: '',
        xmfs: '',
        xmfj: '',
      },
      rules: {
        xmmc: [
          { required: true, message: '请输入项目名称', trigger: 'blur' }
        ],
        xmlb: [
          { required: true, message: '请选择项目类别', trigger: 'change' }
        ],
        xmly: [
          { required: true, message: '请输入项目理由', trigger: 'blur' }
        ],
        sqks: [
          { required: true, message: '请选择申请科室', trigger: 'change' }
        ],
        xmys: [
          { required: true, message: '请输入项目预算', trigger: 'blur' }
        ],
        sbsj: [
          { required: true, message: '请选择申报时间', trigger: 'change' }
        ],
        xmnr: [
          { required: true, message: '请输入项目内容', trigger: 'blur' }
        ],
        xmfs: [
          { required: true, message: '请输入项目方式', trigger: 'blur' }
        ],
      },
      money: 0,
      totalMoney: 0,
      multipleSelection: [],
      isEdit: false,
      id: "",
      loading: false,
      userList: [],
      dialogForm_check: {
        shjg: '',
        clyj: '',
      },
      rules_check: {
        shjg: [
          { required: true, message: '请选择审核结果', trigger: 'change' }
        ],
        clyj: [
          { required: true, message: '请输入处理意见', trigger: 'blur' }
        ]
      },
      xmlbId: '',
      checkID: '',

      dialogVisible_detail: false,
      dialogTableVisible_record: false,
      gridData: [],
      singleData:'',

      dialogFormVisible_fwng: false,
      dialogForm_fwng: {
        lxObj: '',
        bt: '',
        fwzh:'',
        fqrObj: '',
        fqksObj: '',
        gllcObj:'',
        zw: '',
        fj:'',
      },
      rules_check_fwng: {
        lxObj: [
          { required: true, message: '请选择类型', trigger: 'change'}
        ],
        bt: [
          { required: true, message: '请输入标题', trigger: 'blur'}
        ],
        fwzh: [
          { required: true, message: '请规范输入发文字号', trigger: 'blur'}
        ],
        fqrObj: [
          { required: true, message: '请选择发起人', trigger: 'change'}
        ],
        fqksObj: [
          { required: true, message: '请选择发起科室', trigger: 'change'}
        ],
        gllcObj:[
          {required: true, message: '请选择关联科室', trigger: 'change'}
        ],
        zw: [
          { required: true, message: '请输入正文', trigger: 'blur'}
        ],
        fj:[
          { required: true, message: '请上传附件', trigger: 'blur'}
        ]
      },
      timestamp: Date.now(),
      gwId:'',
      reEdit: '',
      prefixPDFUrl:window.globalVariables.api+'/plugins/pdf.js/web/viewer2.html?file=',
    };
  },
  mounted() {
    this.getListData();
  },
  methods: {
    //获取用户列表
    getUserList() {
      let data = {
        dept_id: dept_ids[0],
        page: 1,
        limit: 9999
      }
      org_users(data).then(res => {
        if (res.code == 1) {
          this.userList = res.data.page_data;
        }
      })
    },
    //组织机构列表
    orgList() {
      let transObjs = {
        limit:999
      }
      org_list(transObjs)
        .then(res => {
          if (res.code == "1") {
            let singleData = res.data.page_data;
            singleData.forEach(item => {
              this.orgLIST.push({
                label: item.uo_name,
                value: item.uo_id
              })
            });
          }
        })
        .catch(err => { console.log(err) });
    },
     //开启的类别
    lbList() {
      let transObj = {
        lb_status:1
      };
      fwng_lb_list(transObj).then((res) => {
        if (res.code == "1") {
          this.lxLIST = [];
          res.data.page_data.forEach(item => {
            this.lxLIST.push({
              label: item.lb_name,
              value: item.lb_id
            })
          });
        }
      });
    },
    getListData() {
      this.loading = true;
      let transObj = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        xm_status: this.state_value,
        my_gw:1,
      };
      wdfw_list(transObj).then((res) => {
        this.loading = false;
        if (res.code == "1") {
          this.applyTable = res.data.page_data;
          this.cur_page = Number(res.data.page_now);
          this.total = Number(res.data.total_rows);
        }
      });
    },
    //操作模块-预览
    reviewShow(item) {
      // 预览显示
      let transObj = {
        gw_id:item.gw_id
      }
      wdfw_detail(transObj)
      .then(res => {
        if (res.code == "1") {
          this.singleData = res.data.one_info;
          this.dialogVisible_detail = true;
        }
      })
      .catch(err=>{console.log(err)})
    },
    //操作模块-编辑
    editShow(item, mark) {
      if (mark == 'edit') {
        this.reEdit = false;
      }else{
        this.reEdit = true;
      }
      this.isEdit = true;
      this.userLIST = [{
        label:real_name,value:user_id
      }]
      //请求数据回填
      this.chooseID = item.xm_id;
      this.gwId = item.gw_id;
      let transObj = {
        gw_id: item.gw_id
      }
      wdfw_detail(transObj)
        .then(res => {
          if (res.code == "1") {
            let singleData = res.data.one_info;
            let linkObj = { label:singleData.gw_fqks_name,value:singleData.gw_fqks_id}
             this.KsLinkLc(linkObj)
            this.dialogForm_fwng = {
              lxObj: { label:singleData.lb_name,value:singleData.lb_id},
              bt: singleData.gw_title,
              fwzh:singleData.gw_zh,
              fqrObj: {label:real_name,value:user_id},
              fqksObj: {label:singleData.gw_fqks_name,value:singleData.gw_fqks_id},
              gllcObj: {label:singleData.lc_name,value:singleData.lc_id},
              zw: singleData.gw_content,
              fj: singleData.gw_fj,
            };
            this.dialogFormVisible_fwng = true;
          }
        })
        .catch(err => { console.log(err) })
        this.lbList();
        // this.getUserList();
        this.orgList();
    },
    //选择类别
    switchLBData(val) {
      let transObj = {
        issubmit:1,
        lb_id: val.value,
      }
      get_gwzh(transObj)
      .then(res => {
        if (res.code == 1) {
          this.dialogForm_fwng.fwzh = res.data.data;
        } else {
          this.$message({
            message: res.msg,
            type: "error",
          });
        }
      })
      .catch(err=>{console.log(err)})
    },
    //发文拟稿_提交
    formSubmit_fwng(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let transObj={
            issubmit: 1,
            jdbg_gwgl_gw: {
              lb_name: this.dialogForm_fwng.lxObj.label,//类别名称
              lb_id:this.dialogForm_fwng.lxObj.value,//类别id
              gw_title: this.dialogForm_fwng.bt,// 公文名称

              gw_zh:this.dialogForm_fwng.fwzh,//发文字号(拼合)

              gw_fqr_name: this.dialogForm_fwng.fqrObj.label,//发起人姓名
              gw_fqks_name: this.dialogForm_fwng.fqksObj.label,//发起科室名称
              gw_fqks_id: this.dialogForm_fwng.fqksObj.value,//发起科室id
              gw_content: this.dialogForm_fwng.zw,//正文
              gw_fj: this.dialogForm_fwng.fj,//公文附件
              lc_id:this.dialogForm_fwng.gllcObj.value,
            }
          }
          if (!this.isEdit) {//新增
            fwng_add(transObj)
            .then(res => {
              if (res.code == "1") {
                this.$message({
                  message: res.msg,
                  type: "success",
                });
                this.getListData()
                this.dialogFormVisible_fwng = false;
              } else {
                this.$message({
                    message: res.msg,
                    type: "error",
                  });
              }
            })
            .catch(err=>{console.log(err)})
          } else {
            if (this.reEdit) {
              transObj.gw_id = this.gwId;
              transObj.jdbg_gwgl_gw.gw_status = 2;
            }else{
              transObj.gw_id = this.gwId;
            }
            wdfw_edit(transObj)
              .then(res => {
                if (res.code == "1") {
                  this.$message({
                    message: res.msg,
                    type: "success",
                  });
                  this.getListData()
                  this.dialogFormVisible_fwng = false;
                }
              })
              .catch(err=>{console.log(err)})
          }

        }
      })
    },
    //详情
    detailShow(item) {
      let chooseID = item.xm_id;
      this.$router.push({ name: "xmlxsb_xmsq_xq", params: { id: chooseID } });
    },
    //提交审核
    applyCheck(item) {
      let transObj = {
        issubmit: 1,
        gw_id: item.gw_id,
        jdbg_gwgl_gw: {
          gw_status: 2
        }
      }
      wdfw_edit(transObj)
        .then(res => {
          if (res.code == "1") {
            this.$message({
              message: res.msg,
              type: "success",
            });
            this.getListData();
          } else {
            this.$message({
              message: res.msg,
              type: "error",
            });
          }
        })
        .catch(err => { console.log(err) })
    },
    //审批记录
    checkRecord(item) {
      let transObj = {
        gw_id: item.gw_id
      }
      wdfw_detail(transObj)
        .then(res => {
          if (res.code == "1") {
            let singleData = res.data.one_info;
            this.gridData = res.data.one_info.shjl;
          }
        })
        .catch(err=>{console.log(err)})
      this.dialogTableVisible_record = true;
    },
    //重新拟稿
    reNG(item) {
      this.delData(item);
    },
    //删除
    delData(item) {
      let transObj = {
        gw_id: item.gw_id
      };
      this.$confirm("确认删除该申请?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          wdfw_del(transObj).then((res) => {
            if (res.code == 1) {
              this.$message({
                message: "申请删除成功！",
                type: "success",
              });
              this.getListData();
            } else {
              this.$message({
                message: res.msg,
                type: "error",
              });
            }
          });
        })
        .catch(() => { });
    },
    //催办
    higSpeed(item) {
      let transObj = {
        issubmit: 1,
        gw_id: item.gw_id,
        jdbg_gwgl_gw: {
          gw_cb: 1
        }
      }
      wdfw_edit(transObj)
        .then(res => {
          if (res.code == "1") {
            this.$message({
              message: res.msg,
              type: "success",
            });
            this.getListData();
          } else {
            this.$message({
              message: res.msg,
              type: "error",
            });
          }
        })
        .catch(err => { console.log(err) })
    },
    //打印表单
    printForm(item) {
      let chooseID = 1;
      this.$router.push({ name: "xmlxsb_xmsq_dybb", params: { id: chooseID } });
    },
    //弹出审核dialog
    myCheckSwitch(item) {
      this.checkID = item.sh_id;
      this.dialogFormVisible_check = true;
    },
    //多选
    handleSelectionChange(val) {
      this.multipleSelection = [];
      this.multipleSelection = val;
    },
    //项目类别列表数据
    xmlbList() {
      xmlb_list({})
        .then(res => {
          if (res.code == "1") {
            this.xmlbLIST = [];
            res.data.page_data.forEach(item => {
              this.xmlbLIST.push({
                label: item.lb_name,
                value: item.lb_id,
              })
            })
          }
        })
        .catch(err => {
          console.log(error)
        })
    },
    //项目立项申报
    addFormSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.loading = true;
          let transObj = {
            issubmit: 1,
            jdbg_xmlxsb_xmsq: {
              xm_name: this.dialogForm.xmmc,
              lb_name: this.dialogForm.xmlb.label,//类别名称
              lb_id: this.dialogForm.xmlb.value,//类别id
              xm_reason: this.dialogForm.xmly,//理由
              dept_name: this.dialogForm.sqks.label,//部门名称
              dept_id: this.dialogForm.sqks.value,//部门id
              xm_content: this.dialogForm.xmnr,//内容
              xm_file: this.dialogForm.xmfj,// 附件
              xm_type: this.dialogForm.xmfs,//项目方式
              xm_price: this.dialogForm.xmys,//预算
              xm_sbsj: this.dialogForm.sbsj,//申报时间
              xm_status: "",//状态
              xm_fp_user: "",//分配用户
              xm_is_wc: "",//是否完成1是2否
              xm_shlc: "",//审核流程

            }
          }
          console.log(transObj, "提交参数");
          if (!this.isEdit) {
            xmsq_add(transObj).then(res => {
              this.loading = false;
              if (res.code == 1) {
                this.$message({
                  message: res.msg,
                  type: "success",
                });
                this.dialogFormVisible = false;
                this.getListData();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                });
              }
            })
          } else {//编辑
            let transObj = {
              issubmit: 1,
              xm_id: this.chooseID,
              jdbg_xmlxsb_xmsq: {
                xm_name: this.dialogForm.xmmc,
                lb_name: this.dialogForm.xmlb,//类别名称
                lb_id: this.dialogForm.xmlb_id,//类别id
                xm_reason: this.dialogForm.xmly,//理由
                dept_name: this.dialogForm.sqks.label,//部门名称
                xm_content: this.dialogForm.xmnr,//内容
                xm_file: this.dialogForm.xmfj,// 附件
                xm_type: this.dialogForm.xmfs,//项目方式
                xm_price: this.dialogForm.xmys,//预算
                xm_sbsj: this.dialogForm.sbsj,//申报时间
                xm_status: "",//状态
                xm_fp_user: "",//分配用户
                xm_is_wc: "",//是否完成1是2否
                xm_shlc: "",//审核流程
                dept_id: "",//部门id
              }
            }
            xmsq_edit(transObj).then(res => {
              this.loading = false;
              if (res.code == 1) {
                this.$message({
                  message: res.msg,
                  type: "success",
                });
                this.dialogFormVisible = false;
                this.getListData();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error",
                });
              }
            })
          }

        }
      })
    },
    //审核提交
    addFormSubmitCheck(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let transObj = {
            sh_id: this.checkID,
            sh_status: this.dialogForm_check.shjg,
            sh_reason: this.dialogForm_check.clyj,
          }
          xmsq_edit(transObj)
            .then(res => {
              if (res.code == "1") {
                this.$message({
                  message: res.msg,
                  type: 'success'
                });
                this.initMyApply();
                this.dialogFormVisible_check = false;
              } else {
                this.$message({
                  message: res.msg,
                  type: 'error'
                });
              }
            })
            .catch(err => {
              console.log(err)
            })
        }
      })
    },
    //翻页
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
   //点击科室找流程
    KsLinkLc(val) {
     let transObjs = {
        limit:999,
        public:1,
        lc_status: 1,
        lc_yydx:val.value,
        lc_yydx_name:val.label,
      }
      gwglLcgl_List(transObjs)
        .then(res => {
          let singleData = res.data.page_data;
          this.lcglLIST = [];
          singleData.forEach(item => {
            this.lcglLIST.push({
              label: item.lc_name,
              value: item.lc_id
            })
          })
        })
        .catch(err => { console.log(err) });
    },
  },

};
</script>

<style scoped>
@import url("../../../styles/documentOnlineRev.scss");

.red {
  color: red;
}

.blue {
  color: #4351FF;
}
.onlineShow{
  min-height:400px;
}
</style>
