From 8d91ee6e59a64623c2d717c26b0002c16d1d979d Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@shlanbao.cn> Date: 星期四, 21 十二月 2023 14:41:54 +0800 Subject: [PATCH] 添加药材信息 --- src/views/dry/api/DryHerbInfo.api.ts | 64 +++++ src/views/dry/sql/DryHerbInfo_menu_insert.sql | 26 ++ src/views/dry/DryHerbInfoList.vue | 177 ++++++++++++++++ src/views/dry/components/DryHerbInfoForm.vue | 70 ++++++ src/views/dry/components/DryHerbInfoModal.vue | 66 ++++++ src/views/dry/dataDefine/DryHerbInfo.data.ts | 226 ++++++++++++++++++++ 6 files changed, 629 insertions(+), 0 deletions(-) diff --git a/src/views/dry/DryHerbInfoList.vue b/src/views/dry/DryHerbInfoList.vue new file mode 100644 index 0000000..4c05f2b --- /dev/null +++ b/src/views/dry/DryHerbInfoList.vue @@ -0,0 +1,177 @@ +<template> + <div> + <!--寮曠敤琛ㄦ牸--> + <BasicTable @register="registerTable" :rowSelection="rowSelection"> + <!--鎻掓Ы:table鏍囬--> + <template #tableTitle> + <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 鏂板 </a-button> + <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 瀵煎嚭 </a-button> + <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls"> 瀵煎叆 </j-upload-button> + <a-dropdown v-if="selectedRowKeys.length > 0"> + <template #overlay> + <a-menu> + <a-menu-item key="1" @click="batchHandleDelete"> + <Icon icon="ant-design:delete-outlined" /> + 鍒犻櫎 + </a-menu-item> + </a-menu> + </template> + <a-button + >鎵归噺鎿嶄綔 + <Icon icon="mdi:chevron-down" /> + </a-button> + </a-dropdown> + </template> + <!--鎿嶄綔鏍�--> + <template #action="{ record }"> + <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> + </template> + <!--瀛楁鍥炴樉鎻掓Ы--> + <template #htmlSlot="{ text }"> + <div v-html="text"></div> + </template> + <!--鐪佸競鍖哄瓧娈靛洖鏄炬彃妲�--> + <template #pcaSlot="{ text }"> + {{ getAreaTextByCode(text) }} + </template> + <template #fileSlot="{ text }"> + <span v-if="!text" style="font-size: 12px; font-style: italic">鏃犳枃浠�</span> + <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">涓嬭浇 </a-button> + </template> + </BasicTable> + <!-- 琛ㄥ崟鍖哄煙 --> + <DryHerbInfoModal @register="registerModal" @success="handleSuccess" /> + </div> +</template> + +<script lang="ts" name="dry-dryHerbInfo" setup> + import { ref, computed, unref } from 'vue' + import { BasicTable, useTable, TableAction } from '/@/components/Table' + import { useModal } from '/@/components/Modal' + import { useListPage } from '/@/hooks/system/useListPage' + import DryHerbInfoModal from './components/DryHerbInfoModal.vue' + import { columns, searchFormSchema } from './dataDefine/DryHerbInfo.data' + import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './api/DryHerbInfo.api' + import { downloadFile } from '/@/utils/common/renderUtils' + + const checkedKeys = ref<Array<string | number>>([]) + //娉ㄥ唽model + const [registerModal, { openModal }] = useModal() + //娉ㄥ唽table鏁版嵁 + const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ + tableProps: { + title: 'dry_herb_info', + api: list, + columns, + canResize: false, + formConfig: { + //labelWidth: 120, + schemas: searchFormSchema, + autoSubmitOnEnter: true, + showAdvancedButton: true, + fieldMapToNumber: [], + fieldMapToTime: [], + }, + actionColumn: { + width: 120, + fixed: 'right', + }, + }, + exportConfig: { + name: 'dry_herb_info', + url: getExportUrl, + }, + importConfig: { + url: getImportUrl, + success: handleSuccess, + }, + }) + + const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext + + /** + * 鏂板浜嬩欢 + */ + function handleAdd() { + openModal(true, { + isUpdate: false, + showFooter: true, + }) + } + + /** + * 缂栬緫浜嬩欢 + */ + function handleEdit(record: Recordable) { + openModal(true, { + record, + isUpdate: true, + showFooter: true, + }) + } + + /** + * 璇︽儏 + */ + function handleDetail(record: Recordable) { + openModal(true, { + record, + isUpdate: true, + showFooter: false, + }) + } + + /** + * 鍒犻櫎浜嬩欢 + */ + async function handleDelete(record) { + await deleteOne({ id: record.id }, handleSuccess) + } + + /** + * 鎵归噺鍒犻櫎浜嬩欢 + */ + async function batchHandleDelete() { + await batchDelete({ ids: selectedRowKeys.value }, handleSuccess) + } + + /** + * 鎴愬姛鍥炶皟 + */ + function handleSuccess() { + ;(selectedRowKeys.value = []) && reload() + } + + /** + * 鎿嶄綔鏍� + */ + function getTableAction(record) { + return [ + { + label: '缂栬緫', + onClick: handleEdit.bind(null, record), + }, + ] + } + + /** + * 涓嬫媺鎿嶄綔鏍� + */ + function getDropDownAction(record) { + return [ + { + label: '璇︽儏', + onClick: handleDetail.bind(null, record), + }, + { + label: '鍒犻櫎', + popConfirm: { + title: '鏄惁纭鍒犻櫎', + confirm: handleDelete.bind(null, record), + }, + }, + ] + } +</script> + +<style scoped></style> diff --git a/src/views/dry/api/DryHerbInfo.api.ts b/src/views/dry/api/DryHerbInfo.api.ts new file mode 100644 index 0000000..e593f94 --- /dev/null +++ b/src/views/dry/api/DryHerbInfo.api.ts @@ -0,0 +1,64 @@ +import {defHttp} from '/@/utils/http/axios'; +import { useMessage } from "/@/hooks/web/useMessage"; + +const { createConfirm } = useMessage(); + +enum Api { + list = '/dry/dryHerbInfo/list', + save='/dry/dryHerbInfo/add', + edit='/dry/dryHerbInfo/edit', + deleteOne = '/dry/dryHerbInfo/delete', + deleteBatch = '/dry/dryHerbInfo/deleteBatch', + importExcel = '/dry/dryHerbInfo/importExcel', + exportXls = '/dry/dryHerbInfo/exportXls', +} +/** + * 瀵煎嚭api + * @param params + */ +export const getExportUrl = Api.exportXls; +/** + * 瀵煎叆api + */ +export const getImportUrl = Api.importExcel; +/** + * 鍒楄〃鎺ュ彛 + * @param params + */ +export const list = (params) => + defHttp.get({url: Api.list, params}); + +/** + * 鍒犻櫎鍗曚釜 + */ +export const deleteOne = (params,handleSuccess) => { + return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); +} +/** + * 鎵归噺鍒犻櫎 + * @param params + */ +export const batchDelete = (params, handleSuccess) => { + createConfirm({ + iconType: 'warning', + title: '纭鍒犻櫎', + content: '鏄惁鍒犻櫎閫変腑鏁版嵁', + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { + handleSuccess(); + }); + } + }); +} +/** + * 淇濆瓨鎴栬�呮洿鏂� + * @param params + */ +export const saveOrUpdate = (params, isUpdate) => { + let url = isUpdate ? Api.edit : Api.save; + return defHttp.post({url: url, params}); +} diff --git a/src/views/dry/components/DryHerbInfoForm.vue b/src/views/dry/components/DryHerbInfoForm.vue new file mode 100644 index 0000000..ce0bee9 --- /dev/null +++ b/src/views/dry/components/DryHerbInfoForm.vue @@ -0,0 +1,70 @@ +<template> + <div style="min-height: 400px"> + <BasicForm @register="registerForm" /> + <div style="width: 100%; text-align: center" v-if="!formDisabled"> + <a-button @click="submitForm" pre-icon="ant-design:check" type="primary">鎻� 浜�</a-button> + </div> + </div> +</template> + +<script lang="ts"> + import { BasicForm, useForm } from '/@/components/Form/index' + import { computed, defineComponent } from 'vue' + import { defHttp } from '/@/utils/http/axios' + import { propTypes } from '/@/utils/propTypes' + import { getBpmFormSchema } from '../dataDefine/DryHerbInfo.data' + import { saveOrUpdate } from '../api/DryHerbInfo.api' + + export default defineComponent({ + name: 'DryHerbInfoForm', + components: { + BasicForm, + }, + props: { + formData: propTypes.object.def({}), + formBpm: propTypes.bool.def(true), + }, + setup(props) { + const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({ + labelWidth: 150, + schemas: getBpmFormSchema(props.formData), + showActionButtonGroup: false, + baseColProps: { span: 24 }, + }) + + const formDisabled = computed(() => { + if (props.formData.disabled === false) { + return false + } + return true + }) + + let formData = {} + const queryByIdUrl = '/dry/dryHerbInfo/queryById' + async function initFormData() { + let params = { id: props.formData.dataId } + const data = await defHttp.get({ url: queryByIdUrl, params }) + formData = { ...data } + //璁剧疆琛ㄥ崟鐨勫�� + await setFieldsValue(formData) + //榛樿鏄鐢� + await setProps({ disabled: formDisabled.value }) + } + + async function submitForm() { + let data = getFieldsValue() + let params = Object.assign({}, formData, data) + console.log('琛ㄥ崟鏁版嵁', params) + await saveOrUpdate(params, true) + } + + initFormData() + + return { + registerForm, + formDisabled, + submitForm, + } + }, + }) +</script> diff --git a/src/views/dry/components/DryHerbInfoModal.vue b/src/views/dry/components/DryHerbInfoModal.vue new file mode 100644 index 0000000..5d75f49 --- /dev/null +++ b/src/views/dry/components/DryHerbInfoModal.vue @@ -0,0 +1,66 @@ +<template> + <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> + <BasicForm @register="registerForm" /> + </BasicModal> +</template> + +<script lang="ts" setup> + import { ref, computed, unref } from 'vue' + import { BasicModal, useModalInner } from '/@/components/Modal' + import { BasicForm, useForm } from '/@/components/Form/index' + import { formSchema } from '../dataDefine/DryHerbInfo.data' + import { saveOrUpdate } from '../api/DryHerbInfo.api' + // Emits澹版槑 + const emit = defineEmits(['register', 'success']) + const isUpdate = ref(true) + //琛ㄥ崟閰嶇疆 + const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({ + //labelWidth: 150, + schemas: formSchema, + showActionButtonGroup: false, + baseColProps: { span: 24 }, + }) + //琛ㄥ崟璧嬪�� + const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { + //閲嶇疆琛ㄥ崟 + await resetFields() + setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter }) + isUpdate.value = !!data?.isUpdate + if (unref(isUpdate)) { + //琛ㄥ崟璧嬪�� + await setFieldsValue({ + ...data.record, + }) + } + // 闅愯棌搴曢儴鏃剁鐢ㄦ暣涓〃鍗� + setProps({ disabled: !data?.showFooter }) + }) + //璁剧疆鏍囬 + const title = computed(() => (!unref(isUpdate) ? '鏂板' : '缂栬緫')) + //琛ㄥ崟鎻愪氦浜嬩欢 + async function handleSubmit(v) { + try { + let values = await validate() + setModalProps({ confirmLoading: true }) + //鎻愪氦琛ㄥ崟 + await saveOrUpdate(values, isUpdate.value) + //鍏抽棴寮圭獥 + closeModal() + //鍒锋柊鍒楄〃 + emit('success') + } finally { + setModalProps({ confirmLoading: false }) + } + } +</script> + +<style lang="less" scoped> + /** 鏃堕棿鍜屾暟瀛楄緭鍏ユ鏍峰紡 */ + :deep(.ant-input-number) { + width: 100%; + } + + :deep(.ant-calendar-picker) { + width: 100%; + } +</style> diff --git a/src/views/dry/dataDefine/DryHerbInfo.data.ts b/src/views/dry/dataDefine/DryHerbInfo.data.ts new file mode 100644 index 0000000..d34afa8 --- /dev/null +++ b/src/views/dry/dataDefine/DryHerbInfo.data.ts @@ -0,0 +1,226 @@ +import {BasicColumn} from '/@/components/Table'; +import {FormSchema} from '/@/components/Table'; + +//鍒楄〃鏁版嵁 +export const columns: BasicColumn[] = [ + { + title: '涓嵂鍚�', + align:"center", + dataIndex: 'name' + }, + { + title: '鎷奸煶', + align:"center", + dataIndex: 'pinyin' + }, + { + title: '鍒悕', + align:"center", + dataIndex: 'alias' + }, + { + title: '鑻辨枃鍚�', + align:"center", + dataIndex: 'english' + }, + { + title: '鑽敤閮ㄤ綅', + align:"center", + dataIndex: 'parts' + }, + { + title: '妞嶇墿褰㈡��', + align:"center", + dataIndex: 'morphology' + }, + { + title: '浜у湴鍒嗗竷', + align:"center", + dataIndex: 'origin' + }, + { + title: '閲囨敹鍔犲伐', + align:"center", + dataIndex: 'harvest' + }, + { + title: '鑽潗鎬х姸', + align:"center", + dataIndex: 'characterDrug' + }, + { + title: '鎬у懗褰掔粡', + align:"center", + dataIndex: 'famt' + }, + { + title: '鍔熸晥涓庝綔鐢�', + align:"center", + dataIndex: 'efficacy' + }, + { + title: '涓村簥搴旂敤', + align:"center", + dataIndex: 'clinical' + }, + { + title: '鑽悊鐮旂┒', + align:"center", + dataIndex: 'pharmacological' + }, + { + title: '涓昏鎴愬垎', + align:"center", + dataIndex: 'bases' + }, + { + title: '浣跨敤绂佸繉', + align:"center", + dataIndex: 'usageTaboo' + }, + { + title: '绉熸埛id', + align:"center", + dataIndex: 'tenantId' + }, +]; +//鏌ヨ鏁版嵁 +export const searchFormSchema: FormSchema[] = [ + { + label: "涓嵂鍚�", + field: 'name', + component: 'JInput', + colProps: {span: 6}, + }, + { + label: "鎷奸煶", + field: 'pinyin', + component: 'JInput', + colProps: {span: 6}, + }, + { + label: "鍒悕", + field: 'alias', + component: 'JInput', + colProps: {span: 6}, + }, + { + label: "鑻辨枃鍚�", + field: 'english', + component: 'JInput', + colProps: {span: 6}, + }, + { + label: "浜у湴鍒嗗竷", + field: 'origin', + component: 'JInput', + colProps: {span: 6}, + }, + { + label: "鍔熸晥涓庝綔鐢�", + field: 'efficacy', + component: 'JInput', + colProps: {span: 6}, + }, +]; +//琛ㄥ崟鏁版嵁 +export const formSchema: FormSchema[] = [ + { + label: '涓嵂鍚�', + field: 'name', + component: 'Input', + }, + { + label: '鎷奸煶', + field: 'pinyin', + component: 'Input', + }, + { + label: '鍒悕', + field: 'alias', + component: 'Input', + }, + { + label: '鑻辨枃鍚�', + field: 'english', + component: 'Input', + }, + { + label: '鑽敤閮ㄤ綅', + field: 'parts', + component: 'Input', + }, + { + label: '妞嶇墿褰㈡��', + field: 'morphology', + component: 'Input', + }, + { + label: '浜у湴鍒嗗竷', + field: 'origin', + component: 'Input', + }, + { + label: '閲囨敹鍔犲伐', + field: 'harvest', + component: 'Input', + }, + { + label: '鑽潗鎬х姸', + field: 'characterDrug', + component: 'Input', + }, + { + label: '鎬у懗褰掔粡', + field: 'famt', + component: 'Input', + }, + { + label: '鍔熸晥涓庝綔鐢�', + field: 'efficacy', + component: 'Input', + }, + { + label: '涓村簥搴旂敤', + field: 'clinical', + component: 'Input', + }, + { + label: '鑽悊鐮旂┒', + field: 'pharmacological', + component: 'Input', + }, + { + label: '涓昏鎴愬垎', + field: 'bases', + component: 'Input', + }, + { + label: '浣跨敤绂佸繉', + field: 'usageTaboo', + component: 'Input', + }, + { + label: '绉熸埛id', + field: 'tenantId', + component: 'InputNumber', + }, + // TODO 涓婚敭闅愯棌瀛楁锛岀洰鍓嶅啓姝讳负ID + { + label: '', + field: 'id', + component: 'Input', + show: false + }, +]; + + + +/** +* 娴佺▼琛ㄥ崟璋冪敤杩欎釜鏂规硶鑾峰彇formSchema +* @param param +*/ +export function getBpmFormSchema(_formData): FormSchema[]{ + // 榛樿鍜屽師濮嬭〃鍗曚繚鎸佷竴鑷� 濡傛灉娴佺▼涓厤缃簡鏉冮檺鏁版嵁锛岃繖閲岄渶瑕佸崟鐙鐞唂ormSchema + return formSchema; +} diff --git a/src/views/dry/sql/DryHerbInfo_menu_insert.sql b/src/views/dry/sql/DryHerbInfo_menu_insert.sql new file mode 100644 index 0000000..8c75804 --- /dev/null +++ b/src/views/dry/sql/DryHerbInfo_menu_insert.sql @@ -0,0 +1,26 @@ +-- 娉ㄦ剰锛氳椤甸潰瀵瑰簲鐨勫墠鍙扮洰褰曚负views/dry鏂囦欢澶逛笅 +-- 濡傛灉浣犳兂鏇存敼鍒板叾浠栫洰褰曪紝璇蜂慨鏀箂ql涓璫omponent瀛楁瀵瑰簲鐨勫�� + + +INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external) +VALUES ('2023122112489900070', NULL, 'dry_herb_info', '/dry/dryHerbInfoList', 'dry/DryHerbInfoList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0); + +-- 鏉冮檺鎺у埗sql +-- 鏂板 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023122112489900071', '2023122112489900070', '娣诲姞dry_herb_info', NULL, NULL, 0, NULL, NULL, 2, 'dry:dry_herb_info:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0, 0, '1', 0); +-- 缂栬緫 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023122112489900072', '2023122112489900070', '缂栬緫dry_herb_info', NULL, NULL, 0, NULL, NULL, 2, 'dry:dry_herb_info:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0, 0, '1', 0); +-- 鍒犻櫎 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023122112489900073', '2023122112489900070', '鍒犻櫎dry_herb_info', NULL, NULL, 0, NULL, NULL, 2, 'dry:dry_herb_info:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0, 0, '1', 0); +-- 鎵归噺鍒犻櫎 +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023122112489900074', '2023122112489900070', '鎵归噺鍒犻櫎dry_herb_info', NULL, NULL, 0, NULL, NULL, 2, 'dry:dry_herb_info:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0, 0, '1', 0); +-- 瀵煎嚭excel +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023122112489900075', '2023122112489900070', '瀵煎嚭excel_dry_herb_info', NULL, NULL, 0, NULL, NULL, 2, 'dry:dry_herb_info:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0, 0, '1', 0); +-- 瀵煎叆excel +INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external) +VALUES ('2023122112489900076', '2023122112489900070', '瀵煎叆excel_dry_herb_info', NULL, NULL, 0, NULL, NULL, 2, 'dry:dry_herb_info:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2023-12-21 12:48:07', NULL, NULL, 0, 0, '1', 0); \ No newline at end of file -- Gitblit v1.9.3