lkk
2024-12-16 c7b33db117fd2893d7d1c93bf5d46e87d33e44d0
src/views/record/record/index.vue
@@ -1,38 +1,88 @@
<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="75px">
            <el-form-item label="体检号" prop="tjNum">
                <el-input v-model="queryParams.tjNum" placeholder="请输入领餐人体检号" clearable @keyup.enter.native="handleQuery" style="width: 200px;" ref="inputName" @blur="handleQuery" />
            </el-form-item>
            <el-form-item label="姓名" prop="tjPeopleName">
                <el-input v-model="queryParams.tjPeopleName" placeholder="请输入领餐人姓名" clearable style="width: 200px;"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="登记时间" prop="cateringId">
                <el-input v-model="queryParams.cateringId" placeholder="请输入登记时间" clearable style="width: 200px;"
                    @keyup.enter.native="handleQuery" />
            </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><br>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="75px"
    >
      <el-form-item label="体检号" prop="tjNum">
        <el-input
          v-model="queryParams.tjNum"
          placeholder="请输入领餐人体检号"
          clearable
          @keyup.enter.native="handleQuery"
          style="width: 200px"
          ref="inputName"
          @blur="hb"
        />
      </el-form-item>
      <el-form-item label="姓名" prop="tjPeopleName">
        <el-input
          v-model="queryParams.tjPeopleName"
          placeholder="请输入领餐人姓名"
          clearable
          style="width: 200px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="登记时间" prop="cateringId">
        <el-input
          v-model="queryParams.cateringId"
          placeholder="请输入登记时间"
          clearable
          style="width: 200px"
          @keyup.enter.native="handleQuery"
        />
      </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
    ><br />
        <el-form :label-position="labelPosition"  :inline="true" label-width="75px" :model="formLabelAlign"
            class="demo-form-inline">
            <el-form-item label="配餐名称" >
                <el-input v-model="formLabelAlign.name" style="width: 200px;" placeholder="请输入配餐名称"></el-input>
            </el-form-item>
            <el-form-item label="套餐明细">
                <el-input v-model="formLabelAlign.region" style="width: 200px;" placeholder="请输入套餐明细"></el-input>
            </el-form-item>
            <el-form-item label="营养说明" >
                <el-input v-model="formLabelAlign.type" style="width: 200px;" placeholder="请输入营养说明"></el-input>
            </el-form-item>
        </el-form>
    <el-form
      :label-position="labelPosition"
      :inline="true"
      label-width="75px"
      :model="formLabelAlign"
      class="demo-form-inline"
    >
      <el-form-item label="配餐名称">
        <el-input
          v-model="formLabelAlign.name"
          style="width: 200px"
          placeholder="请输入配餐名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="套餐明细">
        <el-input
          v-model="formLabelAlign.region"
          style="width: 200px"
          placeholder="请输入套餐明细"
        ></el-input>
      </el-form-item>
      <el-form-item label="营养说明">
        <el-input
          v-model="formLabelAlign.type"
          style="width: 200px"
          placeholder="请输入营养说明"
        ></el-input>
      </el-form-item>
    </el-form>
        <el-row :gutter="10" class="mb8">
            <!-- <el-col :span="1.5">
    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
                    <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                        v-hasPermi="['record:record:add']">新增
                    </el-button>
