llj
2025-12-08 d60080e1a29acf61474b882cdf427bf92ec8bc30
费用项目
2个文件已添加
3个文件已修改
1393 ■■■■■ 已修改文件
.env.development 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/modules/permission.js 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basic/gyItemMoney/gyItemMoney.vue 745 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basic/gyItemMoney/gyItemMoneyEdit.vue 613 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.env.development
@@ -5,8 +5,9 @@
ENV = 'development'
# 智云迈思L-MOM管理系统/开发环境
VUE_APP_BASE_API = http://localhost:81/API/
# VUE_APP_BASE_API = http://localhost:81/API/
# VUE_APP_BASE_API = http://220.189.218.155:9010/API/
# VUE_APP_BASE_API = http://47.96.97.237/API/
VUE_APP_BASE_API = http://localhost:8082/LuBaoAPI/
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
src/router/index.js
@@ -397,6 +397,25 @@
      },
    ],
  },
    //费用项目列表
  {//src\views\basic\gyItemMoney\gyItemMoney.vue
    path: "/basic/gy/gyItemMoney",
    component: Layout,
    hidden: true,
    redirect: "noredirect",
    meta: {
      breadcrumb: false, // 如果设置为false,则不会在breadcrumb面包屑中显示
      activeMenu: "/basic/gy", // 当路由设置了该属性,则会高亮相对应的侧边栏。
    },
    children: [
      {
        path: "/basic/gy/gyItemMoney",
        component: () => import("@/views/basic/gyItemMoney/gyItemMoney.vue"),
        name: "GyItemMoney",
        meta: { title: "费用项目列表", activeMenu: "basic/gy" },
      },
    ],
  },
  // 销售订单
  {
    path: "/sell/seOrder/xsSeOrderBill",
src/store/modules/permission.js
@@ -522,6 +522,19 @@
                    path: "gyCartypelist",
                  },
                  {
                    meta: {
                      icon: "build",
                      link: null,
                      noCache: false,
                      title: "费用项目列表",
                    },
                    component: () =>
                      import("@/views/basic/gyItemMoney/gyItemMoney.vue"),
                    hidden: false,
                    name: "GyItemMoney",
                    path: "gyItemMoney",
                  },
                  {
                    meta: {
                      icon: "build",
                      link: null,
src/views/basic/gyItemMoney/gyItemMoney.vue
New file
@@ -0,0 +1,745 @@
<template>
  <div style="padding: 10px; position: relative;">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="98px" class="searchBox">
      <el-row>
        <el-form-item label="项目费用代码" prop="HNumber" style="margin-left: 100px;">
          <el-input v-model="queryParams.HNumber" placeholder="请输入项目费用代码" @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="项目费用名称" prop="HName">
          <el-input v-model="queryParams.HName" placeholder="请输入项目费用名称" @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="组织">
          <el-select v-model="queryParams.HOrgID" placeholder="请选择">
            <el-option v-for="(item, index) in organizationList" :key="index" :label="item.Name" :value="item.ID">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label-width="78px">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">
            搜索</el-button>
          <el-button type="primary" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-row>
      <el-collapse v-model="activeSeach">
        <el-collapse-item title="更多" name="1">
          <el-card class="box-card">
            <div slot="header" class="clearfix"><span>过滤</span></div>
            <div>
              <el-form-item label-width="0">
                <el-row>
                  <el-col :span="7">
                    <el-select v-model="queryParams.ColName1" placeholder="请选择">
                      <span v-for="(item, index) in btList" :key="index">
                        <el-option :label="item.field" :value="item.field" v-if="!item.hide"></el-option>
                      </span>
                    </el-select>
                  </el-col>
                  <el-col :span="6" style="padding: 0 10px;">
                    <el-select v-model="queryParams.Comparator1" placeholder="请选择">
                      <el-option v-for="(item, index) in comparatorList" :key="index" :label="item.label"
                        :value="item.value"></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="11">
                    <el-input v-model="queryParams.ColContent1" placeholder="请输入" clearable
                      @keyup.enter.native="handleQuery" />
                  </el-col>
                </el-row>
              </el-form-item>
              <el-row>
                <el-form-item label-width="0">
                  <el-row>
                    <el-col :span="7">
                      <el-select v-model="queryParams.ColName2" placeholder="请选择">
                        <span v-for="(item, index) in btList" :key="index">
                          <el-option :label="item.field" :value="item.field" v-if="!item.hide"></el-option>
                        </span>
                      </el-select>
                    </el-col>
                    <el-col :span="6" style="padding: 0 10px;">
                      <el-select v-model="queryParams.Comparator2" placeholder="请选择">
                        <span v-for="(item, index) in comparatorList" :key="index">
                          <el-option :label="item.field" :value="item.field" v-if="!item.hide"></el-option>
                        </span>
                      </el-select>
                    </el-col>
                    <el-col :span="11">
                      <el-input v-model="queryParams.ColContent2" placeholder="请输入" clearable
                        @keyup.enter.native="handleQuery" />
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-row>
              <el-form-item label-width="0">
                <el-row>
                  <el-col :span="7">
                    <el-select v-model="queryParams.ColName" placeholder="请选择">
                      <el-option v-for="(item, index) in btList" :key="index" :label="item.field"
                        :value="item.field"></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="6" style="padding: 0 10px;">
                    <el-select v-model="queryParams.Comparator" placeholder="请选择">
                      <el-option v-for="(item, index) in comparatorList" :key="index" :label="item.label"
                        :value="item.value"></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="11">
                    <el-input v-model="queryParams.ColContent" placeholder="请输入" clearable
                      @keyup.enter.native="handleQuery" />
                  </el-col>
                </el-row>
              </el-form-item>
            </div>
          </el-card>
        </el-collapse-item>
      </el-collapse>
    </el-form>
    <el-row :gutter="10" class="mb8" style="margin-top: 10px;">
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddEdit(OperationType = 1)"
          id="btn-Add">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single"
          @click="handleEdit(row = rowForm, OperationType = 3)">编辑</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-delete" size="mini" :disabled="single" @click="handleDelete">删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single"
          @click="set_CheckBill(0, form = rowForm)">审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single"
          @click="set_CheckBill(1, form = rowForm)">反审核</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single"
          @click="set_De_Stop(0, form = rowForm)">禁用</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-edit" size="mini" :disabled="single"
          @click="set_De_Stop(1, form = rowForm)">反禁用</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-download" size="mini" @click="handleRowHide">隐藏列设置</el-button>
      </el-col>
    </el-row>
    <div class="tableBox" v-loading="loading">
      <el-table :data="tableData" ref="tableData" max-height="750" @selection-change="handleSelectionChange" border @row-click="handleRowClick" :row-style="rowStyle"
        @cell-dblclick="handleDblclick" v-if="tableShow">
        <template v-for="(item, index) in btList">
          <el-table-column type="selection" width="55" align="center" :fixed="item.fixed" v-if="item.type == 'checkbox'"
            :key="index" />
          <el-table-column :align="item.align" :prop="item.field" :label="item.title" :width="item.width"
            :key="item.sorderid" v-else-if="!item.hide && item.type != 'checkbox'" :sortable="item.sort"
            show-overflow-tooltip :fixed="item.fixed">
            <template slot-scope="{row,  column }">
              <div :style="item.style">
                <span v-if="column.property.includes('日期')">{{ parseTime(row[column.property], '{y}-{m}-{d}') }}</span>
                <el-button type="text" @click="handleEdit(row, OperationType = 3)"
                  v-else-if="column.property == '费用项目代码'">{{ row.费用项目代码 }}</el-button>
                <span v-else>{{ row[column.label] }}</span>
              </div>
            </template>
          </el-table-column>
        </template>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="page" :limit.sync="pageSize" :pageSizes="pageSizes"
        @pagination="getList" />
      <el-dialog title="隐藏列设置" :visible.sync="openRowHide" width="816px" append-to-body>
        <RowSettings :colName="btResList" :HModName="HModName" @rowEditClose="rowSetClose" v-if="rowHideShow" />
      </el-dialog>
      <!-- 编辑 -->
      <el-dialog title="编辑费用项目资料" :visible.sync="openEdit" width="1480px" append-to-body class="xsckdBox" @close="close">
        <edit :OperationType=OperationType :linterid=this.rowForm.HItemID :HSouceBillType=this.rowForm.HSourceBillType
          :copyType="copyType" @editCloseGy="editGyClose" v-if="editShow" />
      </el-dialog>
    </div>
  </div>
</template>
<script>
import axios from 'axios'
import RowSettings from '@/views/component/rowSettings'
import Edit from '@/views/basic/gyItemMoney/gyItemMoneyEdit.vue'
export default {
  name: 'Gy_ItemMoney',
  components: { RowSettings, Edit },
  props: {
    openPage: { type: String, },
  },
  data() {
    return {
      activeSeach: '',
      HModName: 'Gy_ItemMoney',
      editShow: false,
      openEdit: false,
      tableShow: true,
      openRowHide: false,
      rowHideShow: false,
      copyType: 0,
      comparatorList: [
        { label: '=', value: '=' },
        { label: '>=', value: '>=' },
        { label: '>', value: '>' },
        { label: '<=', value: '<=' },
        { label: '<', value: '<' },
        { label: '<>', value: '<>' },
        { label: '包含', value: '7' },
        { label: '左包含', value: '8' },
        { label: '右包含', value: '9' },
        { label: '不包含', value: '10' },
      ],
      sWhere: '',
      organizationList: JSON.parse(sessionStorage.getItem('organizationList') || '[]'),
      OperationType: null,
      baseURL: process.env.VUE_APP_BASE_API,
      lastSelectedRowIndex: null,
      lastSelectedRow: null,
      selectedRow: null,
      rowForm: {},
      activeName: 'first',
      queryParams: {
        HOrgID: sessionStorage["OrganizationID"] - 0,
        HName: null,
        HNumber: null,
        Comparator1: '',
        Comparator2: '',
        Comparator: '',
        ColContent1: '',
        ColContent2: '',
        ColContent: '',
      },
      ids: [],
      single: true,
      multiple: true,
      loading: true,
      tyResList: [],
      btList: [],
      btResList: [],
      tableData: [],
      dataList: [],
      titleData: ["HItemID", "HUSEORGID", "HParentID"],
      pageSizes: [50, 100, 500, 5000, 50000],
      page: 1,
      pageSize: 0,
      total: 0,
      form: {},
      rules: {},
    };
  },
  created() {
    this.getList()
  },
  methods: {
    handleRowHide() {
      this.rowHideShow = true
      this.openRowHide = true
    },
    rowSetClose(val) {
      this.rowHideShow = false
      this.tableShow = true
      this.openRowHide = val
      this.getList()
    },
    getList() {
      this.pageSize = 50
      this.tableShow = false
      this.loading = true
      if (this.pageSize == 0) {
        this.pageSize = 50
      }
      this.sWhere += " and HUSEORGID = '" + this.queryParams.HOrgID + "'"
      axios.get(this.baseURL + '/Gy_BadReason/Gy_ItemMoneyList', {
        params: {
          "sWhere": this.sWhere,
          "user": sessionStorage["HUserName"],
        },
      }).then(response => {
        this.tyResList = response.data.data
        let data1 = response.data
        let option = []
        if (data1.code == 1) {
          this.btResList = data1.list
          this.total = data1.count;
          var data = [];
          var col = [];
          for (var key in data1.list) {
            data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });
          }
          col.push({ type: 'checkbox', fixed: 'left' });
          for (var i = 0; i < data.length; i++) {
            if (this.titleData.indexOf(data[i].name) > -1) {
              col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true });
            } else if (data[i].name == '费用项目代码') {
              col.push({
                field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 120, event: '费用项目代码',
                templet: function (d) {
                  return '<span style="color: blue;">' + d.费用项目代码 + '</span>'
                }, style: 'cursor: pointer;'
              });
            } else if (data[i].Type == "Decimal" || data[i].Type == "Int32" || data[i].Type == "Double") {
              col.push({ field: data[i].id, title: data[i].name, align: 'right', sort: true, width: 120 });
            } else if (data[i].Type == "DateTime") {
              col.push({
                field: data[i].id,
                title: data[i].name,
                align: 'center',
                sort: true,
                width: 120,
                formatter: (row, column) => {
                  return row[column.property] ? this.parseTime(row[column.property], '{y}-{m}-{d}') : ''
                }
              });
            } else {
              col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 200 });
            }
          }
          option.cols = [col]
          this.dataList = option
          option.data = data1.data;
          this.DisPlay_HideColumn(this.HModName, sessionStorage["HUserName"], option, this.dataList);
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    DisPlay_HideColumn(HModName, user, option, dataOption) {
      axios.get(this.baseURL + '/Xt_grdAlignment_WMES/grdAlignmentWMESList', {
        params: {
          "HModName": HModName,
          "user": user,
        },
      }).then(res => {
        let data1 = res.data
        if (data1.data.length != 0) {
          var dataCol = [];
          var newCols = [[]];
          newCols[0].push(option.cols[0][0]);
          dataCol = data1.data[0].HGridString.split(',');
          if (dataCol.length == option.cols[0].length - 1) {
            for (var j = 0; j < option.cols[0].length - 1; j++) {
              for (var i = 0; i < option.cols[0].length - 1; i++) {
                var dataCols = dataCol[j].split('|');
                if (option.cols[0][i + 1]["field"] == dataCols[5]) {
                  if (dataCols[1] == 1) {
                    option.cols[0][i + 1]["hide"] = true;
                  }
                  if (dataCols[3] > 0) {
                    option.cols[0][i + 1]["width"] = dataCols[3];
                  }
                  if (data1.data[0].HFontSize != 0) {
                    option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
                  } else {
                    option.cols[0][i + 1]["style"] = "font-size:100%";
                  }
                  if (dataCols[1] == 0 && this.titleData.indexOf(option.cols[0][i + 1]["title"]) == -1) {
                    option.cols[0][i + 1]["hide"] = false;
                  }
                  switch (dataCols[2]) {
                    case "L":
                      option.cols[0][i + 1]["align"] = "left";
                      break;
                    case "M":
                      option.cols[0][i + 1]["align"] = "center";
                      break;
                    case "R":
                      option.cols[0][i + 1]["align"] = "right";
                      break;
                  }
                  if (dataCols[4] != null && dataCols[4] != "") {
                    option.cols[0][i + 1]["title"] = dataCols[4];
                  }
                  if (dataCols[6] == 1) {
                    option.cols[0][i + 1]["totalRow"] = true;
                  } else {
                    option.cols[0][i + 1]["totalRow"] = false;
                  }
                  newCols[0].push(option.cols[0][i + 1]);
                  break;
                }
              }
            }
            if (dataCol.length == newCols[0].length - 1) {
              option.cols = newCols;
              for (var i = 1; i < option.cols[0].length - 1; i++) {
                if (option.cols[0][i + 1]["fixed"] != null) {
                  option.cols[0][i + 1]["fixed"] = null;
                } else {
                  break;
                }
              }
              if (data1.data[0].HFixCols != 0) {
                for (var i = 0; i < data1.data[0].HFixCols; i++) {
                  if (dataOption.cols[0].indexOf(option.cols[0][i + 1]["title"]) != -1) {
                    data1.data[0].HFixCols += 1;
                  }
                  option.cols[0][i + 1]["fixed"] = "left";
                }
              }
              for (var i = 1; i < option.cols[0].length; i++) {
                if (data1.data[0].HSortFlag == "是") {
                  option.cols[0][i]["sort"] = true;
                } else {
                  option.cols[0][i]["sort"] = false;
                }
              }
            }
          }
          this.btList = option.cols[0]
          if (data1.data[0].HPageSize == 0) {
            this.pageSize = 50
          } else {
            this.pageSize = data1.data[0].HPageSize
          }
          this.tableData = option.data
          this.tableShow = true
          this.loading = false
        } else {
          this.btList = dataOption.cols[0]
          this.tableData = dataOption.data
          this.tableShow = true
          this.loading = false
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    handleRowClick(row, column, event) {
      this.lastSelectedRow = this.selectedRow;
      this.selectedRow = row;
      this.lastSelectedRowIndex = this.tableData.indexOf(row);
      this.$refs.tableData.toggleRowSelection(row);
      if (this.openPage) {
        this.$emit('carTypeEmit', row, 1)
      }
    },
    rowStyle({ row, rowIndex }) {
      if (this.ids.includes(row.HItemID)) {
        return { "background": "#ecf5ff" }
      }
    },
    handleDblclick(row, column, cell, event) {
      this.OperationType = 3
      if (this.openPage) {
        this.$emit('carTypeEmitDb', row, 1)
      } else {
        this.handleEdit();
      }
    },
    handleSelectionChange(selection) {
      if (this.openPage) {
        if (selection.length > 1) {
          const del_row = selection.shift()
          this.$refs.tableData.toggleRowSelection(del_row, false)
        }
        this.rowForm = {}
        this.ids = selection.map(item => item.HItemID)
        this.rowForm = selection[0]
      } else {
        this.ids = selection.map(item => item.HItemID)
        this.single = selection.length != 1
        this.multiple = !selection.length
        if (!this.single) {
          this.rowForm = selection[0]
        }
      }
    },
    handleQuery() {
      this.sWhere = ''
      if (this.queryParams.ColName && this.queryParams.Comparator) {
        var com = "";
        switch (this.queryParams.Comparator) {
          case "7":
            com = "like'%" + this.queryParams.ColContent + "%'";
            break;
          case "8":
            com = "like'%" + this.queryParams.ColContent + "'";
            break;
          case "9":
            com = "like'" + this.queryParams.ColContent + "%'";
            break;
          case "10":
            com = "not like'%" + this.queryParams.ColContent + "%'";
            break;
          default:
            com = "" + this.queryParams.Comparator + "'" + this.queryParams.ColContent + "'";
            break;
        }
        this.sWhere += " and " + this.queryParams.ColName + " " + com;
      }
      if (this.queryParams.ColName1 && this.queryParams.Comparator1) {
        var com1 = "";
        switch (this.queryParams.Comparator1) {
          case "7":
            com1 = "like'%" + this.queryParams.ColContent1 + "%'";
            break;
          case "8":
            com1 = "like'%" + this.queryParams.ColContent1 + "'";
            break;
          case "9":
            com1 = "like'" + this.queryParams.ColContent1 + "%'";
            break;
          case "10":
            com1 = "not like'%" + this.queryParams.ColContent1 + "%'";
            break;
          default:
            com1 = "" + this.queryParams.Comparator1 + "'" + this.queryParams.ColContent1 + "'";
            break;
        }
        this.sWhere += " and " + this.queryParams.ColName1 + " " + com1;
      }
      if (this.queryParams.ColName2 && this.queryParams.Comparator2) {
        var com2 = "";
        switch (this.queryParams.Comparator2) {
          case "7":
            com2 = "like'%" + this.queryParams.ColContent2 + "%'";
            break;
          case "8":
            com2 = "like'%" + this.queryParams.ColContent2 + "'";
            break;
          case "9":
            com2 = "like'" + this.queryParams.ColContent2 + "%'";
            break;
          case "10":
            com2 = "not like'%" + this.queryParams.ColContent2 + "%'";
            break;
          default:
            com2 = "" + this.queryParams.Comparator + "'" + this.queryParams.ColContent + "'";
            break;
        }
        this.sWhere += " and " + this.queryParams.ColName2 + " " + com2;
      }
      if (this.queryParams.HNumber) {
        this.sWhere += " and 费用项目代码 like '%" + this.queryParams.HNumber + "%'";
      }
      if (this.queryParams.HName) {
        this.sWhere += " and 费用项目名称 like '%" + this.queryParams.HName + "%'";
      }
      if (this.queryParams.HOrgID) {
        this.sWhere += " and HUSEORGID = '" + this.queryParams.HOrgID + "'"
      }
      this.getList()
    },
        // 修改 resetQuery 方法
    resetQuery() {
      // 保存组织ID
      const currentOrgID = sessionStorage["OrganizationID"] - 0
      // 完全重置所有查询参数
      this.queryParams = {
        HOrgID: currentOrgID,
        HName: '',
        HNumber: '',
        Comparator1: '',
        Comparator2: '',
        Comparator: '',
        ColContent1: '',
        ColContent2: '',
        ColContent: '',
        ColName: '',
        ColName1: '',
        ColName2: ''
      }
      // 清空搜索条件字符串
      this.sWhere = ''
      // 重置折叠面板(收起更多搜索条件)
      this.activeSeach = ''
      // 使用 $nextTick 确保 DOM 更新后再重置表单
      this.$nextTick(() => {
        // 重置表单字段(包括 el-select)
        if (this.$refs.queryForm) {
          this.$refs.queryForm.resetFields()
          // 手动重新设置组织ID,因为 resetFields 会清空所有
          this.$set(this.queryParams, 'HOrgID', currentOrgID)
        }
        // 重置页面为第一页
        this.page = 1
        // 重新获取数据(不传任何过滤条件)
        this.getList()
        // 如果有选中行,清除选中状态
        if (this.$refs.tableData) {
          this.$refs.tableData.clearSelection()
        }
        this.single = true
        this.multiple = true
        this.ids = []
        this.rowForm = {}
      })
      // 滚动到顶部
      this.$nextTick(() => {
        const container = document.querySelector('.el-table__body-wrapper')
        if (container) {
          container.scrollTop = 0
        }
      })
    },
    close() {
      this.tableShow = true
      this.single = true
      this.openEdit = false
      this.editShow = false
      this.getList()
    },
    handleAddEdit() {
      this.rowForm.HItemID = 0
      this.$nextTick(() => {
        this.openEdit = true
        this.editShow = true
      })
    },
    handleEdit() {
      this.$nextTick(() => {
        // 添加 200ms 的延时(可以根据需要调整时间)
        setTimeout(() => {
          this.openEdit = true
          this.editShow = true
        }, 200) // 200毫秒延时,可以调整为 100、300 等值
      })
    },
    editGyClose(val) {
      this.editShow = false
      this.openEdit = false
      this.single = true
      this.multiple = true
      this.getList()
    },
    handleDelete() {
      this.$modal.confirm('确认要删除吗,删除后不能恢复').then(() => {
        if (!this.rowForm.审核人) {
          axios.get(this.baseURL + "DeltetGy_ItemMoney", {
            params: { 'HItemID': this.rowForm.HItemID, 'user': sessionStorage["HUserName"] }
          }).then(response => {
            if (response.data.count == 1) {
              this.getList()
              this.$modal.msgSuccess("删除成功")
            } else {
              this.$modal.msgError("错误:" + result.code + result.Message);
            }
          }).catch(error => {
            this.$modal.msgError("接口请求失败!");
          });
        } else {
          this.$modal.msgError("此条数据不是创建状态,无法删除!");
        }
      }).catch(() => { })
    },
    set_CheckBill(num, form) {
      var InterID = form.HItemID || form.HInterID
      axios.get(this.baseURL + "/Gy_BadReason/AuditGy_ProjectMoney", {
        params: { "HInterID": InterID, "IsAudit": num, "CurUserName": sessionStorage["HUserName"] }
      }).then(response => {
        let result = response.data
        if (result.code == 1) {
          this.$modal.msgSuccess('操作成功');
          this.getList();
        } else {
          this.$modal.msgError("错误:" + result.code + result.Message);
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    set_De_Stop(num, form) {
      var InterID = form.HItemID || form.HInterID
      axios.get(this.baseURL + "/Gy_CarType/StopGy_CarType", {
        params: { "HInterID": InterID, "IsStop": num, "CurUserName": sessionStorage["HUserName"] }
      }).then(response => {
        let result = response.data
        if (result.code == 1) {
          this.$modal.msgSuccess('操作成功');
          this.getList();
        } else {
          this.$modal.msgError("错误:" + result.code + result.Message);
        }
      }).catch(error => {
        this.$modal.msgError("接口请求失败!");
      });
    },
    handleExport() {
      const ws = this.$XLSX.utils.json_to_sheet(this.tyResList);
      const wb = this.$XLSX.utils.book_new();
      this.$XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
      this.$XLSX.writeFile(wb, `gyCarType_${new Date().getTime()}.xlsx`);
    },
    parseTime(time, pattern) {
      if (!time) {
        return ''
      }
      const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
      let date
      if (typeof time === 'object') {
        date = time
      } else {
        if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
          time = parseInt(time)
        }
        if ((typeof time === 'number') && (time.toString().length === 10)) {
          time = time * 1000
        }
        date = new Date(time)
      }
      const formatObj = {
        y: date.getFullYear(),
        m: date.getMonth() + 1,
        d: date.getDate(),
        h: date.getHours(),
        i: date.getMinutes(),
        s: date.getSeconds(),
        a: date.getDay()
      }
      const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
        let value = formatObj[key]
        if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
        if (result.length > 0 && value < 10) {
          value = '0' + value
        }
        return value || 0
      })
      return time_str
    }
  }
};
</script>
<style>
.xsckdBox .el-date-editor.el-input {
  width: 100%;
}
</style>
src/views/basic/gyItemMoney/gyItemMoneyEdit.vue
New file
@@ -0,0 +1,613 @@
<template>
  <div v-loading="formLoading" v-if="formShow">
    <div style="margin-bottom: 10px; border-bottom: 1px solid #f6f6f6">
      <el-button type="primary" @click="submitForm" :disabled="subDisabled"
        >保 存</el-button
      >
      <el-button
        type="primary"
        @click="set_CheckBill(0)"
        :disabled="CheckBillDisabled"
        >审 核</el-button
      >
      <el-button
        type="primary"
        @click="set_CheckBill(1)"
        :disabled="DeCheckBillDisabled"
        >反审核</el-button
      >
      <el-button type="primary" @click="close">退 出</el-button>
    </div>
    <el-form ref="form" :model="form" :rules="rules" label-width="110px">
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane label="基本信息" name="first">
          <el-row>
            <el-col :span="8">
              <el-form-item label="费用项目代码" prop="HNumber">
                <el-input v-model="form.HNumber" placeholder="请输入费用项目代码" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="费用项目名称" prop="HName">
                <el-input v-model="form.HName" placeholder="请输入费用项目名称" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="助记码" prop="HHelpCode">
                <el-input v-model="form.HHelpCode" placeholder="请输入助记码" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="标准单价" prop="HPrice">
                <el-input
                  v-model="form.HPrice"
                  placeholder="0.00"
                  type="text"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="系数比率" prop="HRate">
                <el-input
                  v-model="form.HRate"
                  placeholder="0.00"
                  type="text"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="使用状态" prop="HUseFlag">
                <el-select v-model="form.HUseFlag" placeholder="请选择使用状态">
                  <el-option value="未检测" label="未检测"></el-option>
                  <el-option value="未使用" label="未使用"></el-option>
                  <el-option value="已使用" label="已使用"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="等级" prop="HLevel">
                <el-input
                  v-model="form.HLevel"
                  placeholder="0"
                  type="text"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="末级标志" prop="HEndFlag">
                <el-checkbox v-model="form.HEndFlag" disabled>是否末级</el-checkbox>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用标记" prop="HStopflag">
                <el-checkbox v-model="form.HStopflag" disabled>是否禁用</el-checkbox>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="使用组织" prop="HUSEORGID">
                <el-select
                  v-model="form.HUSEORGID"
                  :disabled="useOrgDisabled"
                  @change="handleOrgChange"
                  placeholder="请选择使用组织"
                >
                  <el-option
                    v-for="item in organizationList"
                    :key="item.ID"
                    :label="item.Name"
                    :value="item.ID"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建组织" prop="HCREATEORGID">
                <el-select
                  v-model="form.HCREATEORGID"
                  :disabled="createOrgDisabled"
                  @change="handleCreateOrgChange"
                  placeholder="请选择创建组织"
                >
                  <el-option
                    v-for="item in organizationList"
                    :key="item.ID"
                    :label="item.Name"
                    :value="item.ID"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="其他信息" name="second">
          <el-row>
            <el-col :span="24">
              <el-form-item label="备注" prop="HRemark">
                <el-input
                  v-model="form.HRemark"
                  type="textarea"
                  placeholder="请输入备注信息"
                  :rows="4"
                  style="width: 80%"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="制单信息" name="third">
          <el-row>
            <el-col :span="8">
              <el-form-item label="创建人" prop="HMakeEmp">
                <el-input v-model="form.HMakeEmp" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="审核人" prop="HCheckEmp">
                <el-input v-model="form.HCheckEmp" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用人" prop="HStopEmp">
                <el-input v-model="form.HStopEmp" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="建立时间" prop="HMakeTime">
                <el-date-picker
                  v-model="form.HMakeTime"
                  type="date"
                  disabled
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="审核时间" prop="HCheckTime">
                <el-date-picker
                  v-model="form.HCheckTime"
                  type="date"
                  disabled
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用时间" prop="HStopTime">
                <el-date-picker
                  v-model="form.HStopTime"
                  type="date"
                  disabled
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item label="修改人" prop="HModifyEmp">
                <el-input v-model="form.HModifyEmp" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="修改时间" prop="HModifyTime">
                <el-date-picker
                  v-model="form.HModifyTime"
                  type="date"
                  disabled
                >
              </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
      <el-input v-model="form.HItemID" type="hidden" />
      <el-input v-model="form.HParentID" type="hidden" />
    </el-form>
  </div>
</template>
<script>
import axios from "axios";
import dayjs from "dayjs";
export default {
  name: "gyCarTypeEdit",
  components: {},
  props: {
    OperationType: { type: Number },
    linterid: { type: Number },
    HSouceBillType: { type: String },
    copyType: { type: Number },
  },
  data() {
    return {
      formShow: false,
      formLoading: true,
      useOrgDisabled: false,
      createOrgDisabled: false,
      organizationList: [],
      currentOrgId: "", // 当前组织ID
      subDisabled: false,
      CheckBillDisabled: true,
      DeCheckBillDisabled: true,
      baseURL: process.env.VUE_APP_BASE_API || "http://47.96.97.237/API/",
      activeName: "first",
      title: "",
      open: false,
      showSearch: true,
      ids: [],
      form: {
        HItemID: 0,
        HParentID: 0,
        HNumber: "",
        HName: "",
        HHelpCode: "",
        HPrice: "",
        HRate: "",
        HHeight: "",
        HMaxVolume: "",
        HUseFlag: "未检测",
        HLevel: "",
        HEndFlag: true,
        HStopflag: false,
        HShortNumber: "",
        HUSEORGID: "", // 初始化为空
        HCREATEORGID: "", // 初始化为空
        HRemark: "",
        HMakeEmp: "",
        HMakeTime: null,
        HCheckEmp: null,
        HCheckTime: null,
        HStopEmp: null,
        HStopTime: null,
        HModifyEmp: null,
        HModifyTime: null,
      },
      rules: {
        HNumber: [
          { required: true, message: "费用项目代码不能为空", trigger: "blur" },
        ],
        HName: [
          { required: true, message: "费用项目名称不能为空", trigger: "blur" },
        ],
        HPrice: [
          {
            pattern: /^\d+(\.\d+)?$/,
            message: "必须为数字",
            trigger: "blur",
          },
        ],
        HRate: [
          {
            pattern: /^\d+(\.\d+)?$/,
            message: "必须为数字",
            trigger: "blur",
          },
        ],
        HLevel: [
          {
            pattern: /^\d+$/,
            message: "等级必须为数字",
            trigger: "blur",
          },
        ],
      },
    };
  },
  created() {
    this.initCurrentOrgId();
  },
  activated() {
    this.initCurrentOrgId();
  },
  methods: {
    // 初始化当前组织ID - 与列表页保持一致
    async initCurrentOrgId() {
      try {
        // 从sessionStorage获取当前组织ID,与列表页保持一致
        this.currentOrgId = sessionStorage.getItem('currentOrgId') ||
                           (sessionStorage["OrganizationID"] - 0) ||
                           "";
        // 从sessionStorage获取组织列表,与列表页保持一致
        const savedOrgList = sessionStorage.getItem('organizationList');
        if (savedOrgList) {
          this.organizationList = JSON.parse(savedOrgList);
        }
        // 如果组织列表为空,则从接口获取(备用方案)
        if (!this.organizationList || this.organizationList.length === 0) {
          const response = await axios.get(this.baseURL + "/Web/GetOrganizations", {});
          if (response.data.count == 1) {
            this.organizationList = response.data.data;
          }
        }
        this.getdata();
      } catch (error) {
        console.error("初始化组织数据失败:", error);
        this.$modal.msgError("获取组织数据失败!");
        this.formLoading = false;
      }
    },
    // 获取表单数据
    getdata() {
      // 先调用reset设置默认值
      this.reset();
      if (this.OperationType == 1) {
        // 新增 - 与列表页保持一致
        this.useOrgDisabled = false;
        this.createOrgDisabled = false;
        // 设置创建时间和创建人
        let date = new Date();
        this.form.HMakeTime = dayjs(date).format("YYYY-MM-DD");
        this.form.HMakeEmp = sessionStorage["HUserName"] || "";
        // 关键修改:与列表页保持一致
        // 使用组织:初始为空,用户需要选择
        // 创建组织:默认为当前组织,用户可以修改
        this.form.HCREATEORGID = this.currentOrgId;
        this.form.HUSEORGID = this.currentOrgId; // 使用组织留空,让用户选择
        this.$nextTick(() => {
          this.formShow = true;
          this.formLoading = false;
        });
      } else if (this.OperationType == 3 || this.OperationType == 4) {
        // 编辑或浏览
        this.useOrgDisabled = true;
        this.createOrgDisabled = true;
        if (this.OperationType == 4) {
          // 浏览
          this.subDisabled = true;
          this.CheckBillDisabled = true;
          this.DeCheckBillDisabled = true;
        }
        axios
          .get(this.baseURL + "Web/GetGy_ItemMoneyDetail", {
            params: {
              HID: this.linterid,
            },
          })
          .then((response) => {
            console.log(response);
            let result = response.data.data.h_v_Gy_ItemMoney_1[0];;
              var data = result;
              this.form = {
                HItemID: data.HItemID,
                HParentID: data.父级ID,
                HNumber: data.费用项目代码,
                HName: data.费用项目名称,
                HHelpCode: data.助记码,
                HPrice: data.标准单价,
                HRate: data.系数比率,
                HUseFlag: data.HUseFlag,
                HLevel: data.等级,
                HEndFlag: data.末级标志,
                HStopflag: data.HStopflag,
                HUSEORGID: data.HUSEORGID,
                HCREATEORGID: data.HCREATEORGID,
                HRemark: data.备注,
                HMakeEmp: data.创建人,
                HMakeTime: data.创建时间
                  ? dayjs(new Date(data.创建时间)).format("YYYY-MM-DD")
                  : "",
                HCheckEmp: data.审核人,
                HCheckTime: data.审核时间
                  ? dayjs(new Date(data.审核时间)).format("YYYY-MM-DD")
                  : "",
                HStopEmp: data.HStopEmp,
                HStopTime: data.HStopTime
                  ? dayjs(new Date(data.HStopTime)).format("YYYY-MM-DD")
                  : "",
                HModifyEmp: data.HModifyEmp,
                HModifyTime: data.HModifyTime
                  ? dayjs(new Date(data.HModifyTime)).format("YYYY-MM-DD")
                  : "",
              };
              if (this.OperationType == 3) {
                if (!data.HCheckEmp) {
                  this.CheckBillDisabled = false;
                } else {
                  this.DeCheckBillDisabled = false;
                }
              }
            this.$nextTick(() => {
              this.formShow = true;
              this.formLoading = false;
            });
          })
          .catch((error) => {
            this.$modal.msgError("获取数据失败!");
            this.formLoading = false;
          });
      }
    },
    // 重置表单 - 修改默认值设置
    reset() {
      this.form = {
        HItemID: 0,
        HParentID: 0,
        HNumber: "",
        HName: "",
        HHelpCode: "",
        HPrice: "",
        HRate: "",
        HUseFlag: "未检测",
        HLevel: "",
        HEndFlag: true,
        HStopflag: false,
        HUSEORGID: "", // 使用组织:初始为空,用户需要选择
        HCREATEORGID: this.currentOrgId, // 创建组织:默认为当前组织
        HRemark: "",
        HMakeEmp: sessionStorage["HUserName"] || "",
        HMakeTime: null,
        HCheckEmp: null,
        HCheckTime: null,
        HStopEmp: null,
        HStopTime: null,
        HModifyEmp: null,
        HModifyTime: null,
      };
      this.ids = [];
      this.formShow = false;
      this.subDisabled = false;
      this.formLoading = true;
      this.CheckBillDisabled = true;
      this.DeCheckBillDisabled = true;
      this.activeName = "first";
      if (this.$refs.form) {
        this.$refs.form.resetFields();
      }
    },
    // 组织选择变化
    handleOrgChange(value) {
      this.form.HUSEORGID = value;
    },
    // 创建组织选择变化
    handleCreateOrgChange(value) {
      this.form.HCREATEORGID = value;
    },
    // 关闭表单
    close() {
      this.reset();
      this.formShow = false;
      this.$emit("editCloseGy", 0);
    },
    // 提交表单
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          // 必填字段验证
          if (!this.form.HNumber) {
            this.$modal.msgError("费用项目代码不能为空!");
            return;
          }
          if (!this.form.HName) {
            this.$modal.msgError("费用项目名称不能为空!");
            return;
          }
          // 使用组织必填验证 - 与列表页保持一致
          if (!this.form.HUSEORGID) {
            this.$modal.msgError("使用组织不能为空!");
            return;
          }
          if (!this.form.HCREATEORGID) {
            this.$modal.msgError("创建组织不能为空!");
            return;
          }
          // 数字字段验证
          if (this.form.HPrice && isNaN(this.form.HPrice)) {
            this.$modal.msgError("必须为数字!");
            return;
          }
          if (this.form.HLevel && isNaN(this.form.HLevel)) {
            this.$modal.msgError("等级必须为数字!");
            return;
          }
          var sMainStr = JSON.stringify(this.form);
          var oMain = sMainStr + ";" + sessionStorage["HUserName"];
          axios({
            method: "post",
            url: this.baseURL + "/SaveGy_ItemMoney",
            data: { msg: oMain },
          })
            .then((response) => {
              if (response.data.count == 1) {
                this.subDisabled = true;
                this.CheckBillDisabled = false;
                this.$modal.msgSuccess("保存成功!");
              } else {
                this.$modal.msgError(response.data.Message);
                //this.$modal.msgError("6666");
              }
            })
            .catch((error) => {
              this.$modal.msgError("保存失败!");
            });
        }
      });
    },
    // 审核/反审核
    set_CheckBill(num) {
      var HItemID = this.form.HItemID;
      if (!HItemID || HItemID == "0") {
        this.$modal.msgError("请先保存数据再进行审核操作!");
        return;
      }
      axios
        .get(this.baseURL + "/Gy_BadReason/AuditGy_ItemMoney", {
          params: {
            HInterID: HItemID,
            IsAudit: num,
            CurUserName: sessionStorage["HUserName"],
          },
        })
        .then((response) => {
          let result = response.data;
          if (result.code == 1) {
            this.$modal.msgSuccess(result.Message);
            if (num == 0) {
              this.CheckBillDisabled = true;
              this.DeCheckBillDisabled = false;
            } else {
              this.CheckBillDisabled = false;
              this.DeCheckBillDisabled = true;
            }
          } else {
            this.$modal.msgError(result.Message);
          }
        })
        .catch((error) => {
          this.$modal.msgError("审核操作失败!");
        });
    },
  },
};
</script>
<style>
.xsckdBox .el-date-editor.el-input {
  width: 100%;
}
.form-inline > .el-form-item__content {
  display: flex;
  flex-direction: row;
}
</style>