From 20f2ac4345f1c5db7d781da19da4c530be86a93e Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 13 May 2022 11:54:04 +0800
Subject: [PATCH] 农产品页面新增
---
src/views/farmplant/farmplant.vue | 33 ++-
src/views/farmplant/strain.vue | 299 ++++++++++++++++++++++++++++++++++++++++++
src/api/farmplant/strain.js | 48 ++++++
3 files changed, 367 insertions(+), 13 deletions(-)
diff --git a/src/api/farmplant/strain.js b/src/api/farmplant/strain.js
new file mode 100644
index 0000000..18295ee
--- /dev/null
+++ b/src/api/farmplant/strain.js
@@ -0,0 +1,48 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+ return request({
+ url: '/api/strain/page',
+ method: 'get',
+ params: {
+ ...params,
+ current,
+ size,
+ }
+ })
+}
+export const remove = (ids) => {
+ return request({
+ url: '/api/strain/remove',
+ method: 'post',
+ params: {
+ ids,
+ }
+ })
+}
+
+export const save = (row) => {
+ return request({
+ url: '/api/strain/save',
+ method: 'post',
+ data: row
+ })
+}
+
+export const update = (row) => {
+ return request({
+ url: '/api/strain/update',
+ method: 'post',
+ data: row
+ })
+}
+
+export const getDetail = (id) => {
+ return request({
+ url: '/api/strain/detail',
+ method: 'get',
+ params: {
+ id
+ }
+ })
+}
\ No newline at end of file
diff --git a/src/views/farmplant/farmplant.vue b/src/views/farmplant/farmplant.vue
index db54960..527a980 100644
--- a/src/views/farmplant/farmplant.vue
+++ b/src/views/farmplant/farmplant.vue
@@ -1,5 +1,5 @@
<template>
- <basic-container class="paper">
+ <basic-container>
<avue-crud
:option="option"
:table-loading="loading"
@@ -55,7 +55,6 @@
landList:[],
option: {
tip: false,
- searchMenuSpan: 8,
height: "auto",
editBtn: true,
delBtn: true,
@@ -64,6 +63,8 @@
menuAlign: "center",
align: "center",
selection: true,
+ searchShow: true,
+ searchMenuSpan: 6,
column: [
{
label: "类型",
@@ -124,8 +125,8 @@
{
label: "品种",
prop: "varieties",
- search:true,
- searchSpan:5,
+ // search:true,
+ // searchSpan:5,
labelWidth:110,
rules: [
{
@@ -135,21 +136,27 @@
},
],
},
- // {
- // label: "种养品图片",
- // prop: "url",
- // type: "upload",
- // listType: "picture-img",
- // width: 100,
- // labelWidth:110,
- // addDisplay:false,
- // },
+ {
+ label: "种养品图片",
+ prop: "url",
+ type: "upload",
+ listType: "picture-img",
+ width: 100,
+ labelWidth:110,
+ display:false,
+ },
+ {
+ label: "所属地块",
+ prop: "landName",
+ display:false,
+ },
{
label: "所属地块",
prop: "landId",
searchSpan:4,
search:true,
type:"tree",
+ hide:true,
dicData: [],
props: {
label: "landName",
diff --git a/src/views/farmplant/strain.vue b/src/views/farmplant/strain.vue
new file mode 100644
index 0000000..f71938a
--- /dev/null
+++ b/src/views/farmplant/strain.vue
@@ -0,0 +1,299 @@
+<template>
+ <basic-container>
+ <avue-crud
+ :option="option"
+ :table-loading="loading"
+ :data="data"
+ :page.sync="page"
+ :permission="permissionList"
+ :before-open="beforeOpen"
+ v-model="form"
+ ref="crud"
+ @row-update="rowUpdate"
+ @row-save="rowSave"
+ @row-del="rowDel"
+ @search-change="searchChange"
+ @search-reset="searchReset"
+ @selection-change="selectionChange"
+ @current-change="currentChange"
+ @size-change="sizeChange"
+ @refresh-change="refreshChange"
+ @on-load="onLoad"
+ >
+ <template slot="menuLeft">
+ <el-button
+ type="danger"
+ size="small"
+ icon="el-icon-delete"
+ plain
+ @click="handleDelete"
+ >删 除
+ </el-button>
+ </template>
+ </avue-crud>
+ </basic-container>
+</template>
+
+<script>
+import {
+ getDetail,
+ getList,
+ update,
+ remove,
+ save,
+} from "@/api/farmplant/strain";
+import { mapGetters } from "vuex";
+export default {
+ data() {
+ return {
+ visible: true,
+ form: {},
+ query: {},
+ loading: true,
+ excelBox: false,
+ page: {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0,
+ },
+ selectionList: [],
+ option: {
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 6,
+ height: "auto",
+ editBtn: true,
+ delBtn: true,
+ viewBtn: true,
+ menuWidth: 200,
+ menuAlign: "center",
+ align: "center",
+ selection: true,
+ column: [
+ {
+ label: "农产品名称",
+ prop: "strainName",
+ searchLabelWidth: 110,
+ labelWidth: 110,
+ search: true,
+ searchSpan: 5,
+ rules: [
+ {
+ required: true,
+ message: "请输入农产品名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "类型",
+ prop: "strainType",
+ type: "select",
+ labelWidth: 110,
+ search: true,
+ searchSpan: 4,
+ dicUrl: "/api/blade-system/dict-biz/dictionary?code=strainType",
+ props: {
+ label: "dictValue",
+ value: "dictKey",
+ },
+ dataType: "string",
+ rules: [
+ {
+ required: true,
+ message: "请输入类型",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "别名",
+ prop: "alias",
+ labelWidth: 110,
+ rules: [
+ {
+ required: false,
+ message: "请输入别名",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "图片",
+ type: "upload",
+ listType: "picture-img",
+ propsHttp: {
+ res: "data",
+ url: "url",
+ },
+ canvasOption: {
+ text: " ",
+ ratio: 1.0,
+ },
+ action: "/api/blade-resource/oss/endpoint/put-files",
+ tip: "",
+ span: 24,
+ labelWidth: 110,
+ prop: "url",
+ rules: [
+ {
+ required: true,
+ message: "请上传农产品图片",
+ trigger: "blur",
+ },
+ ],
+ },
+ ],
+ },
+ data: [],
+ };
+ },
+ created() {},
+ computed: {
+ ...mapGetters(["permission", "userInfo"]),
+ // permissionList() {
+ // return {
+ // addBtn: this.vaildData(this.permission.social_add, true),
+ // viewBtn: this.vaildData(this.permission.social_view, false),
+ // delBtn: this.vaildData(this.permission.social_delete, false),
+ // editBtn: this.vaildData(this.permission.social_edit, false),
+ // };
+ // },
+ ids() {
+ let ids = [];
+ this.selectionList.forEach((ele) => {
+ ids.push(ele.id);
+ });
+ return ids.join(",");
+ },
+ },
+ mounted() {},
+ methods: {
+ //新增
+ rowSave(row, done, loading) {
+ save(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>
+</style>
--
Gitblit v1.9.3