@@ -42,238 +92,347 @@
                        v-hasPermi="['record:record:edit']">修改
                    </el-button>
                </el-col> -->
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-plus" size="mini" :disabled="multiple" @click="handleDelete"
                    v-hasPermi="['record:record:remove']">领餐
                </el-button>
            </el-col>
            <el-col :span="1.5">
                <el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport"
                    v-hasPermi="['record:record:export']">导出
                </el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['record:record:remove']"
          >领餐
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['record:record:export']"
          >导出
        </el-button>
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table
      v-loading="loading"
      :data="recordList"
      @selection-change="handleSelectionChange"
      border
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="${comment}" align="center" prop="id"/> -->
      <el-table-column label="序号" align="center" prop="newID" width="55px" />
      <el-table-column
        label="领餐人体检号"
        align="center"
        prop="tjNum"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="领餐人姓名"
        align="center"
        prop="tjPeopleName"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="性别"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="年龄"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="电话"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="团体/个人"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="所选套餐"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="登记时间"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="配餐名称"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="报告时间"
        align="center"
        prop="cateringId"
        :show-overflow-tooltip="true"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="80px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['record:record:edit']"
            title="修改"
          >
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['record:record:remove']"
            title="删除"
          >
          </el-button>
        </template>
      </el-table-column>
    </el-table>
        <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange" border>
            <el-table-column type="selection" width="55" align="center" />
            <!-- <el-table-column label="${comment}" align="center" prop="id"/> -->
            <el-table-column label="序号" align="center" prop="newID" width="55px" />
            <el-table-column label="领餐人体检号" align="center" prop="tjNum" :show-overflow-tooltip="true" />
            <el-table-column label="领餐人姓名" align="center" prop="tjPeopleName" :show-overflow-tooltip="true" />
            <el-table-column label="性别" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="年龄" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="电话" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="团体/个人" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="所选套餐" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="登记时间" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="配餐名称" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="报告时间" align="center" prop="cateringId" :show-overflow-tooltip="true" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="80px">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                        v-hasPermi="['record:record:edit']" title="修改">
                    </el-button>
                    <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                        v-hasPermi="['record:record:remove']" title="删除">
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
        <!-- 添加或修改领餐记录对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                <el-form-item label="领餐人体检号" prop="tjNum">
                    <el-input v-model="form.tjNum" placeholder="请输入领餐人体检号" />
                </el-form-item>
                <el-form-item label="领餐人姓名" prop="tjPeopleName">
                    <el-input v-model="form.tjPeopleName" placeholder="请输入领餐人姓名" />
                </el-form-item>
                <el-form-item label="${comment}" prop="cateringId">
                    <el-input v-model="form.cateringId" placeholder="请输入${comment}" />
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
    </div>
    <!-- 添加或修改领餐记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="领餐人体检号" prop="tjNum">
          <el-input v-model="form.tjNum" placeholder="请输入领餐人体检号" />
        </el-form-item>
        <el-form-item label="领餐人姓名" prop="tjPeopleName">
          <el-input
            v-model="form.tjPeopleName"
            placeholder="请输入领餐人姓名"
          />
        </el-form-item>
        <el-form-item label="${comment}" prop="cateringId">
          <el-input v-model="form.cateringId" placeholder="请输入${comment}" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
    listRecord,
    getRecord,
    delRecord,
    addRecord,
    updateRecord
  listRecord,
  getRecord,
  delRecord,
  addRecord,
  updateRecord,
} from "@/api/record/record";
export default {
    name: "Record",
    data() {
        return {
            formLabelAlign: {
          name: '',
          region: '',
          type: ''
        },
        labelPosition: "right",
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 领餐记录表格数据
            recordList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                tjNum: null,
                tjPeopleName: null,
                cateringId: new Date(new Date().getTime() + 8 * 3600 * 1000).toJSON().substr(0, 19).replace('T', ' '),
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
            }
        };
    },
    created() {
        this.getList();
    },
    mounted() {
  name: "Record",
  data() {
    return {
      formLabelAlign: {
        name: "",
        region: "",
        type: "",
      },
      labelPosition: "right",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 领餐记录表格数据
      recordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tjNum: null,
        tjPeopleName: null,
        cateringId: new Date(new Date().getTime() + 8 * 3600 * 1000)
          .toJSON()
          .substr(0, 19)
          .replace("T", " "),
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },
  created() {
    this.getList();
  },
  mounted() {
    this.$nextTick(() => {
      this.$refs.inputName.focus();
    });
  },
    methods: {
        /** 查询领餐记录列表 */
        getList() {
            this.loading = true;
            listRecord(this.queryParams).then(response => {
                this.recordList = response.rows;
                response.rows.forEach((item,index) => {
          item.newID=(this.queryParams.pageNum-1)*this.queryParams.pageSize+index+1
  methods: {
    /** 查询领餐记录列表 */
    getList() {
      this.loading = true;
      listRecord(this.queryParams).then((response) => {
        this.recordList = response.rows;
        response.rows.forEach((item, index) => {
          item.newID =
            (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
            index +
            1;
        });
                this.total = response.total;
                this.loading = false;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        tjNum: null,
        tjPeopleName: null,
        cateringId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        deleted: null,
      };
      this.resetForm("form");
    },
    hb() {
      if (this.queryParams.tjNum != null) {
        this.handleQuery();
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.cateringId = ""
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加领餐记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getRecord(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改领餐记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.reId != null) {
            updateRecord(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.reset();
        },
        // 表单重置
        reset() {
            this.form = {
                id: null,
                tjNum: null,
                tjPeopleName: null,
                cateringId: null,
                createBy: null,
                createTime: null,
                updateBy: null,
                updateTime: null,
                deleted: null
            };
            this.resetForm("form");
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "添加领餐记录";
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.reset();
            const id = row.id || this.ids
            getRecord(id).then(response => {
                this.form = response.data;
                this.open = true;
                this.title = "修改领餐记录";
          } else {
            addRecord(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
        },
        /** 提交按钮 */
        submitForm() {
            this.$refs["form"].validate(valid => {
                if (valid) {
                    if (this.form.reId != null) {
                        updateRecord(this.form).then(response => {
                            this.$modal.msgSuccess("修改成功");
                            this.open = false;
                            this.getList();
                        });
                    } else {
                        addRecord(this.form).then(response => {
                            this.$modal.msgSuccess("新增成功");
                            this.open = false;
                            this.getList();
                        });
                    }
                }
            });
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            const reIds = row.reId || this.ids;
            this.$modal.confirm('是否确认删除编号为"' + reIds + '"的数据项?').then(function () {
                return delRecord(reIds);
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => { });
        },
        /** 复选框选中数据 */
        handleDmKsSelectionChange(selection) {
            this.checkedDmKs = selection.map(item => item.index)
          }
        }
        ,
        /** 导出按钮操作 */
        handleExport() {
            this.download('${moduleName}/${businessName}/export', {
                ...this.queryParams
            }, `${businessName}_#[[${new Date().getTime()}.xlsx`)
        }
    }
}
    ;
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const reIds = row.reId || this.ids;
      this.$modal
        .confirm('是否确认删除编号为"' + reIds + '"的数据项?')
        .then(function () {
          return delRecord(reIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 复选框选中数据 */
    handleDmKsSelectionChange(selection) {
      this.checkedDmKs = selection.map((item) => item.index);
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "${moduleName}/${businessName}/export",
        {
          ...this.queryParams,
        },
        `${businessName}_#[[${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>