Przeglądaj źródła

feat: 增加说明书管理编辑和新增功能

Damon 8 miesięcy temu
rodzic
commit
8b330d7aab

+ 48 - 0
src/api/operation/explain.js

@@ -0,0 +1,48 @@
+import request from '@/utils/request'
+
+
+// 获取列表
+export function list(data) {
+  return request({
+    url: `/admin/electronicManual/page`,
+    method: 'post',
+    data,
+    // headers: {
+    //   'Content-Type': 'multipart/form-data'
+    // }
+  })
+}
+
+// status 0:上架 1:下架 2:删除
+export function deletes(id, status) {
+  return request({
+    url: `/admin/electronicManual/hitOrSold/${id}/${status}`,
+    method: 'get'
+  })
+}
+
+// 详情
+export function detail(id) {
+  return request({
+    url: `/admin/electronicManual/detail?id=` + id,
+    method: 'get'
+  })
+}
+
+// 新增 
+export function add(data) {
+  return request({
+    url: `/admin/electronicManual/save`,
+    method: 'post',
+    data
+  })
+}
+
+//  编辑
+export function edit(data) {
+  return request({
+    url: `/admin/electronicManual/update`,
+    method: 'post',
+    data
+  })
+}

+ 1 - 1
src/utils/request.js

@@ -65,7 +65,7 @@ service.interceptors.request.use(config => {
       const s_time = sessionObj.time; // 请求时间
       var interval; // 间隔时间(ms),小于此时间视为重复提交
 
-      // console.log("gadfadsqwerqewrwqr=aaa==" + JSON.stringify(config));
+      console.log("gadfadsqwerqewrwqr=aaa==" + JSON.stringify(config));
 
       ///活动管理-新增赠送流量特殊处理
       if (config.url === "/admin/activity/doExchange") {

+ 174 - 0
src/views/operation/explain/detail.vue

@@ -0,0 +1,174 @@
+<!-- 活动管理 说明书管理详情 -->
+<template>
+  <div class="app-container">
+    <el-form
+      :model="form"
+      ref="form"
+      :rules="rules"
+      label-width="110px"
+      :disabled="disabled"
+    >
+      <el-form-item label="说明书名称:" prop="name">
+        <el-input v-model="form.name" placeholder="请输入协议名称" />
+      </el-form-item>
+
+      <el-form-item label="设备分类:" prop="categoryName">
+        <el-select v-model="form.categoryName" placeholder="请选择设备分类">
+          <el-option
+            v-for="item in categoryOptions"
+            :key="item.value"
+            :label="item.label"
+            :value="item.label"
+          />
+        </el-select>
+      </el-form-item>
+
+      <el-form-item label="二维码图片:" prop="codeUrl">
+        <Upload
+          listType="picture-card"
+          :url="form.codeUrl"
+          @upload="uploadCode($event, 'codeUrl')"
+          :disabled="disabled"
+        />
+      </el-form-item>
+
+      <el-form-item label="说明书文件:" prop="fileUrl">
+        <el-row type="flex" justify="space-between">
+          <el-col :span="16">
+            <el-input
+              v-model="form.fileUrl"
+              placeholder="请输入或上传下载路径"
+            />
+          </el-col>
+          <el-col :span="6">
+            <Upload @upload="upload" style="float: right" />
+          </el-col>
+        </el-row>
+      </el-form-item>
+    </el-form>
+    <div class="form-btn">
+      <el-button @click="cancel">取消</el-button>
+      <el-button v-if="!disabled" type="primary" @click="getSubmit"
+        >确定</el-button
+      >
+    </div>
+  </div>
+</template>
+
+<script>
+import { add, detail, edit } from "@/api/operation/explain";
+import { devCategoryMixin, devTypeMixin } from "@/mixin/index";
+
+export default {
+  mixins: [devTypeMixin, devCategoryMixin],
+  data() {
+    return {
+      // 表单
+      form: {
+        fileUrl: "",
+      },
+      // 只读
+      disabled: false,
+      // 是否强制
+      typeOptions: [
+        {
+          value: 0,
+          label: "否",
+        },
+        {
+          value: 1,
+          label: "是",
+        },
+      ],
+      // 校验
+      rules: {
+        name: [{ required: true, message: "请输入协议名称", trigger: "blur" }],
+        categoryName: [
+          { required: true, message: "请选择设备类型", trigger: "change" },
+        ],
+        codeUrl: [
+          {
+            required: true,
+            message: "请上传二维码图片",
+            trigger: "change",
+          },
+        ],
+        fileUrl: [
+          { required: true, message: "请上传下载路径", trigger: "blur" },
+        ],
+      },
+    };
+  },
+
+  mounted() {
+    this.form.id = this.$route.query.id;
+    this.form.state = this.$route.query.state;
+    this.disabled = Boolean(this.$route.query.boolean == 1);
+    this.getCateGory(1);
+    this.getDetail();
+  },
+
+  methods: {
+    // 详情
+    getDetail() {
+      if (this.form.state != 0) {
+        detail(this.form.id).then((res) => {
+          if (res.code === 0) {
+            this.form = res.data;
+          }
+        });
+      }
+    },
+
+    // 上传
+    uploadCode(e) {
+      this.form.codeUrl = e.file;
+    },
+
+    // 上传
+    upload(e) {
+      this.form.fileUrl = e.file;
+    },
+
+    // 取消
+    cancel() {
+      this.$tab.closeOpenPage("/operation/explain");
+      // this.$router.go(-1);
+    },
+
+    // 确定
+    getSubmit() {
+      if (this.categoryOptions) {
+        for (var i = 0; i < this.categoryOptions.length; i++) {
+          if (this.form.categoryName === this.categoryOptions[i].label) {
+            this.form.categoryId = this.categoryOptions[i].value;
+            break;
+          }
+        }
+      }
+
+      if (this.$route.query.state == 0) {
+        add(this.form).then((res) => {
+          if (res.code === 0) {
+            this.$message.success("添加成功!");
+            this.cancel();
+          }
+        });
+      } else {
+        edit(this.form).then((res) => {
+          if (res.code === 0) {
+            this.$message.success("修改成功!");
+            this.cancel();
+          }
+        });
+      }
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+.el-form {
+  width: 500px;
+}
+</style>

+ 142 - 0
src/views/operation/explain/index.vue

@@ -0,0 +1,142 @@
+<!-- 运营管理 说明书管理 -->
+<template>
+  <div class="app-container">
+    <!-- 搜索 -->
+    <el-form inline size="mini">
+      <el-form-item>
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          plain
+          @click="getDetail(0, 0, 0)"
+          v-hasPermi="['operation:explain:add']"
+          >新增</el-button
+        >
+      </el-form-item>
+    </el-form>
+    <!-- 列表 -->
+    <el-table :data="tableData" v-loading="loading">
+      <el-table-column label="序号" align="center" type="index" />
+      <el-table-column
+        label="说明书名称"
+        align="center"
+        prop="name"
+        show-overflow-tooltip
+      />
+
+      <el-table-column label="设备分类" prop="categoryName" align="center" />
+
+      <el-table-column label="更新时间" align="center" prop="updateTimeStr" />
+      <el-table-column label="创建时间" align="center" prop="createTimeStr" />
+      <el-table-column label="操作" align="center">
+        <template slot-scope="scope">
+          <el-button
+            type="text"
+            @click="getDetail(1, 1, scope.row.id)"
+            v-hasPermi="['operation:explain:check']"
+            >查看</el-button
+          >
+
+          <span style="margin: 0 10px">
+            <el-button
+              type="text"
+              @click="getDetail(0, 2, scope.row.id)"
+              v-hasPermi="['operation:explain:edit']"
+              >编辑</el-button
+            >
+
+            <el-button
+              type="delete"
+              @click="getDelete(scope.row)"
+              v-hasPermi="['operation:explain:delete']"
+              >删除</el-button
+            >
+          </span>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="form.pageNum"
+      :limit.sync="form.pageSize"
+      @pagination="getList"
+    />
+  </div>
+</template>
+
+<script>
+import { deletes, list } from "@/api/operation/explain";
+import { currentMixin, devMixin, disabledMixin } from "@/mixin/index";
+import { dialogCallBack } from "@/utils/DialogUtil";
+export default {
+  mixins: [devMixin, currentMixin, disabledMixin],
+  data() {
+    return {
+      // 遮罩层
+      loading: false,
+      // 表单
+      form: {
+        pageNum: 1,
+        pageSize: 10,
+      },
+      // 总数据
+      total: 0,
+      // 列表
+      tableData: [],
+    };
+  },
+
+  watch: {},
+  mounted() {
+    this.getList();
+  },
+
+  methods: {
+    addData() {},
+    // 列表
+    getList() {
+      this.loading = true;
+      list(this.form).then((res) => {
+        if (res.code === 0) {
+          this.tableData = res.data.records;
+          this.total = res.data.total;
+          this.loading = false;
+        }
+      });
+    },
+
+    // 说明书管理详情
+    getDetail(boolean, state, id) {
+      this.$router.push({
+        path: `/operation/explain/detail`,
+        query: {
+          id: id,
+          boolean: boolean,
+          state: state,
+        },
+      });
+    },
+
+    // 删除
+    getDelete(row) {
+      var that = this;
+      dialogCallBack(that, function () {
+        that
+          .$confirm(`是否删除${row.name}?`, "提示:", {
+            type: "warning",
+          })
+          .then(() => {
+            deletes(row.id, 2).then((res) => {
+              if (res.code === 0) {
+                that.$message.success("删除成功!");
+                that.getList();
+              }
+            });
+          });
+      });
+    },
+  },
+};
+</script>