fuliqi
2024-04-03 bce10b2db48c97a23543189368ceb6a8f3737fb3
src/views/system/calculate/record/index.vue
@@ -1,21 +1,25 @@
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="规则名称" prop="rulesName">
        <el-input
          v-model="queryParams.rulesName"
          placeholder="请输入规则名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      <el-form-item label="单位名" prop="checkUnitId">
        <el-select v-model="queryParams.checkUnitId" clearable @clear="handleQuery" placeholder="请选择单位">
          <el-option
            label="成都x运维"
            value="1">
          </el-option>
          <el-option
            label="成都a运维"
            value="2">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="合同名称" prop="contractName">
        <el-input
          v-model="queryParams.contractName"
          placeholder="请输入合同名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      <el-form-item label="核算日期" prop="date" >
        <el-date-picker clearable
          v-model="queryParams.date"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择核算日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -26,33 +30,85 @@
    <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="['system:record:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:record:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:record:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出
        </el-button>
          v-hasPermi="['system:record:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="rulesList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="规则名称" align="center" prop="rulesName"/>
      <el-table-column label="合同名称" align="center" prop="contractName"/>
      <el-table-column label="金额(元)" align="center" prop="amount"/>
      <el-table-column label="数量" align="center" prop="num">
        100
      </el-table-column>
      <el-table-column label="合计(元)" align="center" prop="money">
        <template slot-scope="scope" >
          {{scope.row.amount*100}}
    <el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="核算记录日期" align="center" prop="date" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
      <el-table-column label="核算规则" align="center" prop="ruleId">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          <div v-if="scope.row.ruleId == 1">成都x运维考核结果应用规则</div>
        </template>
      </el-table-column>
      <el-table-column label="单位名" align="center" prop="unitId" >
        <template slot-scope="scope">
          <div v-if="scope.row.unitId == 2">成都x运维</div>
        </template>
      </el-table-column>
      <el-table-column label="总服务费" align="center" prop="totalMount" />
      <el-table-column label="扣减服务费" align="center" prop="deductAmount" />
      <el-table-column label="考核分数" align="center" prop="score" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:record:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:record:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -65,19 +121,38 @@
      @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="rulesName">
          <el-input v-model="form.rulesName" placeholder="请输入规则名称"/>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="核算对象" prop="checkUnitId">
          <el-select v-model="queryParams.checkUnitId" clearable @clear="handleQuery" placeholder="核算对象">
            <el-option
              label="成都x运维"
              value="1">
            </el-option>
            <el-option
              label="成都a运维"
              value="2">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="合同名称" prop="contractName">
          <el-input v-model="form.contractName" placeholder="请输入合同名称"/>
        <el-form-item label="核算记录日期" prop="date" >
          <el-date-picker clearable
            v-model="form.date"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择核算记录日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="金额" prop="amount">
          <el-input v-model="form.amount" placeholder="请输入金额"/>
        <el-form-item label="总服务费" prop="totalMount">
          <el-input v-model="form.totalMount" placeholder="请输入总服务费" />
        </el-form-item>
        <el-form-item label="扣减服务费" prop="deductAmount">
          <el-input v-model="form.deductAmount" placeholder="请输入扣减服务费" />
        </el-form-item>
        <el-form-item label="考核分数" prop="score">
          <el-input v-model="form.score" placeholder="请输入考核分数" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -88,13 +163,12 @@
</template>
<script>
import { listRules, getRules, delRules, addRules, updateRules } from '@/api/platform/calculate-rule'
import { listRecord, getRecord, delRecord, addRecord, updateRecord } from "@/api/platform/calculate-record";
export default {
  name: 'Rules',
  name: "Record",
  data() {
    return {
      num: 100,
      // 遮罩层
      loading: true,
      // 选中数组
@@ -107,126 +181,132 @@
      showSearch: true,
      // 总条数
      total: 0,
      // 核算规则表格数据
      rulesList: [],
      // 核算记录表格数据
      recordList: [],
      // 弹出层标题
      title: '',
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        rulesName: null,
        contractName: null,
        deleted: null
        date: null,
        ruleId: null,
        unitId: null,
        totalMount: null,
        deductAmount: null,
        score: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    }
      rules: {
        id: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList()
    this.getList();
  },
  methods: {
    /** 查询核算规则列表 */
    /** 查询核算记录列表 */
    getList() {
      this.loading = true
      listRules(this.queryParams).then(response => {
        this.rulesList = response.rows
        this.total = response.total
        this.loading = false
      })
      this.loading = true;
      listRecord(this.queryParams).then(response => {
        this.recordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        rulesName: null,
        contractName: null,
        amount: null,
        createTime: null,
        updateTime: null,
        deleted: null
      }
      this.resetForm('form')
        date: null,
        ruleId: null,
        unitId: null,
        totalMount: null,
        deductAmount: null,
        score: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加核算规则'
      this.reset();
      this.open = true;
      this.title = "添加核算记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      this.reset();
      const id = row.id || this.ids
      getRules(id).then(response => {
        this.form = response.data
        this.open = true
        this.title = '修改核算规则'
      })
      getRecord(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改核算记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRules(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.getList()
            })
            updateRecord(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRules(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.getList()
            })
            addRecord(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      })
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除核算规则编号为"' + ids + '"的数据项?').then(function() {
        return delRules(ids)
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除核算记录编号为"' + ids + '"的数据项?').then(function() {
        return delRecord(ids);
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('platform/rules/export', {
      this.download('system/record/export', {
        ...this.queryParams
      }, `rules_${new Date().getTime()}.xlsx`)
      }, `record_${new Date().getTime()}.xlsx`)
    }
  }
}
};
</script>