2025-03-21 10:15:35 +08:00
< template >
< a -spin :spinning ="confirmLoading" >
< JFormContainer :disabled ="disabled" >
< template # detail >
< a -form ref = "formRef" class = "antd-modal-form" :labelCol ="labelCol" :wrapperCol ="wrapperCol"
2025-05-15 16:48:57 +08:00
name = "ConfigService2DirectiveForm" >
2025-07-15 08:39:29 +08:00
< a -row v-show ="!isEditMedia" >
2025-08-06 16:01:50 +08:00
< a -col :span ="12" v-show ="false" >
2025-04-30 10:49:49 +08:00
< a -form -item label = "分类标签" v -bind = " validateInfos.instructionTagId "
id = "ConfigServiceDirectiveForm-instructionTagId" name = "instructionTagId" >
2025-08-04 14:48:44 +08:00
< j -dict -select -tag v -model :value ="formData.instructionTagId" :orgCode ="mainOrgCode"
2025-08-07 16:24:07 +08:00
: dictCode = "`nu_config_service_instruction_tag,instruction_name,id,del_flag = 0 and iz_enabled = 0 order by sort asc`"
2025-07-23 08:39:10 +08:00
placeholder = "请选择分类标签" allowClear @ upDictCode = "upInstructionDictCode" : disabled = "!!formData.id" / >
2025-04-30 10:49:49 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
2025-08-06 16:01:50 +08:00
< a -col :span ="12" v-show ="false" >
2025-03-21 10:15:35 +08:00
< a -form -item label = "服务类别" v -bind = " validateInfos.categoryId " id = "ConfigServiceDirectiveForm-categoryId"
name = "categoryId" >
2025-07-23 08:39:10 +08:00
< j -dict -select -tag type = "list" v -model :value ="formData.categoryId" :disabled ="!!formData.id"
2025-08-04 14:48:44 +08:00
: orgCode = "mainOrgCode" : dictCode = "categoryDictCode" placeholder = "请选择服务类别" allow - clear
@ upDictCode = "upCategoryDictCode" / >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
2025-08-06 16:01:50 +08:00
< a -col :span ="12" v-show ="false" >
2025-03-21 10:15:35 +08:00
< a -form -item label = "服务类型" v -bind = " validateInfos.typeId " id = "ConfigServiceDirectiveForm-typeId"
name = "typeId" >
< j -dict -select -tag type = "list" v -model :value ="formData.typeId" :dictCode ="typeDictCode"
2025-08-04 14:48:44 +08:00
: orgCode = "mainOrgCode" : disabled = "!!formData.id" placeholder = "请选择服务类型" allowClear
@ upDictCode = "upTypeDictCode" / >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
2025-08-06 16:01:50 +08:00
< / a - c o l >
2025-03-21 10:15:35 +08:00
< a -col :span ="12" >
< a -form -item label = "服务指令名称" v -bind = " validateInfos.directiveName "
id = "ConfigServiceDirectiveForm-directiveName" name = "directiveName" >
2025-08-05 15:59:16 +08:00
< a -input v -model :value ="formData.directiveName" placeholder = "请输入服务指令名称" allow -clear :maxlength ="20"
: showCount = "true" : disabled = "!!formData.id" > < / a - i n p u t >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
< a -form -item label = "收费价格(元)" v -bind = " validateInfos.tollPrice " id = "ConfigServiceDirectiveForm-tollPrice"
name = "tollPrice" >
2025-08-06 16:01:50 +08:00
< a -input -number v -model :value ="formData.tollPrice" placeholder = "请输入收费价格" style = "width: 100%" :min ="0"
: max = "99999.99" : precision = "2" @ keydown = "onPriceKeydown" / >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
< a -form -item label = "提成价格(元)" v -bind = " validateInfos.comPrice " id = "ConfigServiceDirectiveForm-comPrice"
name = "comPrice" >
2025-08-06 16:01:50 +08:00
< a -input -number v -model :value ="formData.comPrice" placeholder = "请输入提成价格" style = "width: 100%" :min ="0"
: max = "99999.99" : precision = "2" @ keydown = "onPriceKeydown" / >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
2025-03-24 14:59:31 +08:00
< a -col :span ="12" >
2025-03-21 10:15:35 +08:00
< a -form -item label = "医保报销" v -bind = " validateInfos.izReimbursement "
id = "ConfigServiceDirectiveForm-izReimbursement" name = "izReimbursement" >
< j -dict -select -tag type = 'radio' v -model :value ="formData.izReimbursement" dictCode = "med_ins_reimb"
allowClear / >
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
< a -form -item label = "机构优惠" v -bind = " validateInfos.izPreferential "
id = "ConfigServiceDirectiveForm-izPreferential" name = "izPreferential" >
< j -dict -select -tag type = 'radio' v -model :value ="formData.izPreferential"
dictCode = "institutional_discount" allowClear / >
< / a - f o r m - i t e m >
2025-03-24 14:59:31 +08:00
< / a - c o l >
2025-03-21 10:15:35 +08:00
< a -col :span ="12" >
< a -form -item label = "周期类型" v -bind = " validateInfos.cycleType " id = "ConfigServiceDirectiveForm-cycleType"
name = "cycleType" >
< j -dict -select -tag type = "list" v -model :value ="formData.cycleType" dictCode = "period_type"
2025-07-23 08:39:10 +08:00
placeholder = "请选择周期类型" allowClear @ upDictCode = "upCycleTypeDictCode" : disabled = "!!formData.id" / >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
< a -form -item label = "服务时长(分钟)" v -bind = " validateInfos.serviceDuration "
id = "ConfigServiceDirectiveForm-serviceDuration" name = "serviceDuration" >
< a -input -number v -model :value ="formData.serviceDuration" :min ="5" :max ="55" :step ="5"
placeholder = "请输入服务时长(分钟)" allow - clear / >
< / a - f o r m - i t e m >
< / a - c o l >
< / a - r o w >
2025-07-15 08:39:29 +08:00
< a -row v-show ="!isEditMedia" >
2025-03-21 10:15:35 +08:00
< a -col :span ="24" >
2025-04-28 16:08:53 +08:00
< a -form -item label = "体型标签" id = "ConfigServiceDirectiveForm-typeId" :labelCol ="labelCol2"
2025-03-21 10:15:35 +08:00
: wrapperCol = "wrapperCol2" name = "typeId" >
2025-08-06 16:01:50 +08:00
< span v-if ="disabled && !formData.bodyTags" > - < / span >
< JCheckbox v -else v -model :value ="formData.bodyTags" :orgCode ="mainOrgCode" :dictCode ="bodyTagDictCode"
2025-07-16 08:34:10 +08:00
@ upDictCode = "upBodyTagsDictCode" / >
2025-04-28 16:08:53 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="24" >
< a -form -item label = "情绪标签" :labelCol ="labelCol2" :wrapperCol ="wrapperCol2" name = "emoTags" >
2025-08-06 16:01:50 +08:00
< span v-if ="disabled && !formData.emotionTags" > - < / span >
< JCheckbox v -else v -model :value ="formData.emotionTags" :orgCode ="mainOrgCode"
: dictCode = "emotionTagDictCode" @ upDictCode = "upEmotionTagsDictCode" / >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
< a -form -item label = "是否启用" v -bind = " validateInfos.izEnabled " id = "ConfigServiceDirectiveForm-izEnabled"
name = "izEnabled" >
2025-07-16 08:34:10 +08:00
< j -dict -select -tag type = 'radio' v -model :value ="formData.izEnabled" dictCode = "iz_enabled"
2025-03-21 10:15:35 +08:00
placeholder = "请选择是否启用" allowClear / >
< / a - f o r m - i t e m >
< / a - c o l >
< / a - r o w >
2025-07-23 08:39:10 +08:00
< a -row >
2025-08-04 14:48:44 +08:00
< a -col :span ="12" v-show ="showMedia" >
2025-07-15 08:39:29 +08:00
< a -form -item label = "服务指令图片" v-bind ="validateInfos.previewFile" >
2025-07-23 08:39:10 +08:00
< span v-if ="disabled && !formData.previewFile" > 暂无文件 < / span >
2025-08-08 09:33:27 +08:00
< JImageUpload v -else -if = " opeType = = ' dmlook ' " :fileMax ="1"
: value = "mediaApiAddress + formData.previewFile" >
< / JImageUpload >
< JImageUpload v -else :fileMax ="1" v -model :value ="formData.previewFile" > < / JImageUpload >
2025-04-01 09:35:36 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
2025-07-15 08:39:29 +08:00
< a -form -item label = "服务指令描述" v -bind = " validateInfos.serviceContent "
id = "ConfigServiceDirectiveForm-serviceContent" name = "serviceContent" >
2025-08-05 15:59:16 +08:00
< a -textarea v -model :value ="formData.serviceContent" :autosize ="true" placeholder = "请输入服务指令描述"
: maxlength = "200" : showCount = "true" / >
2025-04-01 09:35:36 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< / a - r o w >
2025-08-04 14:48:44 +08:00
< a -row v-show ="!disabled && showMedia" >
2025-03-21 10:15:35 +08:00
< a -col :span ="12" >
2025-07-15 08:39:29 +08:00
< a -form -item label = "指令音频文件" v-bind ="validateInfos.mp3File" id="ConfigServiceDirectiveForm-mp3File" >
2025-08-04 14:48:44 +08:00
< j -upload v -model :value ="formData.mp3File" accept = ".mp3" :maxCount ="1" > < / j - u p l o a d >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" >
2025-07-15 08:39:29 +08:00
< a -form -item label = "指令视频文件" v-bind ="validateInfos.mp4File" id="ConfigServiceDirectiveForm-mp4File" >
2025-08-04 14:48:44 +08:00
< j -upload v -model :value ="formData.mp4File" accept = ".mp4" :maxCount ="1" > < / j - u p l o a d >
2025-03-21 10:15:35 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
2025-07-23 08:39:10 +08:00
< / a - r o w >
2025-03-21 10:15:35 +08:00
< / a - f o r m >
< / template >
< / JFormContainer >
2025-08-04 14:48:44 +08:00
< JFormContainer style = "margin-top: -40px;" v-show ="showMedia" >
2025-03-21 10:15:35 +08:00
< template # detail >
< a -form ref = "formRef" class = "antd-modal-form" :labelCol ="labelCol" :wrapperCol ="wrapperCol"
name = "ConfigServiceDirectiveForm" >
< a -row >
2025-07-23 08:39:10 +08:00
< a -col :span ="12" v-if ="!!formData.mp3File" >
< a -form -item label = "指令音频预览" id = "ConfigServiceDirectiveForm-mp3File" >
< audio controls disabled = "false" >
2025-08-07 16:24:07 +08:00
< source
2025-08-08 09:33:27 +08:00
: src = "opeType == 'dmlook' ? mediaApiAddress + formData.mp3File : getFileAccessHttpUrl(formData.mp3File)" >
2025-03-21 10:15:35 +08:00
< / audio >
< / a - f o r m - i t e m >
< / a - c o l >
2025-07-23 08:39:10 +08:00
< a -col :span ="12" v-if ="disabled && !formData.mp3File" >
< a -form -item label = "指令音频预览" >
< span > 暂无文件 < / span >
< / a - f o r m - i t e m >
< / a - c o l >
< a -col :span ="12" v-if ="!!formData.mp4File" :push="!!formData.mp3File ? 0 : 12" >
< a -form -item label = "指令视频预览" id = "ConfigServiceDirectiveForm-mp4File" >
< video controls >
2025-08-07 16:24:07 +08:00
< source
2025-08-08 09:33:27 +08:00
: src = "opeType == 'dmlook' ? mediaApiAddress + formData.mp4File : getFileAccessHttpUrl(formData.mp4File)" >
2025-03-21 10:15:35 +08:00
< / video >
< / a - f o r m - i t e m >
< / a - c o l >
2025-07-23 08:39:10 +08:00
< a -col :span ="12" v-if ="disabled && !formData.mp3File" >
< a -form -item label = "指令视频预览" >
< span > 暂无文件 < / span >
< / a - f o r m - i t e m >
< / a - c o l >
2025-08-07 16:24:07 +08:00
< / a - r o w >
< a -row >
2025-07-15 08:39:29 +08:00
< a -col :span ="12" >
< a -form -item label = "即时指令图标" v-bind ="validateInfos.immediateFile" >
2025-07-23 08:39:10 +08:00
< span v-if ="disabled && !formData.immediateFile" > 暂无文件 < / span >
2025-08-08 09:33:27 +08:00
< JImageUpload v -else -if = " opeType = = ' dmlook ' " :fileMax ="1"
: value = "mediaApiAddress + formData.immediateFile" >
< / JImageUpload >
< JImageUpload v -else :fileMax ="1" v -model :value ="formData.immediateFile" > < / JImageUpload >
2025-07-15 08:39:29 +08:00
< / a - f o r m - i t e m >
< / a - c o l >
2025-03-21 10:15:35 +08:00
< / a - r o w >
< / a - f o r m >
< / template >
< / JFormContainer >
< / a - s p i n >
< / template >
< script lang = "ts" setup >
import { ref , reactive , defineExpose , nextTick , defineProps , computed , onMounted , watch } from 'vue' ;
import { defHttp } from '/@/utils/http/axios' ;
import { useMessage } from '/@/hooks/web/useMessage' ;
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue' ;
import { JCheckbox } from '/@/components/Form' ;
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue' ;
2025-04-01 09:35:36 +08:00
import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue' ;
2025-03-21 10:15:35 +08:00
import { getValueType } from '/@/utils' ;
2025-07-23 08:39:10 +08:00
import { saveOrUpdate , syncMediaForBiz , syncMediaForAllBiz } from '../ConfigServiceDirective.api' ;
2025-03-21 10:15:35 +08:00
import { Form } from 'ant-design-vue' ;
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue' ;
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils' ;
2025-08-07 16:24:07 +08:00
import { env } from 'process' ;
2025-04-01 09:35:36 +08:00
2025-08-06 16:01:50 +08:00
const onPriceKeydown = ( e : KeyboardEvent ) => {
const key = e . key ;
// 放行控制键
if ( [ 'Backspace' , 'Delete' , 'ArrowLeft' , 'ArrowRight' , 'Tab' ] . includes ( key ) ) return ;
// 只能输数字和点
if ( ! /[\d.]/ . test ( key ) ) {
e . preventDefault ( ) ;
return ;
}
const input = e . target as HTMLInputElement ;
const { value , selectionStart : s , selectionEnd : t } = input ;
const next = value . slice ( 0 , s ! ) + key + value . slice ( t ! ) ;
// 整数最多5位, 小数最多2位
if ( ! /^\d{0,5}(?:\.\d{0,2})?$/ . test ( next ) ) {
e . preventDefault ( ) ;
}
} ;
2025-03-21 10:15:35 +08:00
const props = defineProps ( {
formDisabled : { type : Boolean , default : false } ,
formData : { type : Object , default : ( ) => ( { } ) } ,
2025-05-27 14:14:07 +08:00
formBpm : { type : Boolean , default : true } ,
2025-08-04 14:48:44 +08:00
mainOrgCode : '' ,
2025-08-07 16:24:07 +08:00
mediaApiAddress : '' , //指令资源请求地址
2025-08-08 09:33:27 +08:00
opeType : 'look' ,
2025-03-21 10:15:35 +08:00
} ) ;
2025-08-08 09:33:27 +08:00
2025-08-06 16:01:50 +08:00
const bodyTagDictCode = ref ( ` nu_config_body_tag,tag_name,id,del_flag = 0 and iz_enabled = 0 order by sort asc ` )
const emotionTagDictCode = ref ( ` nu_config_emotion_tag,tag_name,id,del_flag = 0 and iz_enabled = 0 order by sort asc ` )
2025-03-21 10:15:35 +08:00
const formRef = ref ( ) ;
const useForm = Form . useForm ;
const emit = defineEmits ( [ 'register' , 'ok' ] ) ;
const formData = reactive < Record < string , any > > ( {
id : '' ,
categoryId : '' ,
typeId : '' ,
instructionTagId : '' ,
directiveName : '' ,
tollPrice : 0 ,
comPrice : 0 ,
izReimbursement : '0' ,
izPreferential : '0' ,
chargingFrequency : '' ,
cycleType : '' ,
sort : 99 ,
serviceContent : '' ,
serviceDuration : '5' ,
2025-07-16 08:34:10 +08:00
status : '' ,
izEnabled : '0' ,
2025-03-21 10:15:35 +08:00
createBy : '' ,
createTime : '' ,
updateBy : '' ,
updateTime : '' ,
mp3File : '' ,
mp4File : '' ,
2025-04-01 09:35:36 +08:00
previewFile : '' ,
immediateFile : '' ,
2025-03-21 10:15:35 +08:00
} ) ;
const { createMessage } = useMessage ( ) ;
const labelCol = ref < any > ( { xs : { span : 24 } , sm : { span : 6 } } ) ;
const wrapperCol = ref < any > ( { xs : { span : 24 } , sm : { span : 16 } } ) ;
const labelCol2 = ref < any > ( { xs : { span : 24 } , sm : { span : 3 } } ) ;
const wrapperCol2 = ref < any > ( { xs : { span : 24 } , sm : { span : 20 } } ) ;
const confirmLoading = ref < boolean > ( false ) ;
2025-07-15 08:39:29 +08:00
const isEditMedia = ref ( false )
2025-07-16 08:34:10 +08:00
const instructionTagName = ref ( '' )
const categoryName = ref ( '' )
const typeName = ref ( '' )
const cycleTypeName = ref ( '' )
2025-08-08 09:33:27 +08:00
const orgMediaPathAddress = ref ( '' ) //对应机构媒体资源静态访问路径
2025-03-21 10:15:35 +08:00
//表单验证
const validatorRules = reactive ( {
categoryId : [ { required : true , message : '请选择服务类别!' } , ] ,
typeId : [ { required : true , message : '请选择服务类型!' } , ] ,
instructionTagId : [ { required : true , message : '请选择分类标签!' } , ] ,
directiveName : [ { required : true , message : '请输入服务指令名称!' } , ] ,
tollPrice : [ { required : true , message : '请输入收费价格!' } , { pattern : /^(([0-9]*)|([0]\.\d{0,4}|[1-9][0-9]*\.\d{0,4}))$/ , message : '请输入正确的金额!' } , ] ,
comPrice : [ { required : false } , { pattern : /^(([0-9]*)|([0]\.\d{0,4}|[1-9][0-9]*\.\d{0,4}))$/ , message : '请输入正确的金额!' } , ] ,
izReimbursement : [ { required : true , message : '请选择是否参与医保报销!' } , ] ,
izPreferential : [ { required : true , message : '请选择是否参与机构优惠!' } , ] ,
// chargingFrequency: [{ required: true, message: '请选择收费频次!' },],
cycleType : [ { required : true , message : '请选择周期类型!' } , ] ,
// sort: [{ required: true, message: '请输入排序!' }, { pattern: /^\d+$/, message: '请输入正整数!' },],
serviceDuration : [
{ required : true , message : '请输入服务时长(分钟)!' } ,
{ pattern : /^\d+$/ , message : '请输入正整数!' } ,
{
validator : ( _ , value ) => {
if ( value % 5 !== 0 ) {
return Promise . reject ( '请输入5的倍数!' ) ;
}
return Promise . resolve ( ) ;
} ,
} ,
{
validator : ( _ , value ) => {
if ( value < 5 || value > 55 ) {
return Promise . reject ( '请输入5到55之间的值!' ) ;
}
return Promise . resolve ( ) ;
} ,
} ,
] ,
izEnabled : [ { required : true , message : '请选择是否启用!' } , ] ,
} ) ;
2025-08-06 16:01:50 +08:00
2025-03-21 10:15:35 +08:00
const { resetFields , validate , validateInfos } = useForm ( formData , validatorRules , { immediate : false } ) ;
// 表单禁用
const disabled = computed ( ( ) => {
if ( props . formBpm === true ) {
if ( props . formData . disabled === false ) {
return false ;
} else {
return true ;
}
}
return props . formDisabled ;
} ) ;
2025-07-15 08:39:29 +08:00
const categoryDictCode = ref ( '' )
2025-03-21 10:15:35 +08:00
const typeDictCode = ref ( '' )
2025-07-15 08:39:29 +08:00
// 计算属性:是否可以上传预览图片
const canUploadPreviewImage = computed ( ( ) => {
return formData . instructionTagId &&
formData . categoryId &&
formData . typeId &&
formData . directiveName &&
formData . cycleType ;
} ) ;
//分类标签名称
const instructionComDictCode = ref ( [ ] )
function upInstructionDictCode ( v _ ) {
instructionComDictCode . value = v _
}
//服务类别名称
const categoryComDictCode = ref ( [ ] )
function upCategoryDictCode ( v _ ) {
categoryComDictCode . value = v _
}
//服务类型名称
const typeComDictCode = ref ( [ ] )
function upTypeDictCode ( v _ ) {
typeComDictCode . value = v _
}
//周期类型名称
const cycleTypeComDictCode = ref ( [ ] )
function upCycleTypeDictCode ( v _ ) {
cycleTypeComDictCode . value = v _
}
2025-07-16 08:34:10 +08:00
//体型标签名称
const upBodyTagsComDictCode = ref ( [ ] )
function upBodyTagsDictCode ( v _ ) {
upBodyTagsComDictCode . value = v _
}
//情绪标签名称
const upEmotionTagsComDictCode = ref ( [ ] )
function upEmotionTagsDictCode ( v _ ) {
upEmotionTagsComDictCode . value = v _
}
2025-07-15 08:39:29 +08:00
2025-07-16 08:34:10 +08:00
watch ( [ instructionComDictCode , categoryComDictCode , typeComDictCode , cycleTypeComDictCode , upBodyTagsComDictCode , upEmotionTagsComDictCode ] , ( ) => {
// 当这些字典数据变化时,强制重新计算 formComputedData
2025-07-15 08:39:29 +08:00
} , { deep : true } ) ;
2025-07-16 08:34:10 +08:00
const bodyTagsObj = ref ( [ ] )
const emotionTagsObj = ref ( [ ] )
const formComputedData = computed ( ( ) => {
if ( ! canUploadPreviewImage . value ) return { } ;
2025-07-15 08:39:29 +08:00
// 获取各个字段的字典值
2025-07-16 08:34:10 +08:00
const instructionName = instructionComDictCode . value . find ( d => d . value == formData . instructionTagId ) ? . label || '' ;
const categoryName = categoryComDictCode . value . find ( d => d . value == formData . categoryId ) ? . label || '' ;
const typeName = typeComDictCode . value . find ( d => d . value == formData . typeId ) ? . label || '' ;
const cycleTypeName = cycleTypeComDictCode . value . find ( d => d . value == formData . cycleType ) ? . label || '' ;
2025-07-15 08:39:29 +08:00
2025-07-16 08:34:10 +08:00
// 处理标签
const processTags = ( tags , dict ) => {
if ( ! tags ) return [ ] ;
return tags . split ( ',' )
. map ( id => dict . find ( d => d . value === id ) )
. filter ( Boolean )
. map ( item => ( { id : item . value , label : item . label } ) ) ;
} ;
return {
2025-07-30 17:04:18 +08:00
mediaFileSavePath : ` directive/ ${ instructionName } / ${ categoryName } / ${ typeName } / ${ cycleTypeName } / ${ formData . directiveName } ` ,
2025-07-16 08:34:10 +08:00
instructionName ,
categoryName ,
typeName ,
cycleTypeName ,
bodyTagsObj : JSON . stringify ( processTags ( formData . bodyTags , upBodyTagsComDictCode . value ) ) ,
emotionTagsObj : JSON . stringify ( processTags ( formData . emotionTags , upEmotionTagsComDictCode . value ) )
} ;
2025-07-15 08:39:29 +08:00
} ) ;
2025-03-21 10:15:35 +08:00
2025-07-15 08:39:29 +08:00
watch (
( ) => formData . instructionTagId ,
( newInstructionTagId ) => {
2025-07-28 10:25:47 +08:00
if ( needWatch . value ) {
2025-07-15 08:39:29 +08:00
formData . categoryId = ''
formData . typeId = ''
2025-07-28 10:25:47 +08:00
formData . cycleType = ''
}
if ( ! newInstructionTagId ) {
2025-07-15 08:39:29 +08:00
categoryDictCode . value = 'nu_config_service_category,category_name,id,1=2' ;
} else {
2025-08-07 16:24:07 +08:00
categoryDictCode . value = ` nu_config_service_category,category_name,id,del_flag = 0 and iz_enabled = 0 and instruction_id = ' ${ newInstructionTagId } ' order by sort asc ` ;
2025-07-15 08:39:29 +08:00
}
}
) ;
2025-03-21 10:15:35 +08:00
watch (
( ) => formData . categoryId ,
( newCategoryId ) => {
2025-07-28 10:25:47 +08:00
if ( needWatch . value ) {
2025-07-15 08:39:29 +08:00
formData . typeId = ''
2025-07-28 10:25:47 +08:00
formData . cycleType = ''
}
if ( ! newCategoryId ) {
2025-08-07 16:24:07 +08:00
typeDictCode . value = 'nu_config_service_type,type_name,id,1=2' ;
2025-03-21 10:15:35 +08:00
} else {
2025-08-07 16:24:07 +08:00
typeDictCode . value = ` nu_config_service_type,type_name,id,del_flag = 0 and iz_enabled = 0 and category_id = ' ${ newCategoryId } ' order by sort asc ` ;
2025-03-21 10:15:35 +08:00
}
}
) ;
2025-07-28 10:25:47 +08:00
watch (
( ) => formData . typeId ,
( newTypeId ) => {
if ( needWatch . value ) {
formData . cycleType = ''
}
}
) ;
2025-03-21 10:15:35 +08:00
/ * *
* 新增
* /
function add ( ) {
edit ( { } ) ;
}
2025-07-28 10:25:47 +08:00
const needWatch = ref ( false )
2025-08-04 14:48:44 +08:00
const showMedia = ref ( true )
2025-03-21 10:15:35 +08:00
/ * *
* 编辑
2025-07-15 08:39:29 +08:00
* isEditMedia _是否为编辑指令资源 ( 隐藏业务字段 )
2025-03-21 10:15:35 +08:00
* /
2025-08-06 16:01:50 +08:00
function edit ( record , isEditMedia _ = false , showMedia _ = true , showExistTags = true ) {
2025-08-08 09:33:27 +08:00
setInterval ( ( ) => {
console . log ( 111 , props . opeType )
console . log ( 222 , props . mediaApiAddress )
console . log ( 333 , formData . previewFile )
} , 2000 )
2025-08-06 16:01:50 +08:00
if ( ! ! record . bodyTags && showExistTags ) {
// 将逗号分隔的字符串转换为 "id = 'id1' or id = 'id2'" 格式
const bodyTagConditions = record . bodyTags . split ( ',' )
. map ( id => ` id = ' ${ id } ' ` )
. join ( ' or ' ) ;
bodyTagDictCode . value = ` nu_config_body_tag,tag_name,id,del_flag = 0 and iz_enabled = 0 ` +
( bodyTagConditions ? ` and ( ${ bodyTagConditions } ) ` : '' ) +
` order by sort asc ` ;
}
if ( ! ! record . emotionTags && showExistTags ) {
// 将逗号分隔的字符串转换为 "id = 'id1' or id = 'id2'" 格式
const emotionTagConditions = record . emotionTags . split ( ',' )
. map ( id => ` id = ' ${ id } ' ` )
. join ( ' or ' ) ;
emotionTagDictCode . value = ` nu_config_emotion_tag,tag_name,id,del_flag = 0 and iz_enabled = 0 ` +
( emotionTagConditions ? ` and ( ${ emotionTagConditions } ) ` : '' ) +
` order by sort asc ` ;
}
2025-07-28 10:25:47 +08:00
needWatch . value = false
2025-08-04 14:48:44 +08:00
showMedia . value = showMedia _
2025-07-28 10:25:47 +08:00
setTimeout ( ( ) => {
needWatch . value = true
} , 1000 )
2025-07-15 08:39:29 +08:00
isEditMedia . value = isEditMedia _
2025-04-28 16:08:53 +08:00
formData . bodyTags = ''
formData . emotionTags = ''
2025-03-21 10:15:35 +08:00
nextTick ( ( ) => {
resetFields ( ) ;
const tmpData = { } ;
Object . keys ( formData ) . forEach ( ( key ) => {
if ( record . hasOwnProperty ( key ) ) {
tmpData [ key ] = record [ key ]
}
} )
//赋值
Object . assign ( formData , tmpData ) ;
} ) ;
}
/ * *
* 提交数据
* /
async function submitForm ( ) {
try {
// 触发表单验证
await validate ( ) ;
} catch ( { errorFields } ) {
if ( errorFields ) {
const firstField = errorFields [ 0 ] ;
if ( firstField ) {
formRef . value . scrollToField ( firstField . name , { behavior : 'smooth' , block : 'center' } ) ;
}
}
return Promise . reject ( errorFields ) ;
}
confirmLoading . value = true ;
const isUpdate = ref < boolean > ( false ) ;
//时间格式化
2025-07-16 08:34:10 +08:00
const computedData = formComputedData . value ;
const model = {
... formData ,
... computedData
} ;
2025-03-21 10:15:35 +08:00
if ( model . id ) {
isUpdate . value = true ;
}
//循环数据
for ( let data in model ) {
//如果该数据是数组并且是字符串类型
if ( model [ data ] instanceof Array ) {
let valueType = getValueType ( formRef . value . getProps , data ) ;
//如果是字符串类型的需要变成以逗号分割的字符串
if ( valueType === 'string' ) {
model [ data ] = model [ data ] . join ( ',' ) ;
}
}
}
2025-03-21 14:23:45 +08:00
//提成价格不能高于收费价格
2025-08-06 16:01:50 +08:00
if ( model . comPrice != 0 && model . tollPrice < model . comPrice ) {
2025-03-21 14:23:45 +08:00
createMessage . warning ( '提成价格不能高于收费价格!' ) ;
confirmLoading . value = false ;
2025-07-16 08:34:10 +08:00
return
2025-03-21 14:23:45 +08:00
}
2025-07-23 08:39:10 +08:00
model . mediaFileSavePath = formComputedData . value . mediaFileSavePath
2025-03-21 10:15:35 +08:00
await saveOrUpdate ( model , isUpdate . value )
. then ( ( res ) => {
if ( res . success ) {
createMessage . success ( res . message ) ;
emit ( 'ok' ) ;
} else {
createMessage . warning ( res . message ) ;
}
} )
. finally ( ( ) => {
confirmLoading . value = false ;
} ) ;
}
2025-07-23 08:39:10 +08:00
/ * *
* 同步媒体资源给指令所有者对应业务平台
*
* /
function syncMediaForBizFunc ( ) {
formData . mediaFileSavePath = formComputedData . value . mediaFileSavePath
syncMediaForBiz ( formData )
. then ( ( res ) => {
createMessage . success ( '操作成功!' ) ;
emit ( 'ok' ) ;
} )
. finally ( ( ) => {
confirmLoading . value = false ;
} ) ;
}
/ * *
* 同步媒体资源给所有业务平台
*
* /
function syncMediaForAllBizFunc ( ) {
formData . mediaFileSavePath = formComputedData . value . mediaFileSavePath
syncMediaForAllBiz ( formData )
. then ( ( res ) => {
createMessage . success ( '操作成功!' ) ;
emit ( 'ok' ) ;
} )
. finally ( ( ) => {
confirmLoading . value = false ;
} ) ;
}
2025-08-07 16:24:07 +08:00
onMounted ( ( ) => {
} )
2025-03-21 10:15:35 +08:00
defineExpose ( {
add ,
edit ,
submitForm ,
2025-07-23 08:39:10 +08:00
syncMediaForBizFunc ,
syncMediaForAllBizFunc
2025-03-21 10:15:35 +08:00
} ) ;
< / script >
< style lang = "less" scoped >
. antd - modal - form {
padding : 14 px ;
}
< / style >