From 425152d436e73d4ef93e2e809998b5c837f7cd96 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Fri, 13 May 2022 08:48:04 +0800
Subject: [PATCH] 农资管理

---
 src/views/stock/stock.vue |  765 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 527 insertions(+), 238 deletions(-)

diff --git a/src/views/stock/stock.vue b/src/views/stock/stock.vue
index 00befd9..55bab8e 100644
--- a/src/views/stock/stock.vue
+++ b/src/views/stock/stock.vue
@@ -26,264 +26,553 @@
                    v-if="permission.stock_delete"
                    @click="handleDelete">删 除
         </el-button>
+
+      </template>
+      <template slot-scope="{ type, size, row }" slot="menu">
+        <el-button
+          icon="el-icon-circle-plus-outline"
+          @click="modifiedGrades(row)"
+          :size="size"
+          :type="type"
+        >入库
+        </el-button
+        >
+        <el-button
+          icon="el-icon-edit-outline"
+          @click="modifiedGrades1(row)"
+          :size="size"
+          :type="type"
+        >出库
+        </el-button
+        >
       </template>
     </avue-crud>
+    <el-dialog
+      title="农资入库"
+      :visible.sync="gradeBoxVisible"
+      width="width"
+      :modal="true"
+      :modal-append-to-body="true"
+      :append-to-body="true"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      :before-close="dialogBeforeClose"
+    >
+      <div>
+        <avue-form
+          ref="form"
+          :option="option1"
+          v-model="form"
+          @reset-change="emptytChange"
+          @submit="submit"
+        >
+        </avue-form>
+      </div>
+    </el-dialog>
+    <el-dialog
+      title="农资出库"
+      :visible.sync="gradeBoxVisible1"
+      width="width"
+      :modal="true"
+      :modal-append-to-body="true"
+      :append-to-body="true"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      :before-close="dialogBeforeClose"
+    >
+      <div>
+        <avue-form
+          ref="form"
+          :option="option1"
+          v-model="form"
+          @reset-change="emptytChange"
+          @submit="submit"
+        >
+        </avue-form>
+      </div>
+    </el-dialog>
   </basic-container>
 </template>
 
 <script>
-  import {getList, getDetail, add, update, remove} from "@/api/stock/stock";
-  import {mapGetters} from "vuex";
+import {getList, getDetail, add, update, remove} from "@/api/stock/stock";
+import {mapGetters} from "vuex";
 
