From 74cb17043657b943336541df2b8fc048d7f7b71f Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期四, 20 三月 2025 09:21:14 +0800
Subject: [PATCH] Merge branch 'dev'
---
src/api/codingRuler/codingRuler.js | 68 ++++++
src/views/codingRuler/index.vue | 490 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 558 insertions(+), 0 deletions(-)
diff --git a/src/api/codingRuler/codingRuler.js b/src/api/codingRuler/codingRuler.js
new file mode 100644
index 0000000..1833bfe
--- /dev/null
+++ b/src/api/codingRuler/codingRuler.js
@@ -0,0 +1,68 @@
+import request from '@/utils/request'
+
+// 鑾峰彇鍒嗛〉
+export const getCodingRulers = (params) => {
+ return request({
+ url: "/coding-ruler/page",
+ method: "GET",
+ params: params
+ })
+}
+
+// 鑾峰彇鍒楄〃
+export const getCodingRulerList = () => {
+ return request({
+ url: "/coding-ruler/list",
+ method: "GET"
+ })
+}
+
+// 閫氳繃id鑾峰彇
+export const getCodingRulerById = (params) => {
+ return request({
+ url: "/coding-ruler/" + params,
+ method: "GET"
+ })
+}
+
+// 閫氳繃id鍒犻櫎
+export const deleteCodingRulerById = (params) => {
+ return request({
+ url: "/coding-ruler/" + params,
+ method: "DELETE"
+ })
+}
+
+// 鎵归噺鍒犻櫎
+export const deleteCodingRulerByIds = (params) => {
+ return request({
+ url: "/coding-ruler/batch",
+ method: "DELETE",
+ data: params
+ })
+}
+
+// 淇敼
+export const editCodingRuler = (params) => {
+ return request({
+ url: "/coding-ruler/",
+ method: "PUT",
+ data: params
+ })
+}
+
+// 娣诲姞
+export const addCodingRuler = (params) => {
+ return request({
+ url: "/coding-ruler/",
+ method: "POST",
+ data: params
+ })
+}
+// 閫氳繃id淇敼鍚姩鐘舵��
+export const changeCodingRulerStatus = (params) =>{
+ return request({
+ url:'/coding-ruler/change/' + params,
+ method: "GET",
+ })
+}
diff --git a/src/views/codingRuler/index.vue b/src/views/codingRuler/index.vue
new file mode 100644
index 0000000..0545c55
--- /dev/null
+++ b/src/views/codingRuler/index.vue
@@ -0,0 +1,490 @@
+<template>
+ <div class="app-container">
+ <div class="slot">
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="75px">
+ <el-form-item label="椤圭洰鐮佺被鍨�" prop="projectCodeType">
+ <el-select v-model="queryParams.projectCodeType" placeholder="椤圭洰鐮佺被鍨�" @change="handleQuery">
+ <el-option
+ v-for="dict in dict.type.coding_type"
+ :key="dict.value"
+ :value="dict.value"
+ :label="dict.label"
+ >
+ </el-option>
+ </el-select>
+
+ </el-form-item>
+ <el-form-item label="鍖洪棿绫诲瀷" prop="intervalType">
+ <el-select v-model="queryParams.intervalType" placeholder="鍖洪棿绫诲瀷" @change="handleQuery">
+ <el-option
+ v-for="dict in dict.type.interval_type"
+ :key="dict.value"
+ :value="dict.value"
+ :label="dict.label"
+ >
+ </el-option>
+ </el-select>
+ </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>
+ <div class="right-section">
+ <div class="add-btn">
+ <el-tooltip content="鏂板" effect="dark" placement="top">
+ <el-button :disabled="!isReserve" circle icon="el-icon-plus" @click="add()" size="small"/>
+ </el-tooltip>
+ </div>
+ </div>
+ </div>
+
+
+ <el-table
+ :data="tableData"
+ row-key="id"
+ border
+ @selection-change="handleSelectionChange">
+ <el-table-column
+ type="selection"
+ width="55">
+ </el-table-column>
+ <el-table-column
+
+ prop="projectCodeType"
+ label="椤圭洰鐮佺被鍨�"
+ >
+ <template slot-scope="scope">
+ <dict-tag :options="dict.type.coding_type" :value="scope.row.projectCodeType"/>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="intervalType"
+ label="鍖洪棿绫诲瀷"
+ >
+ <template slot-scope="scope">
+ <dict-tag :options="dict.type.interval_type" :value="scope.row.intervalType"/>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="leftSymbol"
+ label="宸︾鍙�"
+ >
+ <template slot-scope="scope">
+ <dict-tag :options="dict.type.sys_coding_operator" :value="scope.row.leftSymbol"/>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="leftValue"
+ label="宸﹀��"
+ >
+ </el-table-column>
+ <el-table-column
+ prop="rightSymbol"
+ label="鍙崇鍙�"
+ >
+ <template slot-scope="scope">
+ <dict-tag :options="dict.type.sys_coding_operator" :value="scope.row.rightSymbol"/>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="rightValue"
+ label="鍙冲��"
+ >
+ </el-table-column>
+ <el-table-column
+ prop="status"
+ label="鐘舵��"
+ >
+ <template slot-scope="scope">
+ <el-tag :type="scope.row.status === 0 ? 'info' : 'success'">
+ {{scope.row.status === 0 ? "鏈惎鐢�" : "鍚敤"}}
+ </el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="鎿嶄綔" min-width="100">
+ <template slot-scope="scope">
+ <el-button v-if="editShow" size="medium" type="text" icon="el-icon-open" @click="changeStatus(scope.row)">
+ {{scope.row.status === 0 ? "鍚姩" : "鍏抽棴"}}
+ </el-button>
+
+ <el-button v-if="editShow" size="medium" type="text" icon="el-icon-edit" @click="editCodingRuler(scope.row)"
+ :disabled="scope.row.status === 1"
+ >缂栬緫</el-button>
+
+ <el-button v-if="delShow" size="medium"
+ type="text"
+ icon="el-icon-delete" @click="deleteCodingRuler(scope.row)"
+ :disabled="scope.row.status === 1"
+ >鍒犻櫎</el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+
+ <pagination
+ v-show="total>0"
+ :total="total"
+ :page.sync="queryParams.currentPage"
+ :limit.sync="queryParams.pageSize"
+ @pagination="getList"
+ />
+
+ <el-dialog width="45%" :title="dialogTitle" @close="closeDialog" :visible.sync="open" :show-close="true" :close-on-click-modal="true" :destroy-on-close="true">
+ <el-form :model="codingRulerForm" :rules="rules" ref="codingRulerForm">
+ <el-form-item label="椤圭洰鐮佺被鍨�" :label-width="formLabelWidth" prop="projectCodeType">
+ <el-select v-model="codingRulerForm.projectCodeType" placeholder="椤圭洰鐮佺被鍨�" @change="changeOption($event)">
+ <el-option
+ v-for="dict in dict.type.coding_type"
+ :key="dict.value"
+ :value="dict.value"
+ :label="dict.label"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍖洪棿绫诲瀷" :label-width="formLabelWidth" prop="intervalType">
+ <el-select v-model="codingRulerForm.intervalType" placeholder="鍖洪棿绫诲瀷" @change="changeOption($event)">
+ <el-option
+ v-for="dict in dict.type.interval_type"
+ :key="dict.value"
+ :value="dict.value"
+ :label="dict.label"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="宸︾鍙�" :label-width="formLabelWidth" prop="leftSymbol" >
+ <el-select v-model="codingRulerForm.leftSymbol" placeholder="閫夋嫨绗﹀彿" @change="changeOption($event)">
+ <el-option
+ v-for="dict in leftOption"
+ :key="dict.value"
+ :value="dict.value"
+ :label="dict.label.replace('澶т簬', '>')
+ .replace('灏忎簬', '<')
+ .replace('澶х瓑浜�', '>=')
+ .replace('绛変簬', '=')
+ .replace('灏忎簬绛変簬', '<=')"
+ >
+ </el-option>
+ </el-select>
+
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="宸﹀��" :label-width="formLabelWidth" prop="leftValue">
+ <el-input v-model="codingRulerForm.leftValue" autocomplete="off" type="number" :min="0"></el-input>
+ </el-form-item>
+ </el-col>
+ </el-row>
+ </el-form>
+ <el-form :model="singleForm" :rules="rules2" ref="singleForm" v-show="isSingleInterval">
+ <el-row>
+ <el-col :span="12">
+ <el-form-item label="鍙崇鍙�" :label-width="formLabelWidth" prop="rightSymbol" >
+ <el-select v-model="singleForm.rightSymbol" placeholder="閫夋嫨绗﹀彿" @change="changeOption($event)">
+ <el-option
+ v-for="dict in rightOption"
+ :key="dict.value"
+ :value="dict.value"
+ :label="dict.label.replace('澶т簬', '>')
+ .replace('灏忎簬', '<')
+ .replace('澶х瓑浜�', '>=')
+ .replace('绛変簬', '=')
+ .replace('灏忎簬绛変簬', '<=')"
+ >
+ </el-option>
+ </el-select>
+ </el-form-item>
+ </el-col>
+ <el-col :span="12">
+ <el-form-item label="鍙冲��" :label-width="formLabelWidth" prop="rightValue">
+ <el-input v-model="singleForm.rightValue" autocomplete="off" type="number" :min="0"></el-input>
+ </el-form-item>
+ </el-col>
+ </el-row>
+
+ </el-form>
+
+ <div slot="footer" class="dialog-footer">
+ <el-button @click="closeDialog">鍙� 娑�</el-button>
+ <el-button type="primary" @click="addOrEditCodingRuler">纭� 瀹�</el-button>
+ </div>
+ </el-dialog>
+
+
+ </div>
+</template>
+
+<script>
+import {
+ addCodingRuler,
+ changeCodingRulerStatus,
+ deleteCodingRulerById,
+ editCodingRuler,
+ getCodingRulers
+} from '@/api/codingRuler/codingRuler.js'
+
+export default {
+ dicts: ['sys_coding_operator','coding_type','interval_type'],
+ name: "CodingRulerDialog",
+ data() {
+ return {
+ rules2:{
+ rightSymbol:[{ required: true, message: '璇疯緭鍏ュ彸绗﹀彿', trigger: 'blur' }],
+ rightValue:[{ required: true, message: '璇疯緭鍏ュ彸鍊�', trigger: 'blur' }],
+ },
+ rules:{
+ projectCodeType: [{ required: true, message: '璇疯緭鍏ラ」鐩爜绫诲瀷', trigger: 'blur' }],
+ intervalType: [{ required: true, message: '璇疯緭鍏ュ尯闂寸被鍨�', trigger: 'blur' }],
+ leftSymbol: [{ required: true, message: '璇疯緭鍏ュ乏绗﹀彿', trigger: 'blur' }],
+ leftValue: [{ required: true, message: '璇疯緭鍏ュ乏鍊�', trigger: 'blur' }],
+ },
+ // 鏄惁涓哄崟鍖洪棿
+ isSingleInterval:false,
+ // 寮瑰嚭妗嗘爣棰�
+ dialogTitle:"",
+ //鏄惁鏂板鏉′欢
+ isReserve: true,
+ // 鑳藉惁淇敼鏉′欢
+ editShow:true,
+ // 鑳藉惁鍒犻櫎鏉′欢
+ delShow:true,
+ // 鎬绘潯鏁�
+ total:0,
+ // 琛ㄦ牸鍐呭
+ tableData:[],
+ // 鏄惁寮�鍚悳绱㈡潯浠�
+ showSearch:true,
+ queryParams:{
+ intervalType:'',
+ currentPage: 1,
+ pageSize: 10,
+ projectCodeType:'',
+ },
+ formLabelWidth: '120px',
+ // 琛ㄥ崟鍙傛暟
+ codingRulerForm:{
+ projectCodeType:'',
+ intervalType:'',
+ leftSymbol:'',
+ leftValue:'',
+
+ },
+ singleForm:{
+ rightSymbol:'',
+ rightValue:'',
+ },
+ // 鏄惁鏄剧ず寮瑰嚭灞�
+ open: false,
+ // 閫変腑鏁扮粍
+ ids: [],
+ // //宸︾鍙�
+ // leftOption:[],
+ // //鍙崇鍙�
+ // rightOption:[],
+ }
+ },
+ computed:{
+ leftOption(){
+ if (this.codingRulerForm.intervalType === null || this.codingRulerForm.intervalType === ''){
+ return this.dict.type.sys_coding_operator
+ }else {
+ if (this.codingRulerForm.intervalType === 'interval'){
+ return this.dict.type.sys_coding_operator.filter(item => item.value <= 2);
+ }else {
+ return this.dict.type.sys_coding_operator;
+
+ }
+ }
+ },
+ rightOption(){
+ return this.dict.type.sys_coding_operator.filter(item => item.value >= 2);
+ }
+ },
+ created(){
+
+ },
+ mounted() {
+ // 鍒濆鍖栬〃鍗曟暟鎹�
+ this.getList();
+ },
+ watch:{
+ 'codingRulerForm.intervalType'(val){
+ if (val && val === 'single_interval'){
+ this.isSingleInterval = false;
+ }else if (val === 'interval'){
+ this.isSingleInterval =true;
+ }else {
+ this.isSingleInterval =false;
+ }
+
+ }
+
+ },
+ methods: {
+ // 娓呴櫎楠岃瘉鏍峰紡浠ュ強鍗曞尯闂村彸绗﹀彿鐨勫��
+ changeOption(e){
+ if (e === 'single_interval'){
+ this.singleForm.rightValue = null;
+ this.singleForm.rightSymbol = null;
+ }
+ },
+ // 鑾峰彇琛ㄦ牸鏁版嵁
+ getList(){
+ getCodingRulers(this.queryParams).then(res =>{
+ this.tableData = res.data;
+ this.total = res.total;
+ })
+
+ },
+ // 淇敼
+ editCodingRuler(row){
+ this.open = true;
+ this.dialogTitle = "缂栬緫";
+ // 琛ㄥ崟璧嬪��
+ // 鎷疯礉
+ this.codingRulerForm = {...row};
+ this.singleForm = {...row};
+ },
+ // 鍒犻櫎
+ deleteCodingRuler(row){
+ this.$modal.confirm('鏄惁鍒犻櫎閫変腑缂栫爜瑙勫垯?').then(function(){
+ return deleteCodingRulerById(row.id);
+ }).then(() =>{
+ this.getList();
+ this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+ }).catch(() => {});
+ },
+ // 鏂板
+ add(){
+ this.open = true;
+ this.dialogTitle = "鏂板";
+ },
+ // 鍙栨秷
+ closeDialog() {
+ this.open = false;
+ this.clearForm();
+ },
+ // 娓呯┖琛ㄥ崟
+ clearForm() {
+ this.codingRulerForm = {
+ id :null,
+ projectCodeType:null,
+ intervalType:null,
+ leftSymbol:null,
+ leftValue:null,
+ }
+ this.singleForm ={
+ rightSymbol:null,
+ rightValue:null,
+ }
+ this.resetForm("codingRulerForm");
+ this.resetForm("singleForm");
+ this.isSingleInterval = false;
+ },
+
+ handleSelectionChange(val) {
+ this.ids = val.map(item => item.id)
+ console.log(ids)
+ },
+ // 鎼滅储鎸夐挳鎿嶄綔
+ handleQuery() {
+ this.queryParams.pageNum = 1;
+ this.getList();
+ },
+ // 閲嶇疆鎼滅储
+ resetQuery(){
+ this.resetForm("queryForm");
+ this.handleQuery();
+ },
+ // 鐘舵�佸垏鎹�
+ changeStatus(row){
+ changeCodingRulerStatus(row.id).then(res =>{
+ this.getList();
+ this.$message.info(res.msg)
+ })
+ },
+ async addOrEditCodingRuler() {
+
+ // 榛樿
+ let intervalState = false;
+
+ if(this.codingRulerForm.intervalType && this.codingRulerForm.intervalType === "interval"){
+ // 鍖洪棿鎯呭喌
+ intervalState = true;
+ }else {
+ intervalState = false;
+ }
+ if (intervalState){
+ let need1 = false;
+ let need2 = false;
+ let warning = false;
+ await this.$refs["singleForm"].validate((valid) =>{
+ if (valid){
+ need1 = true;
+ }
+ })
+ await this.$refs["codingRulerForm"].validate((valid) => {
+ if (valid) {
+ need2 = true;
+ if(this.codingRulerForm.leftValue >= this.singleForm.rightValue){
+ warning = true;
+ }
+ }
+ });
+ if (warning){
+ this.$message.warning("鍙冲�煎簲璇ュぇ浜庡乏鍊�")
+ return
+ }
+ if (need1 && need2){
+ this.addOrEdit();
+ }
+ }else {
+ this.$refs["codingRulerForm"].validate((valid) => {
+ if (valid) {
+ this.addOrEdit();
+ }
+ });
+ }
+ },
+ async addOrEdit(){
+ const form = this.codingRulerForm;
+ form.rightSymbol = this.singleForm.rightSymbol;
+ form.rightValue = this.singleForm.rightValue;
+ if (this.dialogTitle === "鏂板") {
+ await addCodingRuler(form).then((res) => {
+ this.$message.success(res.msg);
+ this.open = false;
+ this.getList();
+ })
+ } else if (this.dialogTitle === "缂栬緫" && this.codingRulerForm.id){
+ await editCodingRuler(form).then((res) => {
+ this.$message.success(res.msg);
+ this.open = false;
+ this.getList()
+ })
+ }
+ this.isSingleInterval = false;
+ }
+
+
+ }
+}
+</script>
+
+<style scoped>
+.right-section {
+ display: flex;
+
+
+ .add-btn {
+ margin: 0 10px;
+ }
+}
+.slot {
+ display: flex;
+}
+</style>
--
Gitblit v1.8.0