|
|
@@ -0,0 +1,464 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true">
|
|
|
+ <el-form-item label="物料名称" prop="officeSupplyName">
|
|
|
+ <el-input
|
|
|
+ v-model="queryParams.officeSupplyName"
|
|
|
+ placeholder="请输入物料名称"
|
|
|
+ clearable
|
|
|
+ style="width: 240px"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="只看自己" prop="self">
|
|
|
+ <el-switch v-model="queryParams.self"></el-switch>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="需求月份" prop="month">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="queryParams.month"
|
|
|
+ type="month"
|
|
|
+ value-format="yyyy-MM"
|
|
|
+ placeholder="选择月份"
|
|
|
+ clearable>
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" style="margin-bottom: 8px">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleAdd"
|
|
|
+ v-hasPermi="['material:office:add']"
|
|
|
+ >新增
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ plain
|
|
|
+ icon="el-icon-download"
|
|
|
+ size="mini"
|
|
|
+ @click="handleExport"
|
|
|
+ v-hasPermi="['material:office:export']"
|
|
|
+ >导出
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-table :data="officeSupplyList"
|
|
|
+ ref="officeSupplyList"
|
|
|
+ stripe
|
|
|
+ border
|
|
|
+ size="mini">
|
|
|
+ <el-table-column label="编号" prop="id" width="80"/>
|
|
|
+ <el-table-column label="物料名称" prop="officeSupplyName" :show-overflow-tooltip="true"/>
|
|
|
+ <el-table-column label="规格" prop="specification" :show-overflow-tooltip="true"/>
|
|
|
+ <el-table-column label="单位" prop="unit" mini-width="80"/>
|
|
|
+ <el-table-column label="数量" prop="num" mini-width="80"/>
|
|
|
+ <el-table-column label="价格(元)" prop="price" mini-width="80"/>
|
|
|
+ <el-table-column label="领用人" prop="receiveUserName" width="100"/>
|
|
|
+ <el-table-column label="需求月份" prop="month"/>
|
|
|
+ <el-table-column label="操作" align="center" width="130">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ v-if="showEditBtn(scope.row)"
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
+ v-hasPermi="['material:office:edit']"
|
|
|
+ >修改
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
+ v-hasPermi="['material:office:delete']"
|
|
|
+ >删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div style="margin-top: 10px;text-align: center">
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ @size-change="handleSizeChange"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="queryParams.pageNum"
|
|
|
+ :page-sizes="[10, 20, 50]"
|
|
|
+ :page-size="queryParams.pageSize"
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
+ :total="total">
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <!-- 添加办公用品需求对话框 -->
|
|
|
+ <el-dialog :title="title" :visible.sync="open" @close="dialogClose" width="80%" append-to-body
|
|
|
+ :close-on-click-modal="false">
|
|
|
+ <el-form ref="addForm" :model="addForm" :rules="rules" size="mini" inline>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="22">
|
|
|
+ <el-form-item label="需求月份">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="addForm.month"
|
|
|
+ type="month"
|
|
|
+ value-format="yyyy-MM"
|
|
|
+ placeholder="选择月份"
|
|
|
+ :picker-options="getPickerOptions"
|
|
|
+ clearable>
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="2">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button icon="el-icon-plus" @click="addRow">添加</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <el-table :data="addList" class="add-table" border size="mini">
|
|
|
+ <el-table-column label="物品名称" prop="officeSupplyName">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input v-model="scope.row.officeSupplyName" size="mini" placeholder="请输入物品名称"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="规格/货号" prop="specification">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input v-model="scope.row.specification" size="mini" placeholder="请输入规格/货号"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="单位" prop="unit" width="120px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input v-model="scope.row.unit" size="mini" placeholder="请输入单位"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="价格" prop="price" width="120px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input v-model="scope.row.price" size="mini" placeholder="请输入价格"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="数量" prop="num" width="100px">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input-number v-model="scope.row.num" size="mini" controls-position="right" :min="0"
|
|
|
+ placeholder="请输入数量" style="width: 100%"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="备注">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input v-model="scope.row.remark" size="mini" type="textarea" autosize/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column width="50">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ @click="deleteRow(scope.row)">
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm" size="mini">确 定</el-button>
|
|
|
+ <el-button @click="cancel" size="mini">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 修改办公用品对话框 -->
|
|
|
+ <el-dialog title="修改" :visible.sync="editOpen" @close="dialogClose" width="500px" append-to-body
|
|
|
+ :close-on-click-modal="false">
|
|
|
+ <el-form ref="editForm" :model="editForm" :rules="rules" size="mini" label-width="100px">
|
|
|
+ <el-form-item label="物品名称" prop="officeSupplyName">
|
|
|
+ <el-input v-model="editForm.officeSupplyName" placeholder="请输入物品名称" :disabled="editForm.monthOrWeek==='2'"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="规格/货号" prop="specification">
|
|
|
+ <el-input v-model="editForm.specification" placeholder="请输入规格/货号" :disabled="editForm.monthOrWeek==='2'"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="单位" prop="unit">
|
|
|
+ <el-input v-model="editForm.unit" placeholder="请输入单位" :disabled="editForm.monthOrWeek==='2'"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="价格" prop="price">
|
|
|
+ <el-input v-model="editForm.price" placeholder="请输入价格" :disabled="editForm.monthOrWeek==='2'"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="数量" prop="num">
|
|
|
+ <el-input-number v-model="editForm.num" controls-position="right" :min="0" placeholder="请输入数量"/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注">
|
|
|
+ <el-input v-model="editForm.remark" type="textarea"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" size="mini" @click="submitEditForm">确 定</el-button>
|
|
|
+ <el-button size="mini" @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ listOfficeSupply,
|
|
|
+ getOfficeSupply,
|
|
|
+ delOfficeSupply,
|
|
|
+ addOfficeSupply,
|
|
|
+ updateOfficeSupply,
|
|
|
+ exportOfficeSupply
|
|
|
+} from "@/api/material/office";
|
|
|
+import DateUtil from "@/utils/date"
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "officeSupply",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ // 物料表格数据
|
|
|
+ officeSupplyList: [],
|
|
|
+ // 弹出层标题
|
|
|
+ title: "",
|
|
|
+ // 是否显示弹出层
|
|
|
+ open: false,
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ officeSupplyName: undefined,
|
|
|
+ self: false,
|
|
|
+ month: undefined
|
|
|
+ },
|
|
|
+ // 表单参数
|
|
|
+ addForm: {
|
|
|
+ month: undefined,
|
|
|
+ },
|
|
|
+ addList: [],
|
|
|
+
|
|
|
+ editOpen: false,
|
|
|
+ editForm: {
|
|
|
+ id: undefined,
|
|
|
+ officeSupplyName: undefined,
|
|
|
+ specification: undefined,
|
|
|
+ unit: undefined,
|
|
|
+ price: undefined,
|
|
|
+ num: 0,
|
|
|
+ remark: undefined
|
|
|
+ },
|
|
|
+
|
|
|
+ projectList: [],
|
|
|
+
|
|
|
+ // 表单校验
|
|
|
+ rules: {
|
|
|
+ officeSupplyName: [
|
|
|
+ {required: true, message: "物料名称不能为空", trigger: "blur"}
|
|
|
+ ],
|
|
|
+ specification: [
|
|
|
+ {required: true, message: "物料规格不能为空", trigger: "blur"}
|
|
|
+ ],
|
|
|
+ articleNo: [
|
|
|
+ {required: true, message: "品牌/货号不能为空", trigger: "blur"}
|
|
|
+ ],
|
|
|
+ unit: [
|
|
|
+ {required: true, message: "单位不能为空", trigger: "blur"}
|
|
|
+ ],
|
|
|
+ num: [
|
|
|
+ {required: true, message: "数量不能为空", trigger: "blur"}
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /** 查询物料列表 */
|
|
|
+ getList() {
|
|
|
+ listOfficeSupply(this.queryParams).then(res => {
|
|
|
+ this.officeSupplyList = res.data.records;
|
|
|
+ this.total = res.data.total;
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 取消按钮
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ this.editOpen = false;
|
|
|
+ this.reset();
|
|
|
+ },
|
|
|
+ // 对话框关闭回调
|
|
|
+ dialogClose() {
|
|
|
+ this.open = false;
|
|
|
+ this.editOpen = false;
|
|
|
+ this.reset();
|
|
|
+ },
|
|
|
+ // 表单重置
|
|
|
+ reset() {
|
|
|
+ this.addForm = {
|
|
|
+ month: undefined,
|
|
|
+ };
|
|
|
+ this.addList = []
|
|
|
+ this.resetForm("addForm");
|
|
|
+ this.editForm = {
|
|
|
+ id: undefined,
|
|
|
+ officeSupplyName: undefined,
|
|
|
+ specification: undefined,
|
|
|
+ unit: undefined,
|
|
|
+ price: undefined,
|
|
|
+ num: 0,
|
|
|
+ remark: undefined
|
|
|
+ }
|
|
|
+ this.resetForm("editForm");
|
|
|
+ },
|
|
|
+ /** 搜索按钮操作 */
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.queryParams.pageSize = 10;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ /** 重置按钮操作 */
|
|
|
+ resetQuery() {
|
|
|
+ this.$refs.queryForm.resetFields();
|
|
|
+ this.handleQuery();
|
|
|
+ },
|
|
|
+ handleSizeChange(val) {
|
|
|
+ this.pageSize = val;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ handleCurrentChange(val) {
|
|
|
+ this.pageNum = val;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ getPickerOptions() {
|
|
|
+ return {
|
|
|
+ disabledDate: time => time.getTime() < DateUtil.unix(DateUtil.afterMonth()) * 1000
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showEditBtn(row) {
|
|
|
+ if (DateUtil.getMinutes() < DateUtil.getMinutes(DateUtil.day(DateUtil.month() + '25'))) {
|
|
|
+ return DateUtil.unix(row.month) >= DateUtil.unix(DateUtil.afterMonth())
|
|
|
+ } else {
|
|
|
+ return DateUtil.unix(row.month) >= DateUtil.unix(DateUtil.afterMonth())
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd() {
|
|
|
+ this.reset();
|
|
|
+ this.addForm.monthOrWeek = '1'
|
|
|
+ this.title = "添加办公物品需求";
|
|
|
+ this.addList.push({
|
|
|
+ id: undefined,
|
|
|
+ officeSupplyName: undefined,
|
|
|
+ specification: undefined,
|
|
|
+ unit: undefined,
|
|
|
+ num: 0,
|
|
|
+ price: 0,
|
|
|
+ remark: undefined
|
|
|
+ })
|
|
|
+ this.open = true;
|
|
|
+ },
|
|
|
+ addRow() {
|
|
|
+ this.addList.push({
|
|
|
+ id: undefined,
|
|
|
+ officeSupplyName: undefined,
|
|
|
+ specification: undefined,
|
|
|
+ unit: undefined,
|
|
|
+ num: 0,
|
|
|
+ price: 0,
|
|
|
+ remark: undefined
|
|
|
+ })
|
|
|
+ },
|
|
|
+ deleteRow(row) {
|
|
|
+ if (this.addList.length === 1) {
|
|
|
+ this.addList = [
|
|
|
+ {
|
|
|
+ id: undefined,
|
|
|
+ officeSupplyName: undefined,
|
|
|
+ specification: undefined,
|
|
|
+ unit: undefined,
|
|
|
+ num: 0,
|
|
|
+ price: 0,
|
|
|
+ remark: undefined
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let index = this.addList.indexOf(row);
|
|
|
+ this.addList.splice(index, 1)
|
|
|
+
|
|
|
+ },
|
|
|
+ handleExport() {
|
|
|
+ if (!this.queryParams.month) {
|
|
|
+ this.$message.warning("请选择月份")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ exportOfficeSupply(this.queryParams)
|
|
|
+ },
|
|
|
+ /** 修改按钮操作 */
|
|
|
+ handleUpdate(row) {
|
|
|
+ this.editForm = row
|
|
|
+ this.editOpen = true
|
|
|
+ },
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm() {
|
|
|
+ this.$refs["addForm"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ let data = {
|
|
|
+ month: this.addForm.month,
|
|
|
+ list: this.addList
|
|
|
+ }
|
|
|
+ addOfficeSupply(data).then(res => {
|
|
|
+ this.$message.success("添加成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ submitEditForm() {
|
|
|
+ this.$refs["editForm"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ updateOfficeSupply(this.editForm).then(res => {
|
|
|
+ this.$message.success("修改成功");
|
|
|
+ this.editOpen = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 删除按钮操作 */
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$confirm('是否确认删除编号为"' + row.id + '"的数据项?').then(() => {
|
|
|
+ return delOfficeSupply(row.id);
|
|
|
+ }).then(() => {
|
|
|
+ this.getList();
|
|
|
+ this.$message.success("删除成功");
|
|
|
+ }).catch(() => {
|
|
|
+ });
|
|
|
+ },
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+.add-table::v-deep.el-table .cell {
|
|
|
+ padding-left: 2px;
|
|
|
+ padding-right: 2px;
|
|
|
+}
|
|
|
+
|
|
|
+.add-table::v-deep.el-table th.el-table__cell > .cell {
|
|
|
+ padding-left: 5px;
|
|
|
+ padding-right: 5px;
|
|
|
+}
|
|
|
+</style>
|