智慧农业后台管理页面
guoshilong
2022-11-08 082613d446e29e4ec1c16bfaa52345106a498b23
src/views/farmplant/process.vue
@@ -30,10 +30,6 @@
                        库存量:
                        <span>{{ item.productInventoryNum }}</span>公斤
                    </div>
                    <div class="area">
                        原材料:
                        <span>{{ item.strainName }}</span>
                    </div>
                        <div class="btn">
                            <el-button style="width: 65px;" plain size="small" @click="openWindow(0,item)">
                                <span style="color: #5abf78">销售</span>
@@ -43,12 +39,12 @@
                            </el-button>
                        </div>
                        <div class="btn">
                            <!-- <el-button style="width: 65px;" plain size="small" @click="openWidow(3,item)">
                                <span style="color: #5abf78">出库</span>
                            </el-button>
                            <el-button style="width: 65px;" plain size="small" @click="openWindow(2,item)">
                                加工
                            </el-button> -->
                        <el-button style="width: 65px;" plain size="small" @click="openWindow(3,item)">
                            <span style="color: #5abf78">出库</span>
                        </el-button>
                        <el-button style="width: 65px;" plain size="small" @click="openWindow(2,item)">
                            加工
                        </el-button>
                        </div>
                </div>
            </div>
@@ -65,7 +61,7 @@
                :total="page.total"
            ></el-pagination>
        </div>
        <!-- 销售 -->
        <el-dialog
            title="加工产品销售"
            :modal-append-to-body="false"
@@ -86,6 +82,7 @@
                <template slot-scope="{disabled,size}" slot="saleDestination">
                    <div>
                        <el-cascader
                            ref="cascader"
                            style="width: 100%;"
                            placeholder="请选择销售去向"
                            size="large"
@@ -97,7 +94,7 @@
                </template>
                <template slot-scope="{disabled,size}" slot="saleNum">
                    <div style="margin-bottom: -20px">
                        <el-input type="number" placeholder="请输入销售数量" v-model="form.saleNum">
                        <el-input type="number" min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入销售数量" v-model="form.saleNum">
                            <i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
                        </el-input>
                        <div style="text-align: right;color: #ffb218">可销售量:{{ form.weight }}公斤</div>
@@ -105,14 +102,15 @@
                </template>
                <template slot-scope="{disabled,size}" slot="salePrice">
                    <div style="margin-bottom: -20px">
                        <el-input type="number" placeholder="请输入销售价格" v-model="form.salePrice">
                        <el-input type="number"  min="0" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入销售价格" v-model="form.salePrice">
                            <i slot="suffix" style="font-style:normal;margin-right: 5px;">元/公斤</i>
                        </el-input>
                    </div>
                </template>
                <template slot="menuForm">
                    <div style="text-align: center">
                        <el-button style="width: 120px" type="success" plain @click="submitSole">销售</el-button>
                        <el-button style="width: 80px" plain @click="cleanData">取消</el-button>
                        <el-button style="width: 80px" type="success" plain @click="submitSole">销售</el-button>
                    </div>
                </template>
            </avue-form>
@@ -137,7 +135,7 @@
                </template>
                <template slot-scope="{disabled,size}" slot="saleNum">
                    <div style="margin-bottom: -20px">
                        <el-input type="number" placeholder="请输入损耗数量" v-model="formKC.saleNum">
                        <el-input type="number" @mousewheel.native.prevent @DOMMouseScroll.native.prevent placeholder="请输入损耗数量" v-model="formKC.saleNum">
                            <i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
                        </el-input>
                        <div style="text-align: right;color: #ffb218">库存量:{{ formKC.weight }}公斤</div>
@@ -151,10 +149,9 @@
                </template>
            </avue-form>
        </el-dialog>
        <!-- 加工产品 -->
        <el-dialog
            title="加工产品"
            title="加工产品加工"
            :modal-append-to-body="false"
            :append-to-body="true"
            :close-on-click-modal="false"
