Browse Source

提交代码

JX.Li 1 năm trước cách đây
mục cha
commit
32a5057dae

+ 44 - 0
src/api/gas/roadSectionInspection.js

@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+
+// 查询路段巡查列表
+export function listRoadSectionInspection(query) {
+  return request({
+    url: '/gas/roadSectionInspection/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询路段巡查详细
+export function getRoadSectionInspection(id) {
+  return request({
+    url: '/gas/roadSectionInspection/' + id,
+    method: 'get'
+  })
+}
+
+// 新增路段巡查
+export function addRoadSectionInspection(data) {
+  return request({
+    url: '/gas/roadSectionInspection',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改路段巡查
+export function updateRoadSectionInspection(data) {
+  return request({
+    url: '/gas/roadSectionInspection',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除路段巡查
+export function delRoadSectionInspection(id) {
+  return request({
+    url: '/gas/roadSectionInspection/' + id,
+    method: 'delete'
+  })
+}

+ 8 - 3
src/components/ImageUpload/index.vue

@@ -28,11 +28,12 @@
       的文件
     </div>
     <el-image-viewer
-      v-show="dialogVisible2"
+      v-if="dialogVisible2"
       :z-index="9999"
       :on-close="closeImgViewer"
       :url-list="fileList.map(t => t.url)"
       :initial-index="imgIndex"
+      fit="cover"
     />
 
     <el-dialog
@@ -131,6 +132,7 @@
        * @description 关闭图片查看器
        */
       closeImgViewer() {
+        this.imgIndex = 0
         this.dialogVisible2 = false;
       },
       // 删除图片
@@ -206,8 +208,11 @@
         this.type=file.name.slice(file.name.lastIndexOf(".")+1);
         if (this.type === 'mp4')
         this.dialogVisible = true;
-        else
-        this.dialogVisible2 = true;
+        else{
+          this.imgIndex = this.fileList.findIndex((item) => item.name == file.url)
+          console.log(this.imgIndex)
+          this.dialogVisible2 = true
+        }
         console.log(this.type)
       },
       // 对象转成指定字符串分隔

+ 380 - 0
src/views/gas/roadSectionInspection/index.vue

@@ -0,0 +1,380 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="路段名称" prop="sectionName">
+        <el-input
+          v-model="queryParams.sectionName"
+          placeholder="请输入路段名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="发现问题" prop="findProblem">
+        <el-select v-model="queryParams.findProblem" placeholder="请选择发现问题" clearable size="small">
+          <el-option
+            v-for="dict in dict.type.find_problem"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </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="['gas:roadSectionInspection:add']"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          @click="handleUpdate"
+          v-hasPermi="['gas:roadSectionInspection:edit']"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          @click="handleDelete"
+          v-hasPermi="['gas:roadSectionInspection:remove']"
+        >删除</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="['gas:roadSectionInspection:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="roadSectionInspectionList" @selection-change="handleSelectionChange">
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="主键id" align="center" prop="id" v-if="false"/>
+      <el-table-column label="路段名称" align="center" prop="sectionName" />
+      <el-table-column label="抽检米数" align="center" prop="samplingMeterCount" />
+      <el-table-column label="发现问题" align="center" prop="findProblem">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.find_problem" :value="scope.row.findProblem"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="发现时间" align="center" prop="findTime" width="180">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.findTime, '{y}-{m}-{d} {h}:{i}') }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="照片" align="center">
+        <template slot-scope="scope">
+          <el-image
+            style="width: 50px; height: 50px"
+            :src="scope.row.photoList[0]"
+            :preview-src-list="scope.row.photoList">
+          </el-image>
+        </template>
+      </el-table-column>
+<!--      <el-table-column label="备注" align="center" prop="remark" />-->
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['gas:roadSectionInspection:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-view"
+            @click="views(scope.row)"
+            v-hasPermi="['gas:roadSectionInspection:views']"
+          >查看详情</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['gas:roadSectionInspection:remove']"
+          >删除</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="50%" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px" :disabled="disabled">
+        <el-form-item label="路段名称" prop="sectionName">
+          <el-input v-model="form.sectionName" placeholder="请输入路段名称" />
+        </el-form-item>
+        <el-form-item label="抽检米数" prop="samplingMeterCount">
+          <el-input v-model="form.samplingMeterCount" placeholder="请输入抽检米数" />
+        </el-form-item>
+        <el-form-item label="发现问题" prop="findProblem">
+          <el-select v-model="form.findProblem" placeholder="请选择发现问题" style="width: 100%">
+            <el-option
+              v-for="dict in dict.type.find_problem"
+              :key="dict.value"
+              :label="dict.label"
+              :value="dict.value"
+            ></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="发现时间" prop="findTime">
+          <el-date-picker clearable size="small"
+            v-model="form.findTime"
+            type="datetime"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            placeholder="选择发现时间"  style="width: 100%">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+
+        <el-col :span="24">
+          <el-form-item label="照片" prop="photoList">
+            <imageUpload v-model="form.photoList" :disabled="disabled"/>
+          </el-form-item>
+        </el-col>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { listRoadSectionInspection, getRoadSectionInspection, delRoadSectionInspection, addRoadSectionInspection, updateRoadSectionInspection } from "@/api/gas/roadSectionInspection";
+import fa from "element-ui/src/locale/lang/fa";
+
+export default {
+  name: "RoadSectionInspection",
+  dicts: ['find_problem'],
+  data() {
+    return {
+      // 按钮loading
+      buttonLoading: false,
+      disabled: false,
+      // 遮罩层
+      loading: true,
+      // 导出遮罩层
+      exportLoading: false,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 路段巡查表格数据
+      roadSectionInspectionList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        sectionName: undefined,
+        samplingMeterCount: undefined,
+        findProblem: undefined,
+        findTime: undefined,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        id: [
+          { required: true, message: "主键id不能为空", trigger: "blur" }
+        ],
+        sectionName: [
+          { required: true, message: "路段名称不能为空", trigger: "blur" }
+        ],
+        samplingMeterCount: [
+          { required: true, message: "抽检米数不能为空", trigger: "blur" }
+        ],
+        findProblem: [
+          { required: true, message: "发现问题不能为空", trigger: "change" }
+        ],
+        findTime: [
+          { required: true, message: "发现时间不能为空", trigger: "blur" }
+        ],
+        remark: [
+          { required: true, message: "备注不能为空", trigger: "blur" }
+        ],
+      }
+    };
+  },
+  created() {
+    this.getList();
+  },
+  methods: {
+    /** 查询路段巡查列表 */
+    getList() {
+      this.loading = true;
+      listRoadSectionInspection(this.queryParams).then(response => {
+        this.roadSectionInspectionList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: undefined,
+        sectionName: undefined,
+        samplingMeterCount: undefined,
+        findProblem: undefined,
+        findTime: undefined,
+        remark: undefined,
+        delFlag: undefined,
+        createBy: undefined,
+        createTime: undefined,
+        updateBy: undefined,
+        updateTime: undefined
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length!==1
+      this.multiple = !selection.length
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.disabled = false
+      this.title = "添加路段巡查";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.loading = true;
+      this.reset();
+      const id = row.id || this.ids
+      getRoadSectionInspection(id).then(response => {
+        this.loading = false;
+        this.form = response.data;
+        this.open = true;
+        this.title = "修改路段巡查";
+        this.disabled = false
+      });
+    },
+    /** 修改按钮操作 */
+    views(row) {
+      this.loading = true;
+      this.reset();
+      const id = row.id || this.ids
+      getRoadSectionInspection(id).then(response => {
+        this.loading = false;
+        this.form = response.data;
+        this.open = true;
+        this.title = "查看路段巡查";
+        this.disabled = true
+      });
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          this.buttonLoading = true;
+          if (this.form.id != null) {
+            if (typeof this.form.photoList === 'string') {
+              this.form.photoList = this.form.photoList.split(',')
+            }
+            updateRoadSectionInspection(this.form).then(response => {
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            }).finally(() => {
+              this.buttonLoading = false;
+            });
+          } else {
+            this.form.photoList = this.form.photoList.split(',')
+            addRoadSectionInspection(this.form).then(response => {
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            }).finally(() => {
+              this.buttonLoading = false;
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$modal.confirm('是否确认删除路段巡查编号为"' + ids + '"的数据项?').then(() => {
+        this.loading = true;
+        return delRoadSectionInspection(ids);
+      }).then(() => {
+        this.loading = false;
+        this.getList();
+        this.$modal.msgSuccess("删除成功");
+      }).finally(() => {
+        this.loading = false;
+      });
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+        this.$download.excel('/gas/roadSectionInspection/export', this.queryParams);
+    }
+  }
+};
+</script>