修改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,6 +80,7 @@ export default {
} }
}, },
handleOk() { handleOk() {
if (this.content) {
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' }); let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
// if (this.type == 1 || this.type == 3) { // if (this.type == 1 || this.type == 3) {
// saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'} ARR.txt`) // saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'} ARR.txt`)
@ -90,18 +91,23 @@ 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');
},
}); });
} 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() {
if (this.content) {
let _this = this let _this = this
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' }); let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
// saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'}Automatic Analysis Log.txt`) // saveAs(strData, `${this.type == 1 ?'Gamma-':'Beta-'}Automatic Analysis Log.txt`)
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');
},
}); });
} 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() {
if (this.content) {
let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' }); let strData = new Blob([this.content], { type: 'text/plain;charset=utf-8' });
// saveAs(strData, `Beta-View Sample Infomation.txt`) // saveAs(strData, `Beta-View Sample Infomation.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',
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');
},
}); });
} else {
this.$message.warning("No data can be saved!")
}
} }
} }
} }

View File

@ -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',
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');
},
}); });
} 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() {
if (this.text) {
let strData = new Blob([this.text], { type: 'text/plain;charset=utf-8' }); let strData = new Blob([this.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',
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');
},
}); });
} else {
this.$message.warning("No data can be saved!")
}
} }
}, },
} }