提交 432fafda authored 作者: JaxBBLL's avatar JaxBBLL

feat: add page

上级 66c704c2
import SqlliteDbUtil from '@/utils/sqllitedb'
import table from './sqllite/table.js'
import {
fixNullVal
} from "@/utils/common";
import SqlliteDbUtil from "@/utils/sqllitedb";
import table from "./sqllite/table.js";
import { fixNullVal } from "@/utils/common";
// 巡检
export default {
async selectList() {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
let rs = await sqllitedb.selectSQL(`select * from ${table.assRoomName}`);
return rs;
},
async selectList() {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let rs = await sqllitedb.selectSQL(`select * from ${table.assRoomName}`)
return rs
},
async selectRoomList(roomType = 1) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
let rs = await sqllitedb.selectSQL(
`select * from ${table.assRoomName} where roomType = ${roomType}`
);
return rs;
},
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
let sql = `select * from ${table.assRoomName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0];
}
},
async remove(id) {
if (!id) {
return;
}
let sql = `delete from ${table.assRoomName} where id = '${id}'`;
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
await sqllitedb.executeSQL(sql);
},
async saveBatch(list) {
if (list.length === 0) {
return;
}
console.log("开始保存机房信息...." + list.length);
let sqllitedb = await SqlliteDbUtil.initSqlliteDB();
try {
for (let data of list) {
let column = "";
let values = "";
let idx = 0;
for (let attr in data) {
let dataField = table["assRoom"].find((v) => {
if (v.field === attr) {
return v;
}
});
if (!dataField) {
continue;
}
column += dataField.field + ",";
values += "'" + fixNullVal(data[attr]) + "',";
idx++;
}
async info(id) {
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
let sql = `select * from ${table.assRoomName} where id = '${id}'`;
let res = await sqllitedb.selectSQL(sql);
if (res && res.length > 0) {
return res[0]
}
},
async remove(id) {
if (!id) {
return
}
let sql = `delete from ${table.assRoomName} where id = '${id}'`;
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
await sqllitedb.executeSQL(sql);
},
async saveBatch(list) {
if (list.length === 0) {
return;
}
console.log('开始保存机房信息....' + list.length)
let sqllitedb = await SqlliteDbUtil.initSqlliteDB()
try {
for (let data of list) {
let column = ''
let values = ''
let idx = 0
for (let attr in data) {
let dataField = table['assRoom'].find(v => {
if (v.field === attr) {
return v
}
})
if (!dataField) {
continue
}
column += dataField.field + ','
values += "'" + fixNullVal(data[attr]) + "',"
idx++
}
column = column.endsWith(",")
? column.substring(0, column.length - 1)
: column;
values = values.endsWith(",")
? values.substring(0, values.length - 1)
: values;
column = column.endsWith(',') ? column.substring(0, column.length - 1) : column
values = values.endsWith(',') ? values.substring(0, values.length - 1) : values
let sql = `insert into ${table.assRoomName}(${column}) values(${values})`
let has = await this.info(data.id)
if (has && has.id) {
await this.remove(data.id)
}
await sqllitedb.executeSQL(sql)
}
} catch (e) {
console.log(e.message)
} finally {
await sqllitedb.closeDB();
}
console.log('导入完成...')
}
}
\ No newline at end of file
let sql = `insert into ${table.assRoomName}(${column}) values(${values})`;
let has = await this.info(data.id);
if (has && has.id) {
await this.remove(data.id);
}
await sqllitedb.executeSQL(sql);
}
} catch (e) {
console.log(e.message);
} finally {
await sqllitedb.closeDB();
}
console.log("导入完成...");
},
};
......@@ -23,6 +23,11 @@
color: #3774f6 !important;
}
&.v-btn-danger {
background-color: rgb(246, 197, 197) !important;
color: #dc3545 !important;
}
&.v-btn-round {
border-radius: 20px !important;
}
......
......@@ -27,6 +27,10 @@ export default {
type: Boolean,
default: false,
},
onlyInteger: {
type: Boolean,
default: false,
},
},
methods: {
handleInput(e) {
......@@ -34,18 +38,29 @@ export default {
if (!this.allowNegative) {
value = value.replace(/-/g, "");
}
// 去除非数字和小数点以外的字符
value = value.replace(/[^\d.]/g, "");
// 保证只有一个小数点
const dotCount = (value.match(/\./g) || []).length;
if (dotCount > 1) {
value = value.slice(0, value.lastIndexOf("."));
if (this.onlyInteger) {
// 只能输入整数时,去除小数点和非数字字符
value = value.replace(/[^\d-]/g, "");
} else {
// 允许小数时,去除非数字、小数点和负号以外的字符
value = value.replace(/[^\d.-]/g, "");
}
// 保证只有一个负号且在开头
if (value.indexOf("-") > 0) {
value = value.replace(/-/g, "");
}
// 处理小数点后的位数
if (value.includes(".")) {
const parts = value.split(".");
parts[1] = parts[1].slice(0, this.decimalPlaces);
value = parts.join(".");
if (!this.onlyInteger) {
// 保证只有一个小数点
const dotCount = (value.match(/\./g) || []).length;
if (dotCount > 1) {
value = value.slice(0, value.lastIndexOf("."));
}
// 处理小数点后的位数
if (value.includes(".")) {
const parts = value.split(".");
parts[1] = parts[1].slice(0, this.decimalPlaces);
value = parts.join(".");
}
}
if (value) {
const numValue = parseFloat(value);
......@@ -55,7 +70,11 @@ export default {
value = this.max.toString();
}
}
this.inputValue = value;
this.$nextTick(() => {
this.inputValue = value;
});
console.log("NumberInput", value);
this.$emit("input", value);
},
},
......
......@@ -31,20 +31,21 @@
>
<view>
<view
class="flex items-center"
class="cabinet-item"
v-for="(cabinet, idx) in item.cabinets"
:key="idx"
>
<view class="form-item">
<view>
<!-- <text class="form-label"></text> -->
<input
class="conclusion"
style="width: 120px"
v-model="cabinet.deviceId"
type="text"
placeholder="请输入编号"
/>
</view>
<view class="form-item">
<view class="flex items-center">
<text class="form-label"
><text class="required">*</text
>{{ cabinet.UpositonLabel }}</text
......@@ -53,6 +54,7 @@
class="input"
v-model="cabinet.UpositonS"
type="number"
onlyInteger
placeholder="请输入"
/>
<!-- <input
......@@ -67,6 +69,7 @@
class="input"
v-model="cabinet.UpositonE"
type="number"
onlyInteger
placeholder="请输入"
/>
<!-- <input
......@@ -77,9 +80,14 @@
maxlength="2"
/> -->
</view>
<view>
<button class="v-btn">+</button>
<button class="v-btn v-btn-default ml-10">-</button>
<view class="flex items-center ml-30">
<button class="v-btn" @click="onAddCabinet">+</button>
<button
class="v-btn v-btn-danger ml-10"
@click="onRemoveCabinet(idx)"
>
-
</button>
</view>
</view>
</view>
......@@ -180,7 +188,6 @@ export default {
cabinets: [
{
deviceId: "",
deviceLabel: "故障设备机柜",
UpositonLabel: "U位",
UpositonS: "",
UpositonE: "",
......@@ -347,6 +354,16 @@ export default {
return { statusLabel: "未巡检", status: 0 };
}
},
onAddCabinet() {
const newCabinet = {
deviceId: "",
UpositonLabel: "U位",
UpositonS: "",
UpositonE: "",
};
this.itemData.detail[this.currentIndex].cabinets.push(newCabinet);
},
onRemoveCabinet() {},
},
};
</script>
......@@ -377,8 +394,8 @@ export default {
margin: 0 12px;
}
.conclusion {
color: #c7c7c7;
font-size: 11.2px;
// color: #c7c7c7;
// font-size: 11.2px;
.have {
color: #000;
}
......@@ -469,4 +486,13 @@ export default {
line-height: 51.2px;
}
}
.cabinet-item {
display: flex;
align-items: center;
}
.cabinet-item + .cabinet-item {
margin-top: 10px;
}
</style>
......@@ -201,6 +201,8 @@ import { getInspectionDetails } from "@/request/index.js";
import signDialog from "@/components/signDialog.vue";
import detail from "./components/detail.vue";
import startDialog from "./components/dialog.vue";
import assRoomApi from "@/api/assRoom.js";
export default {
components: {
signDialog,
......@@ -249,6 +251,8 @@ export default {
this.value = this.options.value || "1";
},
onShow() {
this.getRoomList();
if (this.uid) {
this.getDetails(this.uid);
} else {
......@@ -263,6 +267,11 @@ export default {
console.log("onShow", this.all_data);
},
methods: {
getRoomList() {
assRoomApi.selectRoomList(1).then((res) => {
console.log("机房列表", res);
});
},
init() {
return new Promise((resolve, reject) => {
let list = pad_all_inspection_position.rows.map((item, index) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论