修改confirm弹窗的默认按钮,增加无数据的提示

This commit is contained in:
renpy 2023-09-06 17:48:47 +08:00
parent ec6cb33835
commit c45cd40ba9
6 changed files with 136 additions and 103 deletions

View File

@ -63,7 +63,7 @@ export default {
if (res.success) { if (res.success) {
this.content = res.result this.content = res.result
} else { } else {
this.content = res this.content = ""
} }
} catch (error) { } catch (error) {
console.error(error) console.error(error)
@ -80,28 +80,34 @@ export default {
} }
}, },
handleOk() { handleOk() {
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' }); if (this.content) {
// if (this.type == 1 || this.type == 3) { let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
// saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'} ARR.txt`) // if (this.type == 1 || this.type == 3) {
// } else { // saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'} ARR.txt`)
// saveAs(strData, `${this.type == 2 ?'Gamma-':'Beta-'} RRR.txt`) // } else {
// } // saveAs(strData, `${this.type == 2 ?'Gamma-':'Beta-'} RRR.txt`)
let _this = this // }
this.$confirm({ let _this = this
title: 'Please enter file name', this.$confirm({
content: h => <a-input v-model={_this.fileName} />, title: 'Please enter file name',
okText: 'Save', content: h => <a-input v-model={_this.fileName} />,
cancelText: 'Cancle', okText: 'Cancle',
onOk() { cancelText: 'Save',
if (_this.fileName) { okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
_this.visible = false cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
saveAs(strData, `${_this.fileName}.txt`) onOk() {
} console.log('Cancel');
}, },
onCancel() { onCancel() {
console.log('Cancel'); if (_this.fileName) {
}, _this.visible = false
}); saveAs(strData, `${_this.fileName}.txt`)
}
},
});
} else {
this.$message.warning("No data can be saved!")
}
} }
} }
} }

View File

@ -41,7 +41,7 @@ export default {
const res = await getAction(this.type == 1 ? '/gamma/viewAutomaticAnalysisLog' : '/gamma/viewAutomaticAnalysisLog', { // gammam,beta const res = await getAction(this.type == 1 ? '/gamma/viewAutomaticAnalysisLog' : '/gamma/viewAutomaticAnalysisLog', { // gammam,beta
sampleId sampleId
}) })
this.content = res this.content = ""
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} finally { } finally {
@ -54,24 +54,30 @@ export default {
}, },
handleOk() { handleOk() {
let _this = this if (this.content) {
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' }); let _this = this
// saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'}Automatic Analysis Log.txt`) let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
this.$confirm({ // saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'}Automatic Analysis Log.txt`)
title: 'Please enter file name', this.$confirm({
content: h => <a-input v-model={_this.fileName} />, title: 'Please enter file name',
okText: 'Save', content: h => <a-input v-model={_this.fileName} />,
cancelText: 'Cancle', okText: 'Cancle',
onOk() { cancelText: 'Save',
if (_this.fileName) { okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
_this.visible = false cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
saveAs(strData, `${_this.fileName}.txt`) onOk() {
} console.log('Cancel');
}, },
onCancel() { onCancel() {
console.log('Cancel'); if (_this.fileName) {
}, _this.visible = false
}); saveAs(strData, `${_this.fileName}.txt`)
}
},
});
} else {
this.$message.warning("No data can be saved!")
}
} }
} }
} }

View File

@ -142,17 +142,19 @@ export default {
this.$confirm({ this.$confirm({
title: 'Please enter file name', title: 'Please enter file name',
content: h => <a-input v-model={_this.fileName} />, content: h => <a-input v-model={_this.fileName} />,
okText: 'Save', okText: 'Cancle',
cancelText: 'Cancle', cancelText: 'Save',
okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
onOk() { onOk() {
console.log('Cancel');
},
onCancel() {
if (_this.fileName) { if (_this.fileName) {
_this.visible = false _this.visible = false
saveAs(strData, `${_this.fileName}.txt`) saveAs(strData, `${_this.fileName}.txt`)
} }
}, },
onCancel() {
console.log('Cancel');
},
}); });
} }
} }

View File

