fei
1 天以前 d195776f9d23f7c79a049ccececdf674853eadb7
src/views/archiveManager/index.vue
@@ -230,6 +230,58 @@
          v-hasPermi="['system:records:export']"
        >导出</el-button>
      </el-col>
          <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleBatchSubmit"
          v-hasPermi="['system:records:export']"
        >批量提交</el-button>
      </el-col>
        <el-col v-if="userId==1" :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExportTemplate"
          v-hasPermi="['system:materials:edit']"
        >导入模板下载</el-button>
      </el-col>
  <el-col v-if="userId!=1" :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExportTemplateOther"
          v-hasPermi="['system:materials:edit']"
        >导入模板下载</el-button>
      </el-col>
        <el-col  :span="1.5">
        <el-upload
          action=""
          class="upload-demo"
          :show-file-list="false"
          :http-request="handleImportData"
              accept=".xlsx,.xls"
        >
          <el-button size="mini"   type="primary"
                     plain
                     icon="el-icon-top">导入</el-button>
        </el-upload>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
@@ -290,7 +342,7 @@
            @click="handleCheck(scope.row)"
          >查看</el-button>
    <el-button
          v-if="userId!==1"
          v-if="userId!==1&&scope.row.ownData"
            size="mini"
            type="text"
@@ -355,7 +407,25 @@
      />
    </el-select>
  </el-col>
  <el-col :span="6">
     <el-col :span="6">
            <el-select
              v-model="form.recordZone"
              placeholder="选择地区"
              @change="handleRecordTypeChange"
              disabled
                           >
              <el-option
                v-for="item in zoneTypeOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-col>
  <el-col :span="4">
    <el-input
      v-model="form.recordYear"
      placeholder="输入年份"
@@ -365,7 +435,7 @@
      @input="generateRecordId"
    />
  </el-col>
  <el-col :span="6">
  <el-col :span="4">
    <el-input
      v-model="form.recordSeq"
      placeholder="自动生成"
@@ -482,16 +552,19 @@
          <el-col :span="4">
            <el-input
              v-model="form.recordYear"
                            @input="generateRecordId"
              placeholder="输入年份"
              @input="generateRecordId"
:disabled="userId!=1"
            />
          </el-col>
          <el-col :span="4">
            <el-input
              v-model="form.recordSeq"
              placeholder="自动生成"
              disabled
              :disabled="userId!=1"
              @input="generateRecordId"
              placeholder="输入档案序号"
            />
          </el-col>
        </el-row>
