Files
ZERO_CODE/ZeroCodeProject/project_template/stand_table/stand_table.js
vermouth789 fe39320977 123
123
2026-01-11 00:11:34 +08:00

378 lines
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import axios from "axios";
let axios_config = require("./config")
const components = {}
const props = ["tabs", "activetab"]
const data = function () {
return {
tableData: [
{
name: "ni",
pwd: "233"
}
],
column: [
{
label: "名称",
field_name: "name",
type: "input"
},
{
label: "密码",
field_name: "pwd",
type: "select"
}
],
search: {}, //搜索输入内容存储
dialogTableVisible1: false, //显示新增弹窗控制变量
dialogform: {
uuid: "sss"
},
component_name: "index",
form: {
name: "xbc"
},
all_selections: [],
activeName: "1",
filtername: "",
now_selection_record: "",
selections: [],
ids: [],
// 总条数,根据接口获取数据长度(注意:这里不能为空)
totalCount: 1,
// 个数选择器(可修改)
pageSizes: [8, 16],
// 默认每页显示的条数(可修改)
PageSize: 8,
currentPage: 1,
}
}
function mounted() {
const { url, method, data: originalData, then } = axios_config.mounted.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
}
const methods = {
fresh_data(val) {
if (val) {
this.tableData = val
this.totalCount = val.length
}
},
handlePageSizeChange(val) {
// 改变每页显示的条数
this.PageSize = val
// 注意:在改变每页显示的条数时,要将页码显示到第一页
this.currentPage = 1
},
handlePageChange(val) {
// 改变默认的页数
this.currentPage = val
},
// tabs的方法控制
get_config_data(config_data) {
console.log(config_data)
// 执行转译data
let new_data = {
"interaction_name": config_data["interaction_name"],
"return_data": config_data["return_data"],
"submit_data": {
"interaction_source_name": config_data["submit_data"]["interaction_source_name"],
"interaction_source_uuid": config_data["submit_data"]["interaction_source_uuid"],
"interaction_object_type": config_data["submit_data"]["interaction_object_type"],
"interaction_style": config_data["submit_data"]["interaction_style"],
"target_table": config_data["submit_data"]["target_table"],
"target_api_url": config_data["submit_data"]["target_api_url"],
"target_api_ID": config_data["submit_data"]["target_api_ID"],
}
}
let re = this.format_data(config_data["submit_data"]["data"])
new_data["submit_data"]["data"] = re
return new_data
},
format_data(dict) {
if (typeof dict == "string") {
dict = eval(dict)
} else {
for (const key in dict) {
let value = dict[key]
if (typeof value == "object") {
this.format_data(value)
} else {
if (typeof value == 'number') {
dict[key] = value
} else {
if (value.includes("this.")) {
if (dict.hasOwnProperty(key)) {
dict[key] = eval(value)
}
} else {
if (value.includes(".")) {
if (dict.hasOwnProperty(key)) {
dict[key] = eval(value)
}
} else {
dict[key] = value
}
}
}
}
}
}
return dict
},
handleSelectionChange(selection) {
this.ids = selection.map(item => item.uuid);
},
handleSelection(val) {
this.selections = val
},
tableRowClassName(row) {
var arr = this.ids;
for (let i = 0; i < arr.length; i++) {
if (row.row.uuid === arr[i]) {
return 'rowStyle'
}
}
},
cellStyle(cell) {
if (cell.columnIndex == 0 || cell.columnIndex == 1) {
var arr = this.ids;
for (let i = 0; i < arr.length; i++) {
if (cell.row.uuid === arr[i]) {
return 'cell_new'
}
}
}
},
del_data() {
const { url, method, data: originalData, then } = axios_config.del_data.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
export_data() {
const { url, method, data: originalData, then } = axios_config.export_data.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
responseType: 'blob'
}).then(response => {
eval(then)
})
},
export_temp_data() {
const { url, method, data: originalData, then } = axios_config.export_temp_data.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
coustom_button_one() {
const { url, method, data: originalData, then } = axios_config.coustom_button_one.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
coustom_button_two() {
const { url, method, data: originalData, then } = axios_config.coustom_button_two.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
handleCurrentChange(val) {
const { url, method, data: originalData, then } = axios_config.handleCurrentChange.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
adddata() {
const { url, method, data: originalData, then } = axios_config.adddata.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
delrecord(row) {
this.now_selection_record = row.uuid
const { url, method, data: originalData, then } = axios_config.delrecord.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
editrecord(row) {
this.now_selection_record = row.uuid
const { url, method, data: originalData, then } = axios_config.editrecord.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
searchrecord() {
const { url, method, data: originalData, then } = axios_config.searchrecord.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
this.totalCount = res.data.data.return_data.data[res.data.data.submit_data.target_table].recorder_attribute_dict.length
eval(then)
})
},
updateShow(val) {
this.dialogTableVisible1 = val
},
coustomOne(row) {
this.now_selection_record = row.uuid
const { url, method, data: originalData, then } = axios_config.coustomOne.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
coustomTwo(row) {
this.now_selection_record = row.uuid
const { url, method, data: originalData, then } = axios_config.coustomTwo.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
handleClick(val) {
this.search = {}
this.search[val.props.name] = val.props.label
const { url, method, data: originalData, then } = axios_config.handleClick.axios;
const data = JSON.parse(JSON.stringify(originalData));
let new_data = this.get_config_data(data)
new_data["submit_data"]["user_token"] = sessionStorage.getItem("user")
// 发起请求
axios({
method,
url,
data: new_data,
}).then(res => {
// 执行回调函数then回调
eval(then)
})
},
changepage(val) {
this.$emit('change_page', val)
},
}
export default {
data: data,
methods: methods,
mounted: mounted,
components: components,
props: props
}