Newer
Older
smart-economy / src / components / synthetical / management / processSystemManage.vue
StephanieGitHub on 26 Jan 2021 11 KB first commit
<template>
  <div class="full-box zhglcss" style="overflow: hidden">
    <div class="" style="width: 100%;height:100%;">
      <div class="top-tip-box t-title">当前位置:综合管理 > 事物处理系统</div>
      <div class="table-info-box">
        <div class="table-search-box onerow">
          <div class="search-info-box" style="">
            <div class="search-row" style="padding-top:0;margin-bottom:0px;">
              <div class="search-item">
                <div class="search-item-label">隶属局办</div>
                <el-select v-model="filter.dept" filterable clearable placeholder="请选择" style="width: 130px;">
                  <el-option label="全部" value=""></el-option>
                  <el-option v-for="item in deptList" :key="item.value" :label="item.name" :value="item.name"></el-option>
                </el-select>
              </div>
              <div class="search-item">
                <div class="search-item-label">时间</div>
                <el-date-picker
                  type="date"
                  v-model="filter.startDate"
                  placeholder="开始日期"
                  value-format="yyyy-MM-dd"
                  style="width:150px;float: left;">
                </el-date-picker>
              </div>
              <div class="search-item" style="margin-left: 10px;">
                <div class="search-item-label">至</div>
                <el-date-picker
                  type="date"
                  v-model="filter.endDate"
                  placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  style="width:150px;float: left;">
                </el-date-picker>
              </div>
              <div class="search-item">
                <div class="search-item-label">事务标签</div>
                <el-input v-model="filter.tags" placeholder="请输入内容"></el-input>
              </div>
              <el-button class="search-btn" type="primary" @click="searchResult">查询</el-button>
              <el-button class="search-btn" type="primary" @click="resetFilter">重置</el-button>
              <el-button class="operate-btn" type="primary" @click="addData">新增</el-button>
            </div>
          </div>
          <div class="search-border-box">
            <div class="sbb-line"></div>
            <div class="sbb-role"></div>
          </div>
        </div>
        <div class="table-result-boxx" style="height: calc(100% - 95px)">
          <div class="table-container-style">
            <el-table :data="tableData.list" height="200">
              <el-table-column type="index" align="center" label="编号" width="80"></el-table-column>
              <el-table-column prop="category" align="center" label="事务类型" show-overflow-tooltip></el-table-column>
              <el-table-column prop="dept" align="center" label="隶属局办" show-overflow-tooltip></el-table-column>
              <el-table-column prop="taskType" align="center" label="任务类型" show-overflow-tooltip></el-table-column>
              <el-table-column prop="tags" align="center" label="事务标签" show-overflow-tooltip ></el-table-column>
              <el-table-column prop="uploadUser" align="center" label="上传人" show-overflow-tooltip ></el-table-column>
              <el-table-column prop="uploadTime" align="center" label="上传时间"  width="150"></el-table-column>
              <el-table-column prop="" align="center" label="附件">
                <template slot-scope="scope">
                  <div style="" class="list-file"  @click="downLoadFile(item)" v-for="(item,index) in scope.row.attachment" :key="index"><i class="el-icon-document"></i>{{item.name}}</div>
                </template>
              </el-table-column>
            </el-table>
            <el-pagination @current-change="handlePageChange" background layout="total, prev, pager, next" :total="tableData.total" :current-page="tableData.pageNum" :page-size="tableData.pageSize" :page-count="tableData.pages" style="text-align: right;"></el-pagination>
          </div>
        </div>
      </div>
    </div>
    <!---->
    <el-dialog title="新增事物" :visible.sync="dialogVisible" width="450px" :close-on-click-modal=false>
      <el-form :model="importParam" :rules="addRules" ref="importForm" label-width='120px'>
        <el-form-item label="事务类型" prop="category">
          <el-input v-model="importParam.category" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="隶属局办" prop="dept">
          <el-select v-model="importParam.dept" filterable clearable placeholder="请选择" style="width: 150px;">
            <el-option label="全部" value=""></el-option>
            <el-option  v-for="item in deptList" :key="item.value" :label="item.name" :value="item.name"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务类型" prop="taskType">
          <el-input v-model="importParam.taskType" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="事务标签" prop="tags">
          <el-input type="textarea" :rows="2" v-model="importParam.tags"  placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="上传" prop="">
          <el-upload :action='GLOBAL.BASE_HTTP_URL+"/dx-economy-api/file"' name="files" :limit=10 :before-remove="beforeAttachmentRemove" :on-exceed="handleAttachmentExceed" :file-list="fileList" :on-success="handleAttachmentSuccess">
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="importReport()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  let month = new Date().getMonth()==0?0:new Date().getMonth();
  let year = month<10?new Date().getFullYear()+"-0"+month :new Date().getFullYear()+"-"+month;
  export default {
    name: 'yjManage',
    data () {
      return {
        timeFilter:[new Date().format("yyyy-")+"01-01",new Date().format("yyyy-MM-dd")],
        filter:{
          dept:'',
          tags:'',
          startDate: new Date().format("yyyy-")+"01-01",
          endDate:new Date().format("yyyy-MM-dd")
        },
        deptList:[],
        dialogVisible:false,
        fileList:[],
        addRules:{
          category: [ { required: true, message: '请填写事务类型', trigger: 'change' } ],
          dept: [ { required: true, message: '请填写隶属局办', trigger: 'change' } ],
          taskType: [ { required: true, message: '填写输入任务类型', trigger: 'blur' } ],
          tags: [ { required: true, message: '填输入事务标签', trigger: 'blur' } ],
        },
        importParam:{category  :'',dept:'',tags : "",taskType:'',typeId:'',attachment:""},

        zbTypeList:[{id:1,name:'全部'},{id:2,name:'产值增幅同比'},{id:3,name:'进出口增幅同比'}],
        tableData:{
          list: [],
          pageNum: 1,
          pageSize: 10,
          pages: 0,
          total: 0,
        },
      }
    },
    mounted (){},
    created(){
      this.GLOBAL.app.getDictList(resp => {
        this.deptList = resp["隶属局办"];
      })
      this.getDataList()
    },
    watch:{

    },
    methods:{
      searchResult(){
        this.getDataList(1)
      },
      getDataList(pageNum){
        let vm = this;
        vm.$http.get('/dx-economy-api/affair/page',{params:$.extend({pageNum:vm.tableData.pageNum,pageSize:vm.tableData.pageSize},vm.filter)}).then(function (resp) {
          let _data = resp.data;
          if (_data.code === 200 && !vm.$Util.isEmpty(_data.data)) {
            vm.tableData.list = _data.data.list;
            if(!vm.$Util.isEmpty(vm.tableData.list)){
              vm.tableData.list.forEach(function (item) {
                let list = [];
                if( !vm.$Util.isEmpty(item.attachment)) {
                  item.attachment.split(",").find((v) => {
                    list.push({  name: v.split(":")[1], url: vm.GLOBAL.BASE_HTTP_URL + "/dx-economy-api/file/" + v.split(":")[0],id:v.split(":")[0], response: {data: v}})
                  })
                }
                item.attachment = list;
              });
            }
            vm.tableData.pageNum = resp.data.data.pageNum;
            vm.tableData.total = resp.data.data.total;
          }
        })
      },
      downLoadFile(item) {
        let vm = this;
        vm.$confirm('确定下载该文件吗?', '提示', {
          type: 'warning'
        }).then(() => {
          vm.$http.get('/dx-economy-api/file/'+item.id).then(() => {
            /*vm.$notify({
              title: '提示',
              message: '导出'+item.name+'项目成功!',
              type: 'success'
            });*/
          });
        }).catch(() => {})
      },
      /**/
      handleAreaCheckAllChange(value){
        let _this = this,obj = _this.areaCheckObj,_list = [];
        if(value){
          obj.checkList.forEach(item => {
            _list.push(item.id);
          });
        }
        obj.checkedList = _list;
        obj.isIndeterminate = false;
      },
      handleCheckedChange(value) {
        let _this = this,obj = _this.areaCheckObj;
        obj.checkAll = value.length === obj.checkList.length;
        obj.isIndeterminate = value.length > 0 && value.length < obj.checkList.length;
      },
      resetFilter(){
        this.filter.dept='';
        this.filter.tag='';
        this.filter.startDate =  new Date().format("yyyy-")+"01-01";
        this.filter.endDate = new Date().format("yyyy-MM-dd")
      },
      addTypes(){
        let vm = this
        vm.areaCheckObj.checkList.push({
          name:vm.typeNames
        })
        vm.typeDialogVisible = false
      },
      addData(){
        let vm = this
        vm.resetForm("importForm")
        vm.dialogVisible = true
      },
      resetForm(formName) {
        var _this = this;
        console.log("s")
        if(!_this.$Util.isEmpty(_this.$refs[formName])){
          _this.$refs[formName].resetFields();
          _this.fileList=[];
          _this.importParam={typeName  :'',dept:'',tag : "",taskType:'',typeId:'',attachment:""};
        }
      },
      /*新增档案*/
      handleAttachmentExceed() {
        this.$message.warning("当前限制选择1个文件");
      },
      beforeAttachmentRemove(file) {
        var vm = this,num = null
        vm.fileList.findIndex((v,i)=>{
          if(v.name == file.name)
            num = i
        })
        vm.$http.delete('/dx-economy-api/file/'+file.response.data.split(":")[0]).then(function (resp) {
          let _data = resp.data;
          if (_data.code === 200) {
            vm.fileList.splice(num,1)
          }
        })
      },
      handleAttachmentSuccess(res,file,fileList){
        let vm =this
        vm.fileList = fileList
      },
      importReport () {
        let _this = this;
        _this.$refs['importForm'].validate((valid) => {
          if (valid) {
            _this.fileList.find((v)=>{
              _this.importParam.attachment = _this.importParam.attachment == "" ? v.response.data : _this.importParam.attachment + "," + v.response.data
            })
            _this.$http.post('/dx-economy-api/affair', _this.importParam).then(function (resp) {
              let _data = resp.data;
              if (_data.code === 200) {
                _this.$message.success("新增成功")
                _this.resetForm("importForm")
                _this.getDataList(_this.tableData.pageNum)
              } else {
                _this.$message.error(_data.message);
              }
            });
            _this.dialogVisible = false;
          } else {
            return false;
          }
        });
      },
      /*end*/
      handlePageChange(currentPage){
        this.tableData.pageNum = currentPage;
        this.getDataList()
      },
    }
  }
</script>
<style></style>
<style scoped>
  .aaa{}
  .aaa{}
  .aaa{}
  .aaa{}
  .aaa{}
</style>