@@ -623,10 +696,10 @@
</template>
<script>
import { updateStatusById,listRecords,getMaxId, getRecords, delRecords, addRecords, updateRecords } from "@/api/system/records"
import { enload, batchSubmitRecords,updateStatusById,listRecords,getMaxId, getRecords, delRecords, addRecords, updateRecords } from "@/api/system/records"
import { listAllCategory } from "@/api/system/category"
import { listName } from "@/api/system/projectName"
import { listPlaceName } from "@/api/system/placeName"
import { listAllProjectName } from "@/api/system/projectName"
import { listPlaceName, listAllPlaceName } from "@/api/system/placeName"
export default {
  name: "Records",
  data() {
@@ -733,7 +806,7 @@
    this.userId = this.$store.state.user.id;
// 获取用户角色
    this.getId()
  //  this.getId()
    this.getRecordTypes()
    this.getZoneOptions()
    this.fetchProjectOptions()
@@ -794,9 +867,8 @@
    async getZoneOptions()
    {
      try {
        const response = await listPlaceName()
        console.log(response)
     //   alert(134)
        const response = await listAllPlaceName()
        console.log("1111111333333",response.data)
        this.zoneTypeOptions = response.data.data.map(item => ({
          value: item.nnumber,
          label: item.name
@@ -807,8 +879,8 @@
    },
    async fetchProjectOptions() {
      try {
        const response = await listName()
        console.log(response)
        const response = await listAllProjectName()
        console.log("1111111",response)
        this.projectOptions = response.data.data.map(item => ({
          value: item.name,
          label: item.name
@@ -838,7 +910,7 @@
    /** 生成档案号 */
    generateRecordId() {
      if (this.form.recordType && this.form.recordZone && this.form.recordYear) {
      if (this.form.recordType && this.form.recordZone && this.form.recordYear && this.form.recordSeq) {
        // getNextRecordId({
        //   type: this.form.recordType,
@@ -914,7 +986,7 @@
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.form.recordSeq = this.maxId
    // this.form.recordSeq = this.maxId
      this.open = true
      this.vis = false;
      this.title = "添加档案记录"
@@ -934,7 +1006,7 @@
    //
    handleSubmit(row)
    {
      alert(row.id)
   //   alert(row.id)
      var id = row.id
      updateStatusById(id).then(response=>{
        this.$modal.msgSuccess("提交成功")
@@ -956,13 +1028,49 @@
  if(this.recordTypeOptions.length > 0) {
      const recordParts = response.data.recordId.split('-')
      this.$set(this.form, 'recordType', recordParts[0])
            this.$set(this.form, 'recordZone', recordParts[1])
      if(this.recordTypeOptions.length==4)
      {
        this.$set(this.form, 'recordZone', recordParts[1])
      this.$set(this.form, 'recordYear', recordParts[2])
      this.$set(this.form, 'recordSeq', recordParts[3])
      }
      else
      {
            this.$set(this.form, 'recordYear', recordParts[1])
      this.$set(this.form, 'recordSeq', recordParts[2])
      }
    }
        this.open = true
        this.title = "修改档案记录"
      })
    },
    /** 批量提交 */
    handleBatchSubmit() {
     // alert(this.ids)
      if (this.ids.length === 0) {
        this.$modal.msgWarning('请选择要提交的档案记录')
        return
      }
      const myValidIds = this.recordsList
  .filter(item => item.ownData === true)
  .map(item => item.id);
          // 检查选中的ID是否全部属于自己
    const invalidIds = this.ids.filter(id => !myValidIds.includes(id));
    if (invalidIds.length > 0) {
      this.$message.error(`包含无权操作的ID: ${invalidIds.join(',')}`);
      return false;
    }
    //如果id全部有效才继续提交
      batchSubmitRecords( this.ids ).then(response => {
        if (response.code === 0) {
          this.$modal.msgSuccess('批量提交成功')
          this.getList()
          this.ids = []
        } else {
          this.$modal.msgError(response.msg || '批量提交失败')
        }
      })
    },
    /** 修改按钮操作 */
@@ -977,10 +1085,18 @@
  if(this.recordTypeOptions.length > 0) {
      const recordParts = response.data.recordId.split('-')
      this.$set(this.form, 'recordType', recordParts[0])
      if(this.recordTypeOptions.length==4)
      {
            this.$set(this.form, 'recordZone', recordParts[1])
      this.$set(this.form, 'recordYear', recordParts[2])
      this.$set(this.form, 'recordSeq', recordParts[3])
      }
      else
      {
            this.$set(this.form, 'recordYear', recordParts[1])
      this.$set(this.form, 'recordSeq', recordParts[2])
      }
    }
  this.open_check = true
  this.title = "查看档案记录"
@@ -989,6 +1105,7 @@
    /** 提交按钮 */
    submitForm() {
      console.log(this.form)
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
@@ -999,11 +1116,16 @@
            })
          } else {
            console.log(this.form)
            addRecords(this.form).then(response => {
              console.log(response)
              if(response.code==0)
                this.$modal.msgError(response.msg)
              else{
              this.$modal.msgSuccess("新增成功")
              this.open = false
              this.getId()
              this.getList()
              this.getList()}
            })
@@ -1047,7 +1169,58 @@
      this.download('system/records/export', {
        ...this.queryParams
      }, `records_${new Date().getTime()}.xlsx`)
    },
         /** 导入模板下载操作*/
    handleExportTemplate()
    {
      this.download('/system/records/model', {
      }, `records_${new Date().getTime()}.xlsx`)
    },
    handleExportTemplateOther()
    {
          this.download('/system/records/modelOther', {
      }, `records_${new Date().getTime()}.xlsx`)
    },
  /** 导入操作*/
    async handleImportData({file}){
   // 检查文件类型是否为xlsx
  // if (!params.file.name.endsWith('.xlsx')) {
  //   this.$message.error('请上传.xlsx格式的文件');
  //   return;
  // }
  const formData = new FormData();
  formData.append('excelImport', file);
  // formData.append('recordId', this.recordId)
  // alert(this.recordId)
  console.log(file)
  // 显示加载中状态
  const loading = this.$loading({
    lock: true,
    text: '上传中...',
    spinner: 'el-icon-loading',
    background: 'rgba(0, 0, 0, 0.7)'
  });
  enload(formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  }).then(response => {
    loading.close();
    this.$message.success('导入成功');
    this.getList();
  }).catch(error => {
    loading.close();
    this.$message.error('导入失败: ' + (error.message || '未知错误'));
  });
    }
  }
}
</script>