@@ -187,8 +184,61 @@
                </template>
                <template slot="menuForm">
                    <div style="text-align: center">
                        <el-button style="width: 80px" plain @click="cleanKCData">取消</el-button>
                        <el-button style="width: 80px" plain @click="cleanJGData">取消</el-button>
                        <el-button style="width: 80px" type="success" plain @click="submitJGloss">确认</el-button>
                    </div>
                </template>
            </avue-form>
        </el-dialog>
        <!--出库-->
        <el-dialog
            title="加工产品出库"
            :modal-append-to-body="false"
            :append-to-body="true"
            :close-on-click-modal="false"
            :before-close="cleanCKData"
            @close="close"
            width="30%"
            :visible.sync="visibleCK"
            center
        >
            <avue-form ref="form" v-model="formCK" :option="optionCK">
                <template slot-scope="{disabled,size}" slot="name">
                    <div>
                        <el-tag type="success">{{ formCK.name }}</el-tag>
                    </div>
                </template>
                <!-- <template slot-scope="{disabled,size}" slot="saleDestination">
                    <div>
                        <el-cascader
                            style="width: 100%;"
                            placeholder="请选择出库去向"
                            size="large"
                            :options="optionck"
                            @change="handleChangeck"
                            v-model="saleDestination"
                        ></el-cascader>
                    </div>
                </template> -->
                <template slot-scope="{disabled,size}" slot="saleNum">
                    <div style="margin-bottom: -20px">
                        <el-input type="number" placeholder="请输入出库数量" v-model="formCK.saleNum">
                            <i slot="suffix" style="font-style:normal;margin-right: 5px;">公斤</i>
                        </el-input>
                        <div style="text-align: right;color: #ffb218">可出库量:{{ formCK.weight }}公斤</div>
                    </div>
                </template>
                <template slot-scope="{disabled,size}" slot="salePrice">
                    <!--          <div style="margin-bottom: -20px">
                      <el-input type="number" placeholder="请输入销售价格" v-model="formCK.salePrice"><i slot="suffix"
                                                                                                style="font-style:normal;margin-right: 5px;">元/公斤</i>
                      </el-input>
                    </div>-->
                </template>
                <template slot="menuForm">
                    <div style="text-align: center">
                        <el-button style="width: 80px" plain @click="cleanCKData">取消</el-button>
                        <el-button style="width: 80px" type="success" plain @click="submitCK">出库</el-button>
                    </div>
                </template>
            </avue-form>