@ -44,6 +44,7 @@ export default {
this.content = res.result this.content = res.result
} }
else { else {
this.content = ""
this.$message.error(res.message) this.$message.error(res.message)
} }
} catch (error) { } catch (error) {
@ -59,24 +60,30 @@ export default {
} }
}, },
saveText() { saveText() {
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' }); if (this.content) {
// saveAs(strData, `Beta-View Sample Infomation.txt`) let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
let _this = this // saveAs(strData, `Beta-View Sample Infomation.txt`)
this.$confirm({ let _this = this
title: 'Please enter file name', this.$confirm({
content: h => <a-input v-model={_this.fileName} />, title: 'Please enter file name',
okText: 'Save', content: h => <a-input v-model={_this.fileName} />,
cancelText: 'Cancle', okText: 'Cancle',
onOk() { cancelText: 'Save',
if (_this.fileName) { okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
_this.visible = false cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
saveAs(strData, `${_this.fileName}.txt`) onOk() {
} console.log('Cancel');
}, },
onCancel() { onCancel() {
console.log('Cancel'); if (_this.fileName) {
}, _this.visible = false
}); saveAs(strData, `${_this.fileName}.txt`)
}
},
});
} else {
this.$message.warning("No data can be saved!")
}
} }
} }
} }

View File

@ -77,7 +77,7 @@ export default {
}, },
handleOk() { handleOk() {
let text = "" let text = ""
if (this.currTab==1) { if (this.currTab == 1) {
text=this.content.sample.join('\n') text=this.content.sample.join('\n')
} else if (this.currTab == 2) { } else if (this.currTab == 2) {
text=this.content.gasBg.join('\n') text=this.content.gasBg.join('\n')
@ -86,25 +86,30 @@ export default {
}else if (this.currTab == 4) { }else if (this.currTab == 4) {
text=this.content.qc.join('\n') text=this.content.qc.join('\n')
} }
console.log(text); if (this.text) {
let strData = new Blob([text], { type: 'text/plain;charset=utf-8' }); let strData = new Blob([text], { type: 'text/plain;charset=utf-8' });
// saveAs(strData, `GammaViewer Log.txt`) // saveAs(strData, `GammaViewer Log.txt`)
let _this = this let _this = this
this.$confirm({ this.$confirm({
title: 'Please enter file name', title: 'Please enter file name',
content: h => <a-input v-model={_this.fileName} />, content: h => <a-input v-model={_this.fileName} />,
okText: 'Save', okText: 'Cancle',
cancelText: 'Cancle', cancelText: 'Save',
onOk() { okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
if (_this.fileName) { cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
// _this.visible = false onOk() {
saveAs(strData, `${_this.fileName}.txt`) console.log('Cancel');
} },
}, onCancel() {
onCancel() { if (_this.fileName) {
console.log('Cancel'); _this.visible = false
}, saveAs(strData, `${_this.fileName}.txt`)
}); }
},
});
} else {
this.$message.warning("No data can be saved!")
}
} }
} }
} }

View File

@ -45,29 +45,36 @@ export default {
if (res.success) { if (res.success) {
this.text = res.result this.text = res.result
} else { } else {
this.text = ""
this.$message.warning("This operation fails. Contact your system administrator") this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },
handleOk() { handleOk() {
let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' }); if (this.text) {
// saveAs(strData, `GammaViewer Log.txt`) let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' });
let _this = this // saveAs(strData, `GammaViewer Log.txt`)
this.$confirm({ let _this = this
title: 'Please enter file name', this.$confirm({
content: h => <a-input v-model={_this.fileName} />, title: 'Please enter file name',
okText: 'Save', content: h => <a-input v-model={_this.fileName} />,
cancelText: 'Cancle', okText: 'Cancle',
onOk() { cancelText: 'Save',
if (_this.fileName) { okButtonProps: {style: {backgroundColor: "#b98326", color: "#fff", borderColor: "transparent"}},
_this.visible = false cancelButtonProps: {style: {color: "#fff", backgroundColor: "#31aab0", borderColor: "transparent"}},
saveAs(strData, `${_this.fileName}.txt`) onOk() {
} console.log('Cancel');
}, },
onCancel() { onCancel() {
console.log('Cancel'); if (_this.fileName) {
}, _this.visible = false
}); saveAs(strData, `${_this.fileName}.txt`)
}
},
});
} else {
this.$message.warning("No data can be saved!")
}
} }
}, },
} }