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

feat: add page

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