|
@@ -121,6 +121,7 @@
|
|
|
|
|
|
<el-button
|
|
|
type="primary"
|
|
|
+ :loading="loading"
|
|
|
@click="maintenanceSelect"
|
|
|
style="margin-top:10px"
|
|
|
>维护已选
|
|
@@ -135,7 +136,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import myPagination from "@/components/ledger/lib/myPagination"
|
|
|
+import myPagination from "@/components/ledger/lib/myPagination";
|
|
|
+import { queryUpdate, updateEquip } from "@/api/scan/request";
|
|
|
import tools from "@/utils/buildfloor/tools";
|
|
|
|
|
|
export default {
|
|
@@ -146,6 +148,7 @@ export default {
|
|
|
return {
|
|
|
form: {},
|
|
|
batchDialog: false,//dialog
|
|
|
+ loading: false, //批量维护加载状态
|
|
|
active: 0,//进度条
|
|
|
checkAll: false,//全选
|
|
|
isIndeterminate: true,
|
|
@@ -404,9 +407,8 @@ export default {
|
|
|
...item,
|
|
|
...newValuable
|
|
|
}))
|
|
|
- this.$emit('upDataDevice', 1, arr1, arr2)
|
|
|
- }
|
|
|
- if (this.radio === 2) {
|
|
|
+ this.upDataDevice(1, arr1, arr2);
|
|
|
+ } else if (this.radio === 2) {
|
|
|
let param = {}, singleList = {}
|
|
|
this.newEnclosure.forEach(({ path, value }) => param[path] = value)
|
|
|
singleList.infos = { ...equipManufactor, ...supplyPurchase, ...operationMainte, ...insuranceDoc }
|
|
@@ -418,9 +420,90 @@ export default {
|
|
|
...pa,
|
|
|
|
|
|
}))
|
|
|
- this.$emit('upDataDevice', 2, arr3)
|
|
|
+ this.upDataDevice(2, arr3);
|
|
|
+ } else {
|
|
|
+ this.closeDialog()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ upDataDevice(type, data1, data2) {
|
|
|
+ this.loading = true;
|
|
|
+ let param = {content: data1};
|
|
|
+ let param1 = {content: data2};
|
|
|
+ if (type === 1) {
|
|
|
+ //增量
|
|
|
+ //LedgerParam
|
|
|
+ let filterParam = this.filterCheck(param, "sole");
|
|
|
+ let filterParam1 = this.filterCheck(param1, "multiple");
|
|
|
+ if (filterParam) {
|
|
|
+ updateEquip(param, res => {
|
|
|
+ if (res.result === "success") {
|
|
|
+ this.loading = false;
|
|
|
+ this.$emit('upDataDevice')
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ this.closeDialog();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (filterParam1) {
|
|
|
+ param1.content.map(i => {
|
|
|
+ i.equipId = i.id
|
|
|
+ delete i.id
|
|
|
+ return i
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ queryUpdate(param1, res => {
|
|
|
+ if (res.result === "success") {
|
|
|
+ this.loading = false;
|
|
|
+ this.$emit('upDataDevice')
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ this.closeDialog();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else if (type === 2) {
|
|
|
+ //覆盖
|
|
|
+ let filterParams = this.filterCheck(param, "sole");
|
|
|
+ if (filterParams) {
|
|
|
+ updateEquip(param, res => {
|
|
|
+ if (res.result === "success") {
|
|
|
+ this.loading = false;
|
|
|
+ this.$emit('upDataDevice')
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ this.closeDialog();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ filterCheck(arr, type) {
|
|
|
+ if (type === "sole") {
|
|
|
+ for (let i of arr.content) {
|
|
|
+ for (let j in i.infos) {
|
|
|
+ if (Array.isArray(i.infos[j]) && i.infos[j].length < 1) {
|
|
|
+ delete i.infos[j]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Object.keys(i.infos).length;
|
|
|
+ }
|
|
|
+ } else if (type === "multiple") {
|
|
|
+ let nArr = [];
|
|
|
+ arr.content.forEach(i => {
|
|
|
+ let {id, ...value} = i;
|
|
|
+ nArr.push({infos: value});
|
|
|
+ });
|
|
|
+ // nArr.map(i => {
|
|
|
+ // if (Array.isArray(i) && i.length < 1) {
|
|
|
+ // console.log(i)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ for (let j of nArr) {
|
|
|
+ return Object.keys(j.infos).length;
|
|
|
+ }
|
|
|
}
|
|
|
- this.closeDialog()
|
|
|
},
|
|
|
closeDialog() { //关闭弹窗,返回初始状态
|
|
|
this.batchDialog = false
|