@@ -208,10 +258,19 @@
} from "@/api/sale/sale"
import {
    addjg
    submitProcessJG
} from "@/api/process/process"
import {
    submitProcess
} from "@/api/retrieval/retrieval"
import {
    selectInfo
} from "@/api/machining/machining"
import { mapGetters } from "vuex"
import { regionData } from 'element-china-area-data'
import fixed from "@/util/mathHandler"
import {limitNumLength} from "@/util/validate";
export default {
    data () {
@@ -225,8 +284,8 @@
            form: {
                name: "",
                proid: "",
                landId: "",
                strainId: "",
                // landId: "",
                // strainId: "",
                saleTime: "",
                saleNum: "",
                saleDestination: "",
@@ -235,38 +294,60 @@
                salePrice: "",
                createUser: "",
                saleBrand: "",
                processName:"",
                weight:"",
                type:"1",
            },
            //出库字段
            formCK: {
                name: "",
                proid: "",
                // landId: "",
                // strainId: "",
                saleTime: "",
                saleNum: "",
                saleDestination: "",
                city: "",
                county: "",
                createUser: "",
                remarks: "",
                type:"1",
                processName:""
            },
            //损耗字段
            formKC: {
                name: "",
                proid: "",
                landId: "",
                strainId: "",
                // landId: "",
                // strainId: "",
                saleNum: "",
                remarks: "",
                reason: "0",
                lossTime: "",
                processName:"",
                type:"1",
            },
            //加工字段
            formJG: {
                name: "",
                proid: "",
                landId: "",
                strainId: "",
                // landId: "",
                // strainId: "",
                saleNum: "",
                processNum: "",
                remarks: "",
                reason: "0",
                saleTime: "",
                processName:"",
                parentId:"",
            },
            visible: false,
            visibleKC: false,
            visibleJG: false,
            visibleCK: false,
            value: true,
            page: {
                pageSize: 16,
@@ -288,7 +369,7 @@
                            {
                                required: true,
                                message: "请输入产品",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -303,7 +384,7 @@
                            {
                                required: true,
                                message: "请选择销售时间",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -316,7 +397,7 @@
                            {
                                required: true,
                                message: "请输入销售数量",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -328,7 +409,7 @@
                            {
                                required: true,
                                message: "请选择销售去向",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -337,24 +418,32 @@
                        prop: "salePrice",
                        span: 24,
                        type: "number",
                        rules: [
                            {
                              required: true,
                              trigger: ["blur","change"],
                              validator:limitNumLength
                            },
                        ],
                    },
                    {
                        label: "品牌",
                        prop: "saleBrand",
                        span: 24,
                        maxlength:100,
                    },
                    {
                        label: "操作人",
                        prop: "name",
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请输入操作人",
                                trigger: "blur",
                            },
                        ],
                    },
                    // {
                    //     label: "操作人",
                    //     prop: "realName",
                    //     span: 24,
                    //     rules: [
                    //         {
                    //             required: true,
                    //             message: "请输入操作人",
                    //             trigger: ["blur","change"],
                    //         },
                    //     ],
                    // },
                ]
            },
            //库存损耗配置
@@ -372,7 +461,7 @@
                            {
                                required: true,
                                message: "请输入损耗品种",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -387,7 +476,7 @@
                            {
                                required: true,
                                message: "请选择损耗时间",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -400,7 +489,7 @@
                            {
                                required: true,
                                message: "请输入损耗数量",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -409,37 +498,38 @@
                        prop: "reason",
                        span: 24,
                        type: "select",
                        value: "0",
                        dicData: [
                            {
                                label: "库存损耗",
                                value: "0",
                            }],
                        // value: "0",
                        dicUrl:"/api/blade-system/dict-biz/dictionary?code=lossReason",
                        props: {
                            label: "dictValue",
                            value: "dictKey"
                        },
                        rules: [
                            {
                                required: true,
                                message: "请选择损耗原因",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        maxlength:200,
                        span: 24,
                    },
                    {
                        label: "操作人",
                        prop: "name",
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请输入操作人",
                                trigger: "blur",
                            },
                        ],
                    },
                    // {
                    //     label: "操作人",
                    //     prop: "realName",
                    //     span: 24,
                    //     rules: [
                    //         {
                    //             required: true,
                    //             message: "请输入操作人",
                    //             trigger: ["blur","change"],
                    //         },
                    //     ],
                    // },
                ]
            },
            //加工配置
@@ -450,14 +540,14 @@
                column: [
                    {
                        label: "加工品种",
                        prop: "strainName",
                        prop: "processName",
                        span: 24,
                        disabled: true,
                        rules: [
                            {
                                required: true,
                                message: "请输入加工品种",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -472,7 +562,7 @@
                            {
                                required: true,
                                message: "请选择加工时间",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -485,7 +575,7 @@
                            {
                                required: true,
                                message: "请输入加工数量",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -494,7 +584,14 @@
                        prop: "processId",
                        span: 24,
                        type: "tree",
                        dicUrl: "/api/machining/machining/selectInfo",
                        dicData:[],
                        // dicUrl: "/api/machining/machining/selectInfo",
                        // dicFormatter:(res)=>{
                        //     res = res.data.filter(e=>{
                        //         return e.processId != this.formJG.parentId
                        //     })
                        //     return res
                        // },
                        props: {
                            label: "processName",
                            value: "processId"
@@ -503,7 +600,7 @@
                            {
                                required: true,
                                message: "请输入加工产品",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -516,27 +613,28 @@
                            {
                                required: true,
                                message: "请输入产品数量",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        maxlength:200,
                        span: 24,
                    },
                    {
                        label: "操作人",
                        prop: "name",
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请输入操作人",
                                trigger: "blur",
                            },
                        ],
                    },
                    // {
                    //     label: "操作人",
                    //     prop: "realName",
                    //     span: 24,
                    //     rules: [
                    //         {
                    //             required: true,
                    //             message: "请输入操作人",
                    //             trigger: ["blur","change"],
                    //         },
                    //     ],
                    // },
                ]
            },
            //出库配置
@@ -546,15 +644,15 @@
                gutter: 30,
                column: [
                    {
                        label: "出库品种",
                        prop: "strainName",
                        label: "出库产品",
                        prop: "processName",
                        span: 24,
                        disabled: true,
                        rules: [
                            {
                                required: true,
                                message: "请输入出库品种",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -569,7 +667,7 @@
                            {
                                required: true,
                                message: "请选择出库时间",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
@@ -582,39 +680,59 @@
                            {
                                required: true,
                                message: "请输入出库数量",
                                trigger: "blur",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
                    // {
                    //     label: "出库去向",
                    //     prop: "saleDestination",
                    //     span: 24,
                    //     rules: [
                    //         {
                    //             required: true,
                    //             message: "请选择出库去向",
                    //             trigger: ["blur","change"],
                    //         },
                    //     ],
                    // },
                    {
                        label: "出库去向",
                        prop: "saleDestination",
                        prop: "saleDestination1",
                        span: 24,
                        type: "select",
                        // value: "0",
                        dicUrl:"/api/blade-system/dict-biz/dictionary?code=reDestination",
                        props: {
                            label: "dictValue",
                            value: "dictKey"
                        },
                        rules: [
                            {
                                required: true,
                                message: "请选择出库去向",
                                trigger: "blur",
                                message: "请选择损耗原因",
                                trigger: ["blur","change"],
                            },
                        ],
                    },
                    {
                        label: "备注",
                        prop: "remarks",
                        maxlength:200,
                        span: 24,
                    },
                    {
                        label: "操作人",
                        prop: "name",
                        span: 24,
                        rules: [
                            {
                                required: true,
                                message: "请输入操作人",
                                trigger: "blur",
                            },
                        ],
                    },
                    // {
                    //     label: "操作人",
                    //     prop: "realName",
                    //     span: 24,
                    //     rules: [
                    //         {
                    //             required: true,
                    //             message: "请输入操作人",
                    //             trigger: ["blur","change"],
                    //         },
                    //     ],
                    // },
                ]
            },
            selectionList: [],
@@ -622,7 +740,7 @@
        }
    },
    computed: {
        ...mapGetters(["permission", "userInfo"]),
        ...mapGetters(["permission", "userInfo","$farmId"]),
        // permissionList() {
        //   return {
        //     addBtn: this.vaildData(this.permission.social_add, true),
@@ -638,6 +756,26 @@
            })
            return ids.join(",")
        },
    },
    watch: {
        '$farmId':{
            handler (newName, oldName) {
                this.query ={}
                this.onLoad(this.page)
            }
        },
        'formJG.parentId':{
            handler(newName,oldName){
                const column = this.findObject(this.optionJG.column, "processId")
                selectInfo().then(res=>{
                    var data = res.data.data.filter(e=>{
                        return e.processId != newName
                    })
                    column.dicData = data
                })
            }
        }
    },
    mounted () {
    },
@@ -655,21 +793,29 @@
            var that = this
            this.$refs.form.validate((vaild, done) => {
                if (vaild) {
                    insert(this.form).then(() => {
                        this.onLoad(this.page)
                    if(this.form.saleNum<0 || this.form.salePrice<0){
                        this.$message({
                            type: "success",
                            message: "操作成功!"
                            type: "warning",
                            message: "销售数量和销售价格不能为负数!"
                        })
                        //提交完成,关闭窗口清空数据
                        that.cleanData()
                        done()
                    }, error => {
                        window.console.log(error)
                        //提交失败,关闭窗口清空数据
                        that.cleanData()
                        done()
                    })
                    }else{
                        insert(this.form).then(() => {
                            this.onLoad(this.page)
                            this.$message({
                                type: "success",
                                message: "操作成功!"
                            })
                            //提交完成,关闭窗口清空数据
                            that.cleanData()
                            done()
                        }, error => {
                            window.console.log(error)
                            //提交失败,关闭窗口清空数据
                            that.cleanData()
                            done()
                        })
                    }
                }
            })
        },
@@ -678,21 +824,30 @@
            var that = this
            this.$refs.form.validate((vaild, done) => {
                if (vaild) {
                    addjg(this.formJG).then(() => {
                        this.onLoad(this.page)
                        this.$message({
                            type: "success",
                            message: "操作成功!"
                        })
                        //提交完成,关闭窗口清空数据
                        that.cleanJGData()
                        done()
                    }, error => {
                        window.console.log(error)
                        //提交失败,关闭窗口清空数据
                        that.cleanJGData()
                        done()
                    this.formJG['farmId'] = this.$farmId
                  if(this.formJG.saleNum <0 || this.formJG.processNum<0){
                    this.$message({
                      type: "warning",
                      message: "加工数量和产品数量不能为负数!"
                    })
                    done()
                  }else {
                    submitProcessJG(this.formJG).then(() => {
                      this.onLoad(this.page)
                      this.$message({
                        type: "success",
                        message: "操作成功!"
                      })
                      //提交完成,关闭窗口清空数据
                      that.cleanJGData()
                      done()
                    }, error => {
                      window.console.log(error)
                      //提交失败,关闭窗口清空数据
                      that.cleanJGData()
                      done()
                    })
                  }
                }
            })
        },
@@ -701,19 +856,50 @@
            var that = this
            this.$refs.form.validate((vaild, done) => {
                if (vaild) {
                    insertKC(this.formKC).then(() => {
                    if(this.formKC.saleNum<0){
                        this.$message({
                            type: "warning",
                            message: "损耗数量不能为负数!"
                        })
                        done()
                    }else{
                        insertKC(this.formKC).then(() => {
                            this.onLoad(this.page)
                            this.$message({
                                type: "success",
                                message: "操作成功!"
                            })
                            //提交完成,关闭窗口清空数据
                            that.cleanKCData()
                            done()
                        }, error => {
                            window.console.log(error)
                            //提交失败,关闭窗口清空数据
                            that.cleanKCData()
                            done()
                        })
                    }
                }
            })
        },
        // 出库表单提交
        submitCK () {
            var that = this
            this.$refs.form.validate((vaild, done) => {
                if (vaild) {
                    submitProcess(this.formCK).then(() => {
                        this.onLoad(this.page)
                        this.$message({
                            type: "success",
                            message: "操作成功!"
                        })
                        //提交完成,关闭窗口清空数据
                        that.cleanKCData()
                        that.cleanCKData()
                        done()
                    }, error => {
                        window.console.log(error)
                        //提交失败,关闭窗口清空数据
                        that.cleanKCData()
                        that.cleanCKData()
                        done()
                    })
                }
@@ -743,19 +929,19 @@
                this.form.createUser = this.userInfo.user_id
                this.form.weight = data.productInventoryNum
                this.form.proid = data.id
                this.form.landId = data.landId
                this.form.strainId = data.strainId
                // this.form.landId = data.landId
                // this.form.strainId = data.strainId
                this.form.strainName = data.strainName
                this.form.processName = data.processName
                this.visible = true
            } else if (index == 1) {    //库存损耗
            } else if (index == 1) {    //库存损耗
                this.formKC.name = this.userInfo.nick_name
                this.formKC.createUser = this.userInfo.user_id
                this.formKC.weight = data.productInventoryNum
                this.formKC.proid = data.id
                this.formKC.landId = data.landId
                this.formKC.strainId = data.strainId
                // this.formKC.landId = data.landId
                // this.formKC.strainId = data.strainId
                this.formKC.strainName = data.strainName
                this.formKC.processName = data.processName
@@ -765,17 +951,33 @@
                this.formJG.name = this.userInfo.nick_name
                this.formJG.createUser = this.userInfo.user_id
                this.formJG.proid = data.id
                this.formJG.landId = data.landId
                this.formJG.weight = data.weight
                this.formJG.strainId = data.strainId
                // this.formJG.landId = data.landId
                this.formJG.weight = data.productInventoryNum
                // this.formJG.strainId = data.strainId
                this.formJG.strainName = data.strainName
                this.formJG.processName = data.processName
                this.formJG.parentId = data.productId
                this.visibleJG = true
            }else if (index == 3) { //出库
                this.formCK.name = this.userInfo.nick_name
                this.formCK.createUser = this.userInfo.user_id
                this.formCK.weight = data.productInventoryNum
                this.formCK.proid = data.id
                // this.formCK.landId = data.landId
                // this.formCK.strainId = data.strainId
                this.formCK.strainName = data.strainName
                this.formCK.processName = data.processName
                this.visibleCK = true
            }
        },
        //销售
        cleanData () {
            var that = this
            that.form.saleDestination = ""
            that.$refs.cascader.$refs.panel.clearCheckedNodes()
            that.$refs.cascader.$refs.panel.activePath=[]
            that.$refs.form.resetFields()
            that.visible = false
        },
@@ -791,6 +993,13 @@
            that.$refs.form.resetFields()
            that.visibleJG = false
        },
        //出库
        cleanCKData () {
            var that = this
            that.formCK.saleDestination = ""
            that.$refs.form.resetFields()
            that.visibleCK = false
        },
        handleSizeChange (val) {
            this.page.pageSize = val
            this.onLoad(this.page)
@@ -801,7 +1010,7 @@
        },
        onLoad (page, params = {}) {
            params['tenantId'] = this.userInfo.tenant_id
            params['deptId'] = this.userInfo.dept_id
            params['farmId'] = this.$farmId
            getPage(
                page.currentPage,
                page.pageSize,
@@ -809,9 +1018,14 @@
            ).then((res) => {
                const data = res.data.data
                this.page.total = data.total
                this.data = data.records
                this.data = data.records.filter((e)=>{
                    return e.productInventoryNum != 0
                })
                this.data.forEach((e)=>{
                    e.productInventoryNum = fixed.fixedNum(e.productInventoryNum)
                })
                this.loading = false
                this.selectionClear()
                // this.selectionClear()
            })
        },
    },
@@ -841,7 +1055,7 @@
            .farm {
                width: 168px;
                height: 240px;
                height: 310px;
                /*height: 315px;*/
                background-color: #f7f9fb;
                border-radius: 5px;