From fd78adcc4e60321cdcfad0f136476c009c37c5aa Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 09 四月 2024 18:05:04 +0800
Subject: [PATCH] 产品登记表的样式调整
---
src/views/systemSetting/silkStandardSetting/index.vue | 194 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 189 insertions(+), 5 deletions(-)
diff --git a/src/views/systemSetting/silkStandardSetting/index.vue b/src/views/systemSetting/silkStandardSetting/index.vue
index 43fb89c..ea8f6f5 100644
--- a/src/views/systemSetting/silkStandardSetting/index.vue
+++ b/src/views/systemSetting/silkStandardSetting/index.vue
@@ -5,7 +5,7 @@
<template slot="leftButton">
<el-button size="small" type="primary" @click="addBtnClick">鏂板</el-button>
<el-button size="small" type="primary" @click="refreshClick">鍒锋柊</el-button>
- <el-button size="small" type="primary" @click="printClick">鎵撳嵃</el-button>
+ <el-button size="small" type="primary" @click="printClick" disabled>鎵撳嵃</el-button>
</template>
</CommonSearch>
</div>
@@ -24,6 +24,9 @@
@addProjectClick="addBtnClick"
@clearupProject="clearupProject"
@deleteClick="clearupProject"
+ @addColumnClick="addColumnClick"
+ @clearupColumn="clearupColumn"
+ @addColumnInputChange="addColumnInputChange"
>
</SilkTableList>
</div>
@@ -33,6 +36,8 @@
<script>
import SilkTableList from "@/views/systemSetting/silkStandardSetting/components/silkTableList"
+import { getRankStandard, saveRankStandard } from "@/api/systemSetting/silkStandardSetting"
+import { getDataByType } from "@/api/data"
export default {
name: "silkStandardSetting",
props: {},
@@ -43,13 +48,91 @@
return {
isEdit: false,
silkTableList: {},
- tableData: []
+ tableData: [],
+ defaultColumn: [
+ {
+ label: "妫�鏌ラ」鐩悕绉�",
+ prop: "checkItem",
+ projectName: true,
+ isCallMethod: true,
+ getCallMethod: this.getCheckItemName
+ },
+ { label: "寮�濮嬬氦搴�", prop: "startFineness", inputFloat: true },
+ { label: "缁撴潫绾ゅ害", prop: "endFineness", inputFloat: true },
+ { label: "閲庣氦", prop: "rankA", inputFloat: true },
+ { label: "澶ч噹", prop: "rankB", inputFloat: true },
+ { label: "鐗归噹", prop: "rankC", inputFloat: true }
+ ],
+ tableColumn: [],
+ columnNum: 0,
+ dataObj: {
+ checkItem: 1,
+ startFineness: 0,
+ endFineness: 0,
+ rankA: 0,
+ rankB: 0,
+ rankC: 0
+ },
+ projectOptions: getDataByType("projectOptions"),
+ rankObj: {},
+ columnInputList: [],
+ dynamicsRanks: [],
}
},
created() {
this.setTableForm()
+ this.getData()
},
methods: {
+ // 鑾峰彇鏁版嵁
+ getData() {
+ getRankStandard().then((res) => {
+ console.log(res)
+ if (res.code === 200) {
+ if (res.data.length > 0) {
+ this.tableData = []
+ this.tableColumn = this.defaultColumn
+ this.columnDataProcess(res.data[0].dynamicsRanks)
+ this.rankObj = {}
+ this.allDataProcess(res.data)
+ }
+ }
+ })
+ },
+ // 鏁翠綋鏁版嵁澶勭悊
+ allDataProcess(dataList) {
+ let rankList = dataList.map((ite) => {
+ for (let i = 0; i < ite.dynamicsRanks.length; i++) {
+ this.$set(this.rankObj, ite.dynamicsRanks[i].rankProp, ite.dynamicsRanks[i].rankValue)
+ this.$set(this.dataObj, ite.dynamicsRanks[i].rankProp, 0)
+ }
+ return {
+ ...ite,
+ ...this.rankObj
+ }
+ })
+ this.tableData = rankList || []
+ this.silkTableList.tableData = this.tableData
+ },
+ // 鍒椾俊鎭暟鎹鐞�
+ columnDataProcess(data) {
+ this.columnInputList = data.map((ite) => {
+ return { ...ite }
+ })
+ let list = data.map((item) => {
+ return {
+ label: item.rankName,
+ prop: item.rankProp,
+ inputFloat: true
+ }
+ })
+ this.columnNum = list.length + 1
+ for (let j = 0; j < list.length; j++) {
+ this.tableColumn.splice(2, 0, list[j])
+ }
+ console.log(this.tableColumn)
+ this.silkTableList.tableColumn = this.tableColumn
+ },
setTableForm() {
this.silkTableList = {
tableData: this.tableData,
@@ -80,12 +163,33 @@
})
},
// 鍒锋柊
- refreshClick() {},
+ refreshClick() {
+ this.getData()
+ },
// 鎵撳嵃
printClick() {},
// 鍒楄〃杈撳叆鍥炶皟
- inputContent(val, prop, row) {
- console.log(val, prop, row)
+ inputContent(val, prop, scope) {
+ console.log(val, prop, scope)
+ let list = this.tableData.map((item, index) => {
+ let dynamicsRanks = this.columnInputList.map((ite) => {
+ if (ite.rankProp == prop) {
+ ite.rankValue = val
+ }
+ return {
+ ...ite
+ }
+ })
+ if (index === scope.$index) {
+ item[prop] = val
+ item.dynamicsRanks = dynamicsRanks
+ }
+ return {
+ ...item
+ }
+ })
+ console.log(list)
+ this.tableData = list
},
// 鍒犻櫎
clearupProject(data, index) {
@@ -95,6 +199,86 @@
// 淇濆瓨缂栬緫鎸夐挳鍒囨崲
editSaveClick() {
this.isEdit = !this.isEdit
+ if (!this.isEdit) {
+ let params = this.saveParam()
+ saveRankStandard({
+ rankStandard: params
+ }).then((res) => {
+ console.log(res)
+ if (res.code == 200) {
+ this.$message.success("淇濆瓨鎴愬姛")
+ this.getData()
+ }
+ })
+ }
+ },
+ saveParam() {
+ let saveList = this.tableData.map((item) => {
+ return {
+ checkItem: item.checkItem,
+ dynamicsRanks: item.dynamicsRanks,
+ endFineness: item.endFineness,
+ lineId: item.lineId || "",
+ rankA: item.rankA,
+ rankB: item.rankB,
+ rankC: item.rankC,
+ startFineness: item.startFineness
+ }
+ })
+ return saveList
+ },
+ // 娣诲姞鍒�
+ addColumnClick() {
+ let propStr = "prop" + this.columnNum
+ this.tableColumn.splice(2, 0, { label: "", prop: propStr, inputFloat: true, addColumn: true })
+ this.$set(this.dataObj, propStr, 0)
+ this.$set(this.rankObj, propStr, 0)
+ console.log(this.columnInputList)
+ this.columnInputList.push({ rankProp: propStr, rankName: "", rankValue: 0 })
+ console.log(this.tableColumn, this.dataObj, "32323", this.columnInputList)
+ this.silkTableList.tableColumn = this.tableColumn
+ this.columnNum += 1
+ let allList = this.tableData.map((item) => {
+ return {
+ ...item,
+ [propStr]: 0
+ }
+ })
+ this.tableData = allList
+ this.silkTableList.tableData = allList
+ },
+ // 鍒犻櫎鍒�
+ clearupColumn(prop) {
+ let currentIndex = 0
+ this.tableColumn.map((item, index) => {
+ if (item.prop == prop) {
+ currentIndex = index
+ }
+ })
+ this.tableColumn.splice(currentIndex, 1)
+ this.silkTableList.tableColumn = this.tableColumn
+ this.$delete(this.dataObj, prop)
+ },
+ // 鍒楄〃澶磋緭鍏ュ洖璋�
+ addColumnInputChange(val, prop) {
+ console.log(val, prop, this.columnInputList)
+ this.columnInputList.forEach((item) => {
+ if (item.rankProp == prop) {
+ item.rankName = val
+ }
+ })
+ console.log(this.columnInputList, "888")
+ },
+ getCheckItemName(val) {
+ if (val) {
+ for (let i in this.projectOptions) {
+ if (this.projectOptions[i].id == val) {
+ return this.projectOptions[i].value
+ }
+ }
+ } else {
+ return "--"
+ }
}
}
}
--
Gitblit v1.8.0