Joe 4 лет назад
Родитель
Сommit
2c42150ae2
2 измененных файлов с 265 добавлено и 1 удалено
  1. 264 0
      src/views/station/employee.vue
  2. 1 1
      src/views/station/equipment.vue

+ 264 - 0
src/views/station/employee.vue

@@ -0,0 +1,264 @@
+<template>
+  <div class="app-container">
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item style="float: right">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          >添加员工</el-button
+        >
+      </el-form-item>
+    </el-form>
+    <el-table :data="personnelList">
+      <el-table-column
+        label="油站员工主键id"
+        v-if="false"
+        align="center"
+        prop="personnelId"
+      />
+      <el-table-column label="员工姓名" align="center" prop="personnelName" />
+      <el-table-column label="负责枪号" align="center" prop="gunNo" />
+      <el-table-column label="手机号" align="center" prop="personnelPhone" />
+      <el-table-column label="加油站名称" align="center" prop="stationName" 
+        v-if="jiBie!=2"
+      />
+      <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)"
+            >修改</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="500px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="姓名" prop="personnelName">
+          <el-input v-model="form.personnelName" placeholder="请输入员工姓名" />
+        </el-form-item>
+        <el-form-item label="负责枪号" prop="checkedGunList">
+          <template v-if="allGunList.length === 0">
+            请先在油枪管理里配置油枪
+          </template>
+          <template v-else>
+            <el-checkbox-group v-model="form.checkedGunList">
+              <el-checkbox
+                v-for="item in allGunList"
+                :key="item.oilGunId"
+                :label="item.oilGunNo"
+                :value="item.oilGunNo"
+              >
+                {{ item.oilGunNo + "号枪/" + item.oilName }}
+              </el-checkbox>
+            </el-checkbox-group>
+          </template>
+        </el-form-item>
+        <el-form-item label="手机号" prop="personnelPhone">
+          <el-input
+            v-model="form.personnelPhone"
+            placeholder="请输入员工手机号"
+          />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  listPersonnel,
+  getPersonnel,
+  delPersonnel,
+  addPersonnel,
+  updatePersonnel,
+  exportPersonnel,
+} from "@/api/station/personnel";
+import { stationinfo, listGun } from "@/api/station/gun";
+import { getDept } from "@/api/system/dept";
+export default {
+  name: "Personnel",
+  data() {
+    return {
+      // 总条数
+      total: 0,
+      // 油站员工信息表格数据
+      personnelList: [],
+      allGunList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        personnelName: null,
+        gunNo: null,
+        stationId: null,
+        stationName: null,
+        qrCode: null,
+        personnelPhone: null,
+      },
+      // 查询参数
+      queryInfo: {
+        stationId: null,
+      },
+      query: {
+        deptId: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {
+        personnelName: [
+          { required: true, message: "请输入员工姓名", trigger: "blur" },
+        ],
+        checkedGunList: [
+          { required: true, message: "请选择油枪", trigger: "change" },
+        ]
+      },
+    };
+  },
+  created() {
+    this.getList();
+    this.init();
+  },
+  methods: {
+    /** 查询油站员工信息列表 */
+    getList() {
+      listPersonnel(this.queryParams).then((response) => {
+        this.queryParams.stationId = null;
+        this.personnelList = response.rows;
+        this.total = response.total;
+      });
+    },
+    init() {
+      //加载所有油枪
+      listGun({
+        stationId: this.deptId,
+      }).then((response) => {
+        this.allGunList = response.rows;
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+    },
+    // /** 搜索按钮操作 */
+    // handleQuery() {
+    //   this.queryParams.pageNum = 1;
+    //   this.getList();
+    // },
+    // /** 重置按钮操作 */
+    // resetQuery() {
+    //   this.resetForm("queryForm");
+    //   this.handleQuery();
+    // },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.title = "添加油站员工";
+      //【**】
+      this.form = {
+        stationId: this.deptId,
+        checkedGunList: [],
+      };
+      this.form.stationId = this.deptId;
+      this.open = true;
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      let checkedGunList;
+      if (Object.prototype.toString.call(row.gunNo) === "[object String]") {
+        checkedGunList = [...new Set(row.gunNo.split(","))].filter((ele) => {
+          return ele.toString().trim() !== "";
+        });
+      } else {
+        checkedGunList = [];
+      }
+      this.form = { ...row, checkedGunList };
+      this.open = true;
+      this.title = "修改油站员工";
+    },
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          this.form.gunNo = this.form.checkedGunList.toString();
+          if (!!this.form.personnelId) {
+            updatePersonnel(this.form).then((response) => {
+              this.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
+          } else {
+            addPersonnel(this.form).then((response) => {
+              this.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const personnelIds = row.personnelId;
+      this.$confirm("是否确认删除油站员工信息", "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(function () {
+          return delPersonnel(personnelIds);
+        })
+        .then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        })
+        .catch(() => {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm("是否确认导出所有油站员工信息数据项?", "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(function () {
+          return exportPersonnel(queryParams);
+        })
+        .then((response) => {
+          this.download(response.msg);
+        });
+    },
+  },
+};
+</script>

+ 1 - 1
src/views/station/equipment.vue

@@ -271,7 +271,7 @@ export default {
       },
       // 弹窗表单参数
       dialogForm: {
-        checkedGunList:[2]
+        checkedGunList:[]
       },
       // 表单校验
       rules: {