|
@@ -3,9 +3,13 @@
|
|
|
<div class="detail-header">
|
|
|
<div class="d-title">
|
|
|
<span>服务信息</span>
|
|
|
+ <span v-if="route.params.type==='add'">新增</span>
|
|
|
+ <span v-else-if="route.params.type==='detail'">详情</span>
|
|
|
+ <span v-else-if="route.params.type==='edit'">编辑</span>
|
|
|
</div>
|
|
|
<div class="d-btns">
|
|
|
- <el-button class="btn-default primary" type="primary">保存</el-button>
|
|
|
+ <el-button class="btn-default primary" type="primary" v-if="route.params.type==='add'" @click="handleSave()">发布</el-button>
|
|
|
+ <el-button class="btn-default primary" type="primary" v-if="route.params.type==='edit'" @click="handleSave()">保存</el-button>
|
|
|
<el-button class="btn-default" @click="handleClose">关闭</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -92,7 +96,48 @@ function handleClose() {
|
|
|
name: route.name.slice(0,-6)
|
|
|
})
|
|
|
}
|
|
|
+const basicInfo = ref(null)
|
|
|
+const extentInfo = ref(null)
|
|
|
|
|
|
+function handleSave() {
|
|
|
+ Promise.all([basicInfo.value.validateForm(), extentInfo.value.validateForm()]).then(valid => {
|
|
|
+ if(valid.findIndex(val => val===false)===-1) {
|
|
|
+ // 校验通过
|
|
|
+ let pForm={}
|
|
|
+ ServicePublishEdit(pForm, tableData.value).then(res => {
|
|
|
+ if(res.code=='200'&&res.msg==='修改成功') {
|
|
|
+ ElMessage({type:'success', message: '修改成功'})
|
|
|
+ handleClose()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 新增
|
|
|
+ ServicePublishAdd(pForm, tableData.value).then(res => {
|
|
|
+ if(res.code=='200'&&res.msg==='新增成功') {
|
|
|
+ ElMessage({type:'success', message: '新增成功'})
|
|
|
+ handleClose()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+onBeforeMount(()=> {
|
|
|
+ if(route.params.type!=='add') {
|
|
|
+ ServicePublishDetail(route.params.id).then(res => {
|
|
|
+ if(res.code=='200'&&res.msg==='查询成功') {
|
|
|
+ form.basicInfo.forEach(i => {
|
|
|
+ i.value = res.data
|
|
|
+ })
|
|
|
+ form.extentInfo.forEach(i => {
|
|
|
+ i.value = res.data
|
|
|
+ })
|
|
|
+ tableData.value = res.data.tDataItems
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|