nursing_unit_vue/src/views/services/serviceDirective/components/ConfigServiceDirectiveModal...

254 lines
7.2 KiB
Vue

<template>
<!-- <j-modal :title="title" width="70vw" :visible="visible" @ok="handleOk"
:okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭"
:maskClosable="false">
<template #footer>
<a-button @click="handleCancel">关闭</a-button>
<a-button @click="handleOk" v-show="opeType == 'add' || opeType == 'edit' || opeType == 'editMedia'"
:loading="loading">确定</a-button>
<a-button @click="handleSave" v-show="opeType == 'editMedia' || opeType == 'auditMedia'">暂存</a-button>
<a-button type="primary" @click="handleMediaAsync" v-show="opeType == 'auditMedia'">同步</a-button>
<a-button type="primary" @click="handleMediaSyncAllPlat" v-show="opeType == 'editMedia'">同步</a-button>
</template>
<a-spin :spinning="loading">
<ConfigServiceDirectiveForm ref="registerForm" v-if="visible" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false" :mainOrgCode="mainOrgCode"></ConfigServiceDirectiveForm>
</a-spin>
</j-modal> -->
<a-drawer :title="title" width="70vw" v-model:visible="visible" :closable="true"
:footer-style="{ textAlign: 'right' }" @close="handleCancel">
<a-spin :spinning="loading">
<ConfigServiceDirectiveForm ref="registerForm" v-if="visible" @ok="submitCallback" :formDisabled="disableSubmit"
:formBpm="false" :mainOrgCode="mainOrgCode"></ConfigServiceDirectiveForm>
</a-spin>
<template #footer>
<a-button @click="handleCancel" style="margin-right: 8px;">关闭</a-button>
<a-button @click="handleOk" v-show="opeType == 'add' || opeType == 'edit' || opeType == 'editMedia'"
:loading="loading" style="margin-right: 8px;">确定</a-button>
<!-- <a-button @click="handleSave" v-show="opeType == 'editMedia' || opeType == 'auditMedia'">暂存</a-button>
<a-button type="primary" @click="handleMediaAsync" v-show="opeType == 'auditMedia'">同步</a-button>
<a-button type="primary" @click="handleMediaSyncAllPlat" v-show="opeType == 'editMedia'">同步</a-button> -->
</template>
</a-drawer>
<j-modal :title="'指令库'" :fullscreen="true" width="100vw" :visible="dmVisible" @cancel="handleCancelDM"
:maskClosable="false">
<template #footer>
<a-button @click="handleCancelDM">关闭</a-button>
<a-button @click="handlePullDM">镜像</a-button>
</template>
<DirectiveRespositoryList ref="dmRef" :mainOrgCode="mainOrgCode"></DirectiveRespositoryList>
</j-modal>
<!-- <a-drawer :title="'指令库'" width="100vw" v-model:visible="dmVisible" :closable="true"
:footer-style="{ textAlign: 'right' }" @close="handleCancelDM" :maskClosable="false">
<a-spin :spinning="loading">
<DirectiveRespositoryList ref="dmRef" :mainOrgCode="mainOrgCode"></DirectiveRespositoryList>
</a-spin>
<template #footer>
<a-button @click="handleCancelDM" style="margin-right: 8px;">关闭</a-button>
<a-button @click="handlePullDM">镜像</a-button>
</template>
</a-drawer> -->
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose, defineProps } from 'vue';
import ConfigServiceDirectiveForm from './ConfigServiceDirectiveForm.vue'
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
import { useMessage } from '/@/hooks/web/useMessage';
import { saveOrUpdate, queryById, syncDirective } from '../ConfigServiceDirective.api';
import DirectiveRespositoryList from './DirectiveRespositoryList.vue'
import { clearCache } from '/@/utils/cache/cacheUtil'
const mainOrgCode = ref('')
const dmRef = ref()
const loading = ref(false)
const { createMessage, createConfirm } = useMessage();
const props = defineProps({
});
const title = ref<string>('');
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
const opeType = ref('')//操作类型 add新增 edit编辑 editMedia主列表-指令资源 look详情 audit审核 auditMedia审核列表-指令资源
const dmVisible = ref(false)
function handleCancelDM() {
dmVisible.value = false
clearCache()
emit('success')
}
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record, editMedia = false, showMedia = true) {
title.value = disableSubmit.value ? '详情' : opeType.value == 'add' ? '新增' : '编辑';
visible.value = true;
mainOrgCode.value = record.orgCode_
nextTick(() => {
registerForm.value.edit(record, editMedia, showMedia);
});
}
/**
* 编辑指令资源
* @param record
*/
function queryAndEditMedia(id) {
title.value = '编辑指令资源';
visible.value = true;
nextTick(() => {
loading.value = true
queryById({ id }).then(res => {
registerForm.value.edit(res, true);
}).finally(() => {
loading.value = false
})
});
}
/**
* 编辑指令资源
* @param record
*/
function editMedia(record) {
title.value = '编辑指令资源';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record, true);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* 暂存
*/
function handleSave() {
registerForm.value.submitForm();
}
/**
* 给审核对应的业务平台同步资源
*/
function handleMediaAsync() {
registerForm.value.syncMediaForBizFunc();
}
/**
* 给所有业务平台同步资源
*/
function handleMediaSyncAllPlat() {
registerForm.value.syncMediaForAllBizFunc();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
function usingOrStop(id, izEnabled) {
let params = {
id,
izEnabled
}
saveOrUpdate(params, true).then((res) => {
if (res.success) {
createMessage.success(res.message);
} else {
createMessage.warning(res.message);
}
emit('success')
})
}
function queryByIdFunc(id) {
loading.value = true
queryById({ id }).then(res => {
edit(res)
}).finally(() => {
loading.value = false
})
}
function openDM(orgCode) {
dmVisible.value = true
mainOrgCode.value = orgCode
nextTick(() => {
dmRef.value?.init()
})
}
function handlePullDM() {
let selectedData = dmRef.value?.getSelectedIds()
if (!selectedData.count) {
createMessage.warning('未选择服务指令')
return
}
createConfirm({
iconType: 'warning',
title: '镜像确认',
content: '是否确认将<span style="font-weight:500;color:#efac0e;"> ' + selectedData.count + ' </span>条服务指令拉取到本平台?',
okText: '确认',
cancelText: '取消',
onOk: () => {
syncDirective(mainOrgCode.value, { syncIds: selectedData.ids, })
createMessage.success('已开始自动拉取,请耐心等待')
dmRef.value?.init()
}
});
}
defineExpose({
add,
edit,
editMedia,
disableSubmit,
usingOrStop,
queryByIdFunc,
opeType,
queryAndEditMedia,
openDM,
});
</script>
<style lang="less">
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>
<style lang="less" scoped></style>