1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <template>
- <div>
- <el-button :disabled="disabled ? disabled : false" :type="type ? type : 'primary'" :size="size ? size : 'mini'" @click="submit">{{ btnName }}</el-button>
- </div>
- </template>
- <script>
- export default {
- name: '',
- props:{
- type: String,
- btnName: String,
- message: String,
- idName: String,
- keyName: String,
- id: [String,Number,Array],
- disabled: Boolean,
- idIsArr: Boolean,
- paramData: {
- type: Array,
- default () {
- return []
- }
- },
- dialog: Boolean,
- dialogTitle:String,
- dialogKey:String,
- checkContent: Boolean,
- size: String
- },
- data() {
- return {
- };
- },
- computed:{
- },
- watch:{
- },
- methods: {
- submit () {
- if (this.dialog) {
- this.$prompt(this.dialogTitle, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputPattern: this.checkContent ? /^[\d.]+$/ : ''
- }).then(async ({ value }) => {
- let param = {
- content:{}
- }
- param.id = this.idName
- param.content[this.keyName] = this.idIsArr ? [this.id] : this.id
- this.paramData.forEach(item => {
- param.content[item.key] = item.value
- })
- param.content[this.dialogKey] = value
- let res = await this.$api.requested(param)
- this.tool.showMessage(res,() => {
- this.$emit('onSuccess',res.data)
- })
- })
- } else {
- this.$confirm(this.message,'提示',{
- confirmButtonText:'确定',
- cancelButtonText:'取消',
- type:'warning'
- }).then(async () => {
- let param = {
- content:{}
- }
- param.id = this.idName
- param.content[this.keyName] = this.idIsArr ? [this.id] : this.id
- this.paramData.forEach(item => {
- param.content[item.key] = item.value
- })
- let res = await this.$api.requested(param)
- this.tool.showMessage(res,() => {
- this.$emit('onSuccess',res.data)
- })
- })
- }
-
- }
- },
- };
- </script>
- <style scoped>
- </style>
|