-  export default {
-    data() {
-      return {
-        form: {},
-        query: {},
-        loading: true,
-        page: {
-          pageSize: 10,
-          currentPage: 1,
-          total: 0
-        },
-        selectionList: [],
-        option: {
-          height:'auto',
-          calcHeight: 30,
-          tip: false,
-          searchShow: true,
-          searchMenuSpan: 6,
-          border: true,
-          index: true,
-          viewBtn: true,
-          selection: true,
-          dialogClickModal: false,
-          column: [
-            {
-              label: "农资ID",
-              prop: "stockId",
-              rules: [{
-                required: true,
-                message: "请输入农资ID",
-                trigger: "blur"
-              }]
+export default {
+  data() {
+    return {
+      form: {},
+      specsValue1: '',
+      query: {},
+      loading: true,
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0
+      },
+      selectionList: [],
+      option: {
+        height: 'auto',
+        calcHeight: 30,
+        tip: false,
+        searchShow: true,
+        searchMenuSpan: 3,
+        border: true,
+        index: true,
+        align: "center",
+        viewBtn: true,
+        selection: true,
+        dialogClickModal: false,
+        column: [
+          {
+            label: "农资",
+            prop: "stockId",
+            span: 23,
+            type: "select",
+            dicUrl: "/api/stockfactory/stockfactory/selectStockFa",
+            props: {
+              label: "dictValue",
+              value: "dictKey"
             },
-            {
-              label: "规格",
-              prop: "specs",
-              rules: [{
-                required: true,
-                message: "请输入规格",
-                trigger: "blur"
-              }]
+            rules: [{
+              required: true,
+              message: "请输入农资",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "农资类型",
+            prop: "stype",
+            addDisplay: false,
+            searchLabelWidth: 80,
+            searchSpan: 4,
+            type: "select",
+            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockType",
+            props: {
+              label: "dictValue",
+              value: "dictKey"
             },
-            {
-              label: "规格值(0:克 1:斤 2:公斤 3:吨 4:毫升 5:升 )",
-              prop: "specsValue1",
-              rules: [{
-                required: true,
-                message: "请输入规格值(0:克 1:斤 2:公斤 3:吨 4:毫升 5:升 )",
-                trigger: "blur"
-              }]
+            dataType: "number",
+            search: true,
+          },
+          {
+            label: "厂家名称",
+            prop: "factoryName",
+            addDisplay: false,
+          },
+          {
+            label: "规格",
+            prop: "spn",
+            addDisplay: false,
+          },
+          {
+            label: "规格",
+            hide: true,
+            prop: "specs",
+            span: 5,
+            viewDisplay: false,
+            rules: [{
+              required: true,
+              message: "请输入规格",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "规格值1",
+            hide: true,
+            prop: "specsValue1",
+            searchSpan: 4,
+            span: 6,
+            type: "select",
+            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockSpecs1",
+            props: {
+              label: "dictValue",
+              value: "dictKey"
             },
-            {
-              label: "规格值2( 0:袋 1:包 2:瓶 3:盒 4:箱 5:桶 6:支)",
-              prop: "specsValue2",
-              rules: [{
-                required: true,
-                message: "请输入规格值2( 0:袋 1:包 2:瓶 3:盒 4:箱 5:桶 6:支)",
-                trigger: "blur"
-              }]
+            dataType: "number",
+            search: true,
+            viewDisplay: false,
+          },
+          {
+            label: "规格值2",
+            hide: true,
+            prop: "specsValue2",
+            searchSpan: 4,
+            span: 6,
+            type: "select",
+            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockSpecs2",
+            props: {
+              label: "dictValue",
+              value: "dictKey"
             },
-            {
-              label: "入库数量",
-              prop: "amount",
-              rules: [{
-                required: true,
-                message: "请输入入库数量",
-                trigger: "blur"
-              }]
+            dataType: "number",
+            search: true,
+            viewDisplay: false,
+          },
+          {
+            label: "入库数量",
+            span: 6,
+            prop: "amount",
+            rules: [{
+              required: true,
+              message: "请输入入库数量",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "是否库存",
+            prop: "state",
+            type: "select",
+            searchSpan: 4,
+            searchLabelWidth: 95,
+            search: true,
+            addDisplay: false,
+            dicData: [
+              {
+                label: "有库存",
+                value: "0"
+              },
+              {
+                label: "无库存",
+                value: "1"
+              }
+            ],
+          },
+          {
+            label: "入库类型",
+            prop: "type",
+            type: "select",
+            span: 12,
+            searchSpan: 4,
+            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stockPurchase",
+            props: {
+              label: "dictValue",
+              value: "dictKey"
             },
-            {
-              label: "类型 (0:采购入库 1:调拨入库)",
-              prop: "type",
-              rules: [{
-                required: true,
-                message: "请输入类型 (0:采购入库 1:调拨入库)",
-                trigger: "blur"
-              }]
+            dataType: "number",
+            search: true,
+            rules: [{
+              required: true,
+              message: "请输入入库类型",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "入库时间",
+            prop: "time",
+            type: "date",
+            format: "yyyy-MM-dd",
+            valueFormat: "yyyy-MM-dd",
+            span: 11,
+            rules: [{
+              required: true,
+              message: "请输入入库时间",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "单据、凭证照片",
+            prop: "picture",
+            type: "upload",
+            labelWidth: 145,
+            dataType: "string",
+            span: 24,
+            limit: 5,
+            listType: "picture-card",
+            tip: "建议上传手机横屏拍摄的照片,宽高比16:9,最多上传5张",
+            canvasOption: {
+              text: "",
+              ratio: 1.0,
             },
-            {
-              label: "入库时间",
-              prop: "time",
-              rules: [{
-                required: true,
-                message: "请输入入库时间",
-                trigger: "blur"
-              }]
+            propsHttp: {
+              res: "data",
+              url: "url"
             },
-            {
-              label: "图片",
-              prop: "picture",
-              rules: [{
-                required: true,
-                message: "请输入图片",
-                trigger: "blur"
-              }]
-            },
-            {
-              label: "备注",
-              prop: "remarks",
-              rules: [{
+            action: "/api/blade-resource/oss/endpoint/put-files"
+          },
+          {
+            label: "备注",
+            type: "textarea",
+            prop: "remarks",
+            span: 23,
+            rules: [
+              {
                 required: true,
                 message: "请输入备注",
-                trigger: "blur"
-              }]
+                trigger: "blur",
+              },
+            ],
+          },
+        ]
+      },
+      option1: {
+        height: 'auto',
+        calcHeight: 30,
+        tip: false,
+        searchShow: true,
+        searchMenuSpan: 6,
+        border: true,
+        index: true,
+        viewBtn: true,
+        selection: true,
+        dialogClickModal: false,
+        column: [
+          {
+            label: "农资",
+            prop: "stockId1",
+            span: 23,
+            type: "select",
+            dicUrl: "/api/stockfactory/stockfactory/selectStockFa",
+            props: {
+              label: "dictValue",
+              value: "dictKey"
             },
-            {
-              label: "状态 (0:有库存 1:没有库存)",
-              prop: "state",
-              rules: [{
-                required: true,
-                message: "请输入状态 (0:有库存 1:没有库存)",
-                trigger: "blur"
-              }]
-            },
-          ]
-        },
-        data: []
+            rules: [{
+              required: true,
+              message: "请输入农资",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "数量",
+            prop: "amount1",
+          },
+          {
+            label: "时间",
+            prop: "time1",
+            rules: [{
+              required: true,
+              message: "请输入时间",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "类型 (0:出库 1:入库)",
+            prop: "type1",
+            rules: [{
+              required: true,
+              message: "请输入类型 (0:出库 1:入库)",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "操作人",
+            prop: "operator1",
+            rules: [{
+              required: true,
+              message: "请输入操作人",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "规格",
+            prop: "spn1",
+            rules: [{
+              required: true,
+              message: "请输入规格",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "农资类型",
+            prop: "stockType1",
+            rules: [{
+              required: true,
+              message: "请输入农资类型",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "图片",
+            prop: "picture1",
+            rules: [{
+              required: true,
+              message: "请输入图片",
+              trigger: "blur"
+            }]
+          },
+          {
+            label: "备注",
+            prop: "remarks1",
+            rules: [{
+              required: true,
+              message: "请输入备注",
+              trigger: "blur"
+            }]
+          },
+        ]
+      },
+      gradeBoxVisible: false,
+      gradeBoxVisible1: false,
+      data: []
+    };
+  },
+  computed: {
+    ...mapGetters(["permission"]),
+    permissionList() {
+      return {
+        addBtn: this.vaildData(this.permission.stock_add, false),
+        viewBtn: this.vaildData(this.permission.stock_view, false),
+        delBtn: this.vaildData(this.permission.stock_delete, false),
+        editBtn: this.vaildData(this.permission.stock_edit, false)
       };
     },
-    computed: {
-      ...mapGetters(["permission"]),
-      permissionList() {
-        return {
-          addBtn: this.vaildData(this.permission.stock_add, false),
-          viewBtn: this.vaildData(this.permission.stock_view, false),
-          delBtn: this.vaildData(this.permission.stock_delete, false),
-          editBtn: this.vaildData(this.permission.stock_edit, false)
-        };
-      },
-      ids() {
-        let ids = [];
-        this.selectionList.forEach(ele => {
-          ids.push(ele.id);
-        });
-        return ids.join(",");
-      }
-    },
-    methods: {
-      rowSave(row, done, loading) {
-        add(row).then(() => {
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!"
-          });
-          done();
-        }, error => {
-          loading();
-          window.console.log(error);
-        });
-      },
-      rowUpdate(row, index, done, loading) {
-        update(row).then(() => {
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!"
-          });
-          done();
-        }, error => {
-          loading();
-          console.log(error);
-        });
-      },
-      rowDel(row) {
-        this.$confirm("确定将选择数据删除?", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        })
-          .then(() => {
-            return remove(row.id);
-          })
-          .then(() => {
-            this.onLoad(this.page);
-            this.$message({
-              type: "success",
-              message: "操作成功!"
-            });
-          });
-      },
-      handleDelete() {
-        if (this.selectionList.length === 0) {
-          this.$message.warning("请选择至少一条数据");
-          return;
-        }
-        this.$confirm("确定将选择数据删除?", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        })
-          .then(() => {
-            return remove(this.ids);
-          })
-          .then(() => {
-            this.onLoad(this.page);
-            this.$message({
-              type: "success",
-              message: "操作成功!"
-            });
-            this.$refs.crud.toggleSelection();
-          });
-      },
-      beforeOpen(done, type) {
-        if (["edit", "view"].includes(type)) {
-          getDetail(this.form.id).then(res => {
-            this.form = res.data.data;
-          });
-        }
-        done();
-      },
-      searchReset() {
-        this.query = {};
-        this.onLoad(this.page);
-      },
-      searchChange(params, done) {
-        this.query = params;
-        this.page.currentPage = 1;
-        this.onLoad(this.page, params);
-        done();
-      },
-      selectionChange(list) {
-        this.selectionList = list;
-      },
-      selectionClear() {
-        this.selectionList = [];
-        this.$refs.crud.toggleSelection();
-      },
-      currentChange(currentPage){
-        this.page.currentPage = currentPage;
-      },
-      sizeChange(pageSize){
-        this.page.pageSize = pageSize;
-      },
-      refreshChange() {
-        this.onLoad(this.page, this.query);
-      },
-      onLoad(page, params = {}) {
-        this.loading = true;
-        getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
-          const data = res.data.data;
-          this.page.total = data.total;
-          this.data = data.records;
-          this.loading = false;
-          this.selectionClear();
-        });
-      }
+    ids() {
+      let ids = [];
+      this.selectionList.forEach(ele => {
+        ids.push(ele.id);
+      });
+      return ids.join(",");
     }
-  };
+  },
+  methods: {
+    submit(row, done, loading) {
+      var that = this;
+      updateGrade(row).then(
+        () => {
+          that.$refs.form.resetFields();
+          that.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          that.gradeBoxVisible = false;
+
+          done();
+        },
+        error => {
+          window.console.log(error);
+          done();
+        }
+      );
+    },
+    // 往入库页面填充数据
+    modifiedGrades(row) {
+      this.form = {
+        id: null,
+        stockId1: row.stockId,
+
+      };
+      this.gradeBoxVisible = true;
+    },
+    modifiedGrades1(row) {
+      this.form = {
+        id: null,
+        stockId: row.stockId,
+
+      };
+      this.gradeBoxVisible1 = true;
+    },
+    rowSave(row, done, loading) {
+      add(row).then(() => {
+        this.onLoad(this.page);
+        this.$message({
+          type: "success",
+          message: "操作成功!"
+        });
+        done();
+      }, error => {
+        loading();
+        window.console.log(error);
+      });
+    },
+    rowUpdate(row, index, done, loading) {
+      update(row).then(() => {
+        this.onLoad(this.page);
+        this.$message({
+          type: "success",
+          message: "操作成功!"
+        });
+        done();
+      }, error => {
+        loading();
+        console.log(error);
+      });
+    },
+    rowDel(row) {
+      this.$confirm("确定将选择数据删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          return remove(row.id);
+        })
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+        });
+    },
+    handleDelete() {
+      if (this.selectionList.length === 0) {
+        this.$message.warning("请选择至少一条数据");
+        return;
+      }
+      this.$confirm("确定将选择数据删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(() => {
+          return remove(this.ids);
+        })
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          this.$refs.crud.toggleSelection();
+        });
+    },
+    beforeOpen(done, type) {
+      if (["edit", "view"].includes(type)) {
+        getDetail(this.form.id).then(res => {
+          this.form = res.data.data;
+        });
+      }
+      done();
+    },
+    searchReset() {
+      this.query = {};
+      this.onLoad(this.page);
+    },
+    searchChange(params, done) {
+      this.query = params;
+      this.page.currentPage = 1;
+      this.onLoad(this.page, params);
+      done();
+    },
+    selectionChange(list) {
+      this.selectionList = list;
+    },
+    selectionClear() {
+      this.selectionList = [];
+      this.$refs.crud.toggleSelection();
+    },
+    currentChange(currentPage) {
+      this.page.currentPage = currentPage;
+    },
+    sizeChange(pageSize) {
+      this.page.pageSize = pageSize;
+    },
+    refreshChange() {
+      this.onLoad(this.page, this.query);
+    },
+    onLoad(page, params = {}) {
+      this.loading = true;
+      getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
+        const data = res.data.data;
+        this.page.total = data.total;
+        this.data = data.records;
+        this.loading = false;
+        this.selectionClear();
+      });
+    }
+  }
+};
 </script>
 
 <style>

--
Gitblit v1.9.3