|
@@ -0,0 +1,142 @@
|
|
|
+<!-- 新增 -->
|
|
|
+<template>
|
|
|
+ <div class="">
|
|
|
+ <el-dropdown @command="handleCommand">
|
|
|
+ <el-button type="primary">新增<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
|
|
+ </el-button>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <el-dropdown-item :icon="CircleCheck" command="a">药品信息管理</el-dropdown-item>
|
|
|
+ <el-dropdown-item :icon="CircleCheck" command="b">规格</el-dropdown-item>
|
|
|
+ <el-dropdown-item :icon="CircleCheck" command="c">剂型</el-dropdown-item>
|
|
|
+ <el-dropdown-item :icon="CircleCheck" command="d">单位</el-dropdown-item>
|
|
|
+ <el-dropdown-item :icon="CircleCheck" command="e">品种</el-dropdown-item>
|
|
|
+ <el-dropdown-item :icon="CircleCheck" command="f">生产企业</el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+
|
|
|
+ <el-dialog v-model="dialogFormVisible" title="新增药品信息管理" draggable :append-to-body="true">
|
|
|
+ <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules">
|
|
|
+ <el-form-item label="数据类型" :label-width="formLabelWidth" prop="type">
|
|
|
+ <el-select v-model="ruleForm.type" placeholder="请选择数据类型">
|
|
|
+ <el-option label="Zone No.1" value="shanghai" />
|
|
|
+ <el-option label="Zone No.2" value="beijing" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="标签名称" :label-width="formLabelWidth" prop="text">
|
|
|
+ <el-input v-model="ruleForm.text" autocomplete="off" placeholder="请输入标签名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="列宽" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="ruleForm.width" autocomplete="off" placeholder="请输入列宽" >
|
|
|
+ <template #append>px</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序" :label-width="formLabelWidth">
|
|
|
+ <el-input v-model="ruleForm.sort" autocomplete="off" placeholder="请输入排序" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="表格展示" :label-width="formLabelWidth">
|
|
|
+ <el-radio-group v-model="ruleForm.show">
|
|
|
+ <el-radio label="1">显示</el-radio>
|
|
|
+ <el-radio label="2">隐藏</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="描述" :label-width="formLabelWidth" placeholder="请输入描述">
|
|
|
+ <el-input v-model="ruleForm.name" type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="dialogFormVisible = false">Cancel</el-button>
|
|
|
+ <el-button type="primary" @click="submitForm(ruleFormRef)">
|
|
|
+ Confirm
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="ts">
|
|
|
+import { CircleCheck } from '@element-plus/icons-vue'
|
|
|
+import { newDataFun, showDialog } from "@/plugins/newData";
|
|
|
+import type { FormInstance, FormRules,ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { reactive, ref } from 'vue'
|
|
|
+import {
|
|
|
+ medicineAdd,//药品信息管理添加
|
|
|
+} from "@/api";
|
|
|
+
|
|
|
+interface RuleForm {
|
|
|
+ type: string
|
|
|
+ text: string
|
|
|
+ width: string
|
|
|
+ sort: string
|
|
|
+ show: string
|
|
|
+ name: string
|
|
|
+}
|
|
|
+
|
|
|
+const ruleFormRef = ref<FormInstance>()
|
|
|
+const dialogFormVisible = ref(false)
|
|
|
+const formLabelWidth = '80px'
|
|
|
+
|
|
|
+const ruleForm = reactive<RuleForm>({
|
|
|
+ "type": '',
|
|
|
+ "text": "",
|
|
|
+ "width": '',
|
|
|
+ "sort": '',
|
|
|
+ "show": '1',
|
|
|
+ "name": ""
|
|
|
+})
|
|
|
+
|
|
|
+const rules = reactive<FormRules<RuleForm>>({
|
|
|
+ type: [{ required: true, message: '请选择数据类型', trigger: 'change', }],
|
|
|
+ text: [{ required: true, message: '请输入标签名称', trigger: 'blur' }],
|
|
|
+})
|
|
|
+
|
|
|
+const handleCommand = (command: string | number | object) => {
|
|
|
+ console.log('command', command)
|
|
|
+ if(command=='a'){
|
|
|
+ dialogFormVisible.value = true
|
|
|
+ }else{
|
|
|
+ otherFun(command)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//函数
|
|
|
+const otherFun = async (command:any) => {
|
|
|
+ ElMessageBox.prompt(`新增${showDialog(command)},请填写正确格式`, '新增', {
|
|
|
+ confirmButtonText: 'OK',
|
|
|
+ cancelButtonText: 'Cancel',
|
|
|
+ inputPattern: /\S/,
|
|
|
+ inputErrorMessage: `[${showDialog(command)}]名称格式不能为空`,
|
|
|
+ }).then(({ value }) => {
|
|
|
+ console.log('值',value)
|
|
|
+ }).catch(() => {
|
|
|
+ ElMessage.info('已取消新增'+showDialog(command))
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 提交dio
|
|
|
+ * @param formEl
|
|
|
+ */
|
|
|
+const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ await formEl.validate(async(valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ const reslut = await medicineAdd(ruleForm)
|
|
|
+ console.log('添加情况',reslut)
|
|
|
+ } else {
|
|
|
+ console.log('error submit!', fields)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+</script>
|
|
|
+<style lang="scss">
|
|
|
+/* @import url(); 引入css类 */
|
|
|
+</style>
|