123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- <template>
- <hc-drawer v-model="isShow" to-id="node-card-plan" is-close>
- <hc-card>
- <template #header>
- <el-link type="primary" @click="goBack">返回</el-link>
- </template>
- <template #extra>
- <HcTooltip keys="system-service-plan-save-btn">
- <el-button
- class="ml-6"
- hc-btn
- keys="system-service-plan-save-btn"
- type="primary"
- :loading="saveLoading"
- @click="savePlan"
- >
- <HcIcon name="save" />
- 保存数据
- </el-button>
- </HcTooltip>
- <HcTooltip keys="system-service-plan-preview-btn">
- <el-button
- class="node-card-plan-btn ml-6"
- hc-btn
- keys="system-service-plan-preview-btn"
- color="#3F9EFF"
- >
- <HcIcon name="eye" />
- 预览
- </el-button>
- </HcTooltip>
- <HcTooltip keys="system-service-plan-send-btn">
- <el-button
- class="node-card-plan-btn ml-6"
- hc-btn
- keys="system-service-plan-send-btn"
- type="warning"
- @click="sendPlan"
- >
- <HcIcon name="send-plane" />
- 发送计划
- </el-button>
- </HcTooltip>
- <HcTooltip keys="system-service-plan-back-btn">
- <el-button
- class="node-card-plan-btn ml-6"
- hc-btn
- keys="system-service-plan-back-btn"
-
- type="warning"
- >
- <HcIcon name="arrow-go-back" />
- 计划回退
- </el-button>
- </HcTooltip>
- <HcTooltip keys="system-service-plan-comfirm-btn">
- <el-button
- class="node-card-plan-btn ml-6"
- hc-btn
- keys="system-service-plan-comfirm-btn"
-
- type="success"
- >
- <HcIcon name="check" />
- 确认计划
- </el-button>
- </HcTooltip>
- </template>
-
- <div class="hc-table-form-box">
- <HcTableForm
- ref="tableFormRef"
- :form="tableFormData"
- :html="excelHtmlData"
- :loading="loading"
- :pkey="excelIdVal"
- :disabled="!isTableForm"
- @render="tableFormRender"
- />
- </div>
- </hc-card>
- <!-- 选择任务人 -->
- <HcUserModal v-model="isUserModalShow" :data="userData" :datas="dataInfo" @finish="fixedUserFinish" />
- </hc-drawer>
- </template>
- <script setup>
- import { ref, watch } from 'vue'
- import { arrToKey, deepClone, isString } from 'js-fast-way'
- import HcUserModal from './hc-tasks-user/user-modal.vue'
- import { useAppStore } from '~src/store'
- import dataApi from '~api/systemService/service'
- //参数
- const props = defineProps({
- type: {
- type:[String, Number],
- default:'',
- },
- })
- const type = ref(props.type)
- const isShow = defineModel('modelValue', {
- default: false,
- })
- const tableFormRef = ref(null)
- const tableFormData = ref({})
- const excelHtmlData = ref('')
- const loading = ref(false)
- const excelIdVal = ref('')
- const isTableForm = ref(false)
- const useAppState = useAppStore()
- const projectId = ref(useAppState.getProjectId)
- const contractId = ref(useAppState.getContractId)
- watch(isShow, (val) => {
-
- })
- //监听
- watch(() => [
- props.type,
- ], ([val]) => {
- type.value = val
- if (val === 1) {
- excelIdVal.value = '1937773223861026820'
- } else {
- excelIdVal.value = '1937773223861026822'
- }
- if (val) getExcelHtml()
- })
- //获取模板标签数据
- const getExcelHtml = async () => {
- loading.value = true
- //获取数据
- const { error, code, data } = await dataApi.getServiceHtml({
- contractId: contractId.value || '',
- pkeyId: excelIdVal.value,
- projectId: projectId.value || '',
- }, false)
- loading.value = false
- //处理数据
- const resData = isString(data) ? data || '' : ''
-
- if (!error && code === 200 && resData) {
-
- excelHtmlData.value = resData
- } else {
- excelHtmlData.value = ''
- isTableForm.value = false
-
- }
-
- }
- //渲染表单完成
- const tableFormRender = (form) => {
- isTableForm.value = form.isRenderForm
- }
- const goBack = () => {
- isShow.value = false
- }
- const sendPlan = ()=>{
- isUserModalShow.value = true
- }
- const isUserModalShow = ref(false)
- const userData = ref([])
- const dataInfo = ref({
- projectId:projectId.value,
- contractId:contractId.value,
- })
- const fixedUserFinish = (data) => {
- const res = deepClone(data)
- console.log(res, 'res')
- userData.value = res
- const userIds = arrToKey(res, 'userId', ',')
- let userIdsArr = userIds.split(',')
-
- }
- //保存数据
- const saveLoading = ref(false)
- const savePlan = async ()=>{
- console.log( tableFormData.value, 'tableFormData.value')
-
- let objres = {
- ...tableFormData.value,
- projectId: projectId.value,
- contractId: contractId.value,
- pkeyId: excelIdVal.value,
-
- }
- saveLoading.value = true
- const { error, code, msg, data } = await dataApi.saveServiceData({
- dataInfo: objres,
-
- }, false)
- saveLoading.value = false
- if (!error && code === 200) {
-
- window?.$message?.success(msg)
-
- } else {
- saveLoading.value = false
-
-
- }
- }
- </script>
- <style scoped lang="scss">
- .node-card-plan-btn{
- color:white;
- }
- .hc-table-form-box{
- height: 100%;
- overflow-y: auto;
- overflow-x: auto;
-
- }
- </style>
|