|
@@ -38,7 +38,7 @@
|
|
|
开始时间:
|
|
|
</view>
|
|
|
<view class="example-body">
|
|
|
- <uni-datetime-picker v-model="start_time" :start="this.id ? '' : now" />
|
|
|
+ <uni-datetime-picker v-model="start_time" :start="id ? '' : now" />
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="form-item" v-if="report_type">
|
|
@@ -88,260 +88,277 @@
|
|
|
</form>
|
|
|
</view>
|
|
|
</template>
|
|
|
-<style scoped>
|
|
|
-::v-deep .funcAdd .uni-date-x--border,
|
|
|
-.uni-date-x {
|
|
|
- border-radius: 0 !important;
|
|
|
-}
|
|
|
-.funcAdd .example-body {
|
|
|
- margin: 0;
|
|
|
- width: calc(100% - 200rpx);
|
|
|
-}
|
|
|
-</style>
|
|
|
|
|
|
-<script>
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- id: "",
|
|
|
-
|
|
|
- report_type: "",
|
|
|
- device_type: "",
|
|
|
- start_time: "",
|
|
|
- end_time: "",
|
|
|
- remarks: "",
|
|
|
- device_port: "",
|
|
|
- port_type: "",
|
|
|
- device_code: "",
|
|
|
- now: "",
|
|
|
-
|
|
|
- deviceListData: [],
|
|
|
- detailsData: "",
|
|
|
- };
|
|
|
- },
|
|
|
- onLoad: function (option) {
|
|
|
- this.id = option.id;
|
|
|
- uni.setNavigationBarTitle({
|
|
|
- title: option.id ? "编辑" : "新增",
|
|
|
- });
|
|
|
+<script setup>
|
|
|
+import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
|
|
|
+import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, watch } from "vue";
|
|
|
|
|
|
- var nowTemp = new Date();
|
|
|
- this.now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
|
|
|
+const data = reactive({
|
|
|
+ id: "",
|
|
|
|
|
|
- if (option.id) {
|
|
|
- this.getDetailsData({ id: option.id });
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- start_time: function () {
|
|
|
- // alert(this.start_time)
|
|
|
- },
|
|
|
- report_type: function (newVal) {
|
|
|
- if (newVal) {
|
|
|
- var array123 = ["", "1", "2", "3", "4", "5", "6", "7", "16", "128", "131", "130", "129", "17"];
|
|
|
- if (array123.indexOf(this.device_type) == -1) {
|
|
|
- this.device_type = "";
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- device_type: function (newVal) {
|
|
|
- if (newVal) {
|
|
|
- this.deviceList({
|
|
|
- company_code: uni.getStorageSync("selectedCode"),
|
|
|
- device_type: this.device_type,
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 回显信息请求
|
|
|
- async getDetailsData(params = {}) {
|
|
|
- const res = await this.$myRequest({
|
|
|
- url: "AlarmReport/editData",
|
|
|
- data: params,
|
|
|
- showLoading: true,
|
|
|
- });
|
|
|
+ report_type: "",
|
|
|
+ device_type: "",
|
|
|
+ start_time: "",
|
|
|
+ end_time: "",
|
|
|
+ remarks: "",
|
|
|
+ device_port: "",
|
|
|
+ port_type: "",
|
|
|
+ device_code: "",
|
|
|
+ now: "",
|
|
|
|
|
|
- this.detailsData = res.data.data[0];
|
|
|
- console.log(this.detailsData);
|
|
|
- this.report_type = this.detailsData.report_type;
|
|
|
- this.device_type = this.detailsData.device_type;
|
|
|
- this.start_time = this.detailsData.start_time;
|
|
|
- this.end_time = this.detailsData.end_time;
|
|
|
- this.remarks = this.detailsData.remarks;
|
|
|
- this.port_type = this.detailsData.port_type;
|
|
|
- this.device_port = this.detailsData.device_port;
|
|
|
- this.device_code = this.detailsData.device_code;
|
|
|
- },
|
|
|
-
|
|
|
- async submit() {
|
|
|
- //提交验证
|
|
|
-
|
|
|
- if (!this.report_type) {
|
|
|
- uni.showToast({
|
|
|
- title: "请输入报备类型",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.report_type == 1) {
|
|
|
- if (!this.start_time.replace(/^\s*/g, "")) {
|
|
|
- uni.showToast({
|
|
|
- title: "请选择开始时间",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!this.end_time.replace(/^\s*/g, "")) {
|
|
|
- uni.showToast({
|
|
|
- title: "请选择结束时间",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if (this.report_type == 2 || this.report_type == 3) {
|
|
|
- if (!this.device_type) {
|
|
|
- uni.showToast({
|
|
|
- title: "请选择设备类型",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!this.start_time.replace(/^\s*/g, "")) {
|
|
|
- uni.showToast({
|
|
|
- title: "请输入开始时间",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!this.end_time.replace(/^\s*/g, "")) {
|
|
|
- uni.showToast({
|
|
|
- title: "请输入结束时间",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ deviceListData: [],
|
|
|
+ detailsData: "",
|
|
|
+});
|
|
|
|
|
|
- if (this.report_type == 3 && this.device_type) {
|
|
|
- if (this.device_type == 6) {
|
|
|
- if (!this.device_port.replace(/^\s*/g, "")) {
|
|
|
- uni.showToast({
|
|
|
- title: "请输入端口号",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!this.port_type) {
|
|
|
- uni.showToast({
|
|
|
- title: "请选择端口类型",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!this.device_code) {
|
|
|
- uni.showToast({
|
|
|
- title: "请选择报备设备",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!this.device_code) {
|
|
|
- uni.showToast({
|
|
|
- title: "请选择报备设备",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+const {
|
|
|
+ id,
|
|
|
+ report_type,
|
|
|
+ device_type,
|
|
|
+ start_time,
|
|
|
+ end_time,
|
|
|
+ remarks,
|
|
|
+ device_port,
|
|
|
+ port_type,
|
|
|
+ device_code,
|
|
|
+ now,
|
|
|
|
|
|
- let queryParam = {};
|
|
|
- if (this.id) {
|
|
|
- queryParam.id = this.id;
|
|
|
- }
|
|
|
- queryParam.report_type = this.report_type;
|
|
|
- queryParam.company_code = uni.getStorageSync("selectedCode");
|
|
|
- queryParam.remarks = this.remarks;
|
|
|
- queryParam.start_time = this.start_time;
|
|
|
- queryParam.end_time = this.end_time;
|
|
|
-
|
|
|
- if (this.id) {
|
|
|
- queryParam.id = this.id;
|
|
|
- }
|
|
|
+ deviceListData,
|
|
|
+ detailsData,
|
|
|
+} = toRefs;
|
|
|
|
|
|
- if (this.report_type == 1) {
|
|
|
- this.addDevice(queryParam);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.report_type == 2) {
|
|
|
- queryParam.device_type = this.device_type;
|
|
|
- this.addDevice(queryParam);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.report_type == 3) {
|
|
|
- queryParam.device_type = this.device_type;
|
|
|
- if (this.device_type == 6) {
|
|
|
- queryParam.port_type = this.port_type;
|
|
|
- queryParam.device_port = this.device_port;
|
|
|
- }
|
|
|
- queryParam.device_code = this.device_code;
|
|
|
- this.addDevice(queryParam);
|
|
|
- return;
|
|
|
- }
|
|
|
+// 回显信息请求
|
|
|
+async function getDetailsData(params = {}) {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: "AlarmReport/editData",
|
|
|
+ data: params,
|
|
|
+ showLoading: true,
|
|
|
+ });
|
|
|
+
|
|
|
+ detailsData.value = res.data.data[0];
|
|
|
+ console.log(detailsData.value);
|
|
|
+ report_type.value = detailsData.value.report_type;
|
|
|
+ device_type.value = detailsData.value.device_type;
|
|
|
+ start_time.value = detailsData.value.start_time;
|
|
|
+ end_time.value = detailsData.value.end_time;
|
|
|
+ remarks.value = detailsData.value.remarks;
|
|
|
+ port_type.value = detailsData.value.port_type;
|
|
|
+ device_port.value = detailsData.value.device_port;
|
|
|
+ device_code.value = detailsData.value.device_code;
|
|
|
+}
|
|
|
|
|
|
- this.addDevice(queryParam);
|
|
|
- },
|
|
|
+async function submit() {
|
|
|
+ //提交验证
|
|
|
|
|
|
- async addDevice(params = {}) {
|
|
|
- const res = await this.$myRequest({
|
|
|
- url: this.id ? "AlarmReport/edit" : "AlarmReport/add",
|
|
|
- data: params,
|
|
|
+ if (!report_type.value) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请输入报备类型",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (report_type.value == 1) {
|
|
|
+ if (!start_time.value.replace(/^\s*/g, "")) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请选择开始时间",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!end_time.value.replace(/^\s*/g, "")) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请选择结束时间",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (report_type.value == 2 || report_type.value == 3) {
|
|
|
+ if (!device_type.value) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请选择设备类型",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!start_time.value.replace(/^\s*/g, "")) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请输入开始时间",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!end_time.value.replace(/^\s*/g, "")) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请输入结束时间",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (!res.data.flag) {
|
|
|
+ if (report_type.value == 3 && device_type.value) {
|
|
|
+ if (device_type.value == 6) {
|
|
|
+ if (!device_port.value.replace(/^\s*/g, "")) {
|
|
|
uni.showToast({
|
|
|
- title: "提交失败",
|
|
|
+ title: "请输入端口号",
|
|
|
icon: "none",
|
|
|
});
|
|
|
- } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!port_type.value) {
|
|
|
uni.showToast({
|
|
|
- title: "提交成功",
|
|
|
+ title: "请选择端口类型",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
+ return;
|
|
|
}
|
|
|
- setTimeout(() => {
|
|
|
- uni.redirectTo({
|
|
|
- url: "/pages/setting/funReport/funReport",
|
|
|
+ if (!device_code.value) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请选择报备设备",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
- }, 1000);
|
|
|
- },
|
|
|
-
|
|
|
- radioChange(e) {
|
|
|
- console.log("type:" + e.detail.value);
|
|
|
- this.radioOne = e.detail.value;
|
|
|
- },
|
|
|
-
|
|
|
- //报备设备下拉请求数据
|
|
|
- async deviceList(params = {}) {
|
|
|
- const res = await this.$myRequest({
|
|
|
- url: "AlarmReport/deviceList",
|
|
|
- data: params,
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!device_code.value) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "请选择报备设备",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
- this.deviceListData = res.data.data;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- var arr = [];
|
|
|
- this.deviceListData.forEach(function (item) {
|
|
|
- arr.push(item.owner_code);
|
|
|
- });
|
|
|
- if (arr.indexOf(this.device_code) == -1) {
|
|
|
- this.device_code = "";
|
|
|
+ let queryParam = {};
|
|
|
+ if (id.value) {
|
|
|
+ queryParam.id = id.value;
|
|
|
+ }
|
|
|
+ queryParam.report_type = report_type.value;
|
|
|
+ queryParam.company_code = uni.getStorageSync("selectedCode");
|
|
|
+ queryParam.remarks = remarks.value;
|
|
|
+ queryParam.start_time = start_time.value;
|
|
|
+ queryParam.end_time = end_time.value;
|
|
|
+
|
|
|
+ if (id.value) {
|
|
|
+ queryParam.id = id.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (report_type.value == 1) {
|
|
|
+ addDevice(queryParam);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (report_type.value == 2) {
|
|
|
+ queryParam.device_type = device_type.value;
|
|
|
+ addDevice(queryParam);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (report_type.value == 3) {
|
|
|
+ queryParam.device_type = device_type.value;
|
|
|
+ if (device_type.value == 6) {
|
|
|
+ queryParam.port_type = port_type.value;
|
|
|
+ queryParam.device_port = device_port.value;
|
|
|
+ }
|
|
|
+ queryParam.device_code = device_code.value;
|
|
|
+ addDevice(queryParam);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ addDevice(queryParam);
|
|
|
+}
|
|
|
+
|
|
|
+async function addDevice(params = {}) {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: id.value ? "AlarmReport/edit" : "AlarmReport/add",
|
|
|
+ data: params,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!res.data.flag) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "提交失败",
|
|
|
+ icon: "none",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: "提交成功",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: "/pages/setting/funReport/funReport",
|
|
|
+ });
|
|
|
+ }, 1000);
|
|
|
+}
|
|
|
+
|
|
|
+function radioChange(e) {
|
|
|
+ console.log("type:" + e.detail.value);
|
|
|
+ radioOne.value = e.detail.value;
|
|
|
+}
|
|
|
+
|
|
|
+//报备设备下拉请求数据
|
|
|
+async function deviceList(params = {}) {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ url: "AlarmReport/deviceList",
|
|
|
+ data: params,
|
|
|
+ });
|
|
|
+ deviceListData.value = res.data.data;
|
|
|
+
|
|
|
+ var arr = [];
|
|
|
+ deviceListData.value.forEach(function (item) {
|
|
|
+ arr.push(item.owner_code);
|
|
|
+ });
|
|
|
+ if (arr.indexOf(device_code.value) == -1) {
|
|
|
+ device_code.value = "";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onLoad((option) => {
|
|
|
+ id.value = option.id;
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title: option.id ? "编辑" : "新增",
|
|
|
+ });
|
|
|
+
|
|
|
+ var nowTemp = new Date();
|
|
|
+ now.value = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
|
|
|
+
|
|
|
+ if (option.id) {
|
|
|
+ getDetailsData({ id: option.id });
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+watch(() => {
|
|
|
+ function start_time() {
|
|
|
+ // alert(start_time.value)
|
|
|
+ }
|
|
|
+ function report_type(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ var array123 = ["", "1", "2", "3", "4", "5", "6", "7", "16", "128", "131", "130", "129", "17"];
|
|
|
+ if (array123.indexOf(device_type.value) == -1) {
|
|
|
+ device_type.value = "";
|
|
|
}
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function device_type(newVal) {
|
|
|
+ if (newVal) {
|
|
|
+ deviceList({
|
|
|
+ company_code: uni.getStorageSync("selectedCode"),
|
|
|
+ device_type: device_type.value,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
+<style scoped>
|
|
|
+::v-deep .funcAdd .uni-date-x--border,
|
|
|
+.uni-date-x {
|
|
|
+ border-radius: 0 !important;
|
|
|
+}
|
|
|
+.funcAdd .example-body {
|
|
|
+ margin: 0;
|
|
|
+ width: calc(100% - 200rpx);
|
|
|
+}
|
|
|
+</style>
|
|
|
+
|
|
|
<style lang="scss">
|
|
|
input,
|
|
|
select,
|