|
@@ -0,0 +1,282 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import {
|
|
|
+ deleteMzSupplyType,
|
|
|
+ getSupplyClass,
|
|
|
+ insertMzSupplyType,
|
|
|
+ selectAllMzSupplyType,
|
|
|
+ updateMzSupplyType,
|
|
|
+ MzZdSupplyType,
|
|
|
+} from "@/api/orderZdMaintain";
|
|
|
+import XcElOption from "@/components/xiao-chan/xc-el-option/XcElOption.vue";
|
|
|
+import XEUtils from "xe-utils";
|
|
|
+import { VxeTablePropTypes } from "vxe-table";
|
|
|
+import { useVxeTableRef } from "@/utils/useCompRef";
|
|
|
+import { xcMessage } from "@/utils/xiaochan-element-plus";
|
|
|
+import { getPyCode } from "@/api/inpatient/xiang-mu-lu-ru";
|
|
|
+import { useDialog } from "@/components/cy/CyDialog/index";
|
|
|
+import BindChargeDialog from "./BindChargeDialog.vue";
|
|
|
+
|
|
|
+const store = reactive({
|
|
|
+ supplyClass: [],
|
|
|
+ data: [],
|
|
|
+ search: "",
|
|
|
+ supplyChild: [],
|
|
|
+});
|
|
|
+
|
|
|
+const tryFlags = [
|
|
|
+ { code: "1", name: "皮试" },
|
|
|
+ { code: "2", name: "免试" },
|
|
|
+];
|
|
|
+
|
|
|
+const tableRef = useVxeTableRef<MzZdSupplyType>();
|
|
|
+
|
|
|
+function rulesContent(value, maxLength, empty = false) {
|
|
|
+ if (XEUtils.charLength(value, maxLength, empty)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ return new Error(`共${maxLength}个字符,中文算两个`);
|
|
|
+}
|
|
|
+
|
|
|
+const validRules: VxeTablePropTypes.EditRules<MzZdSupplyType> = {
|
|
|
+ supplyName: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ content: "必须填写",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ validator: ({ row }) => {
|
|
|
+ return rulesContent(row.supplyName, 40);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ printName: [
|
|
|
+ {
|
|
|
+ validator: ({ row }) => {
|
|
|
+ return rulesContent(row.printName, 40, true);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ pyCode: [
|
|
|
+ {
|
|
|
+ validator: ({ row }) => {
|
|
|
+ return rulesContent(row.pyCode, 8, true);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ dcode: [
|
|
|
+ {
|
|
|
+ validator: ({ row }) => {
|
|
|
+ return rulesContent(row.dcode, 8, true);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+};
|
|
|
+
|
|
|
+async function handleGetData() {
|
|
|
+ store.data = await selectAllMzSupplyType().catch(() => []);
|
|
|
+ store.supplyChild = store.data.map(item => {
|
|
|
+ item.tryFlagName = findSelectName(item.tryFlag, tryFlags);
|
|
|
+ return {
|
|
|
+ code: item.supplyCode,
|
|
|
+ name: item.supplyName,
|
|
|
+ };
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function findSelectName(value, data) {
|
|
|
+ const find = XEUtils.find(data, i => {
|
|
|
+ return i.code === value;
|
|
|
+ });
|
|
|
+
|
|
|
+ if (find) {
|
|
|
+ return find.name;
|
|
|
+ }
|
|
|
+
|
|
|
+ return "";
|
|
|
+}
|
|
|
+
|
|
|
+async function handleAdd() {
|
|
|
+ const { row } = await tableRef.value.insertAt({
|
|
|
+ supplyName: "",
|
|
|
+ classCode: 1,
|
|
|
+ } as MzZdSupplyType);
|
|
|
+ await tableRef.value.setEditRow(row, "supplyName");
|
|
|
+ await tableRef.value.scrollToRow(row, "supplyName");
|
|
|
+}
|
|
|
+
|
|
|
+async function handleSave() {
|
|
|
+ const errMap = await tableRef.value.validate(false);
|
|
|
+ if (errMap) {
|
|
|
+ xcMessage.error("请检查错误位置");
|
|
|
+ }
|
|
|
+
|
|
|
+ const insert = tableRef.value.getInsertRecords();
|
|
|
+ const update = tableRef.value.getUpdateRecords();
|
|
|
+
|
|
|
+ insert.forEach(item => {
|
|
|
+ insertMzSupplyType(item).catch(res => {});
|
|
|
+ });
|
|
|
+
|
|
|
+ update.forEach(item => {
|
|
|
+ updateMzSupplyType(item).catch(res => {});
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function handleGetPyDode(row) {
|
|
|
+ getPyCode(row.supplyName).then(res => {
|
|
|
+ row.pyCode = res.pyCode;
|
|
|
+ row.dcode = res.wbCode;
|
|
|
+ });
|
|
|
+ row.printName = row.supplyName;
|
|
|
+}
|
|
|
+
|
|
|
+function handleDel(row, value) {
|
|
|
+ let del = "0";
|
|
|
+ if (value) {
|
|
|
+ del = "1";
|
|
|
+ }
|
|
|
+ deleteMzSupplyType(row.supplyCode, del).then(() => {
|
|
|
+ row.delFlag = del;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function handleOpenCharge(code) {
|
|
|
+ useDialog(BindChargeDialog, {
|
|
|
+ params: {
|
|
|
+ code,
|
|
|
+ },
|
|
|
+ dialogProps: {
|
|
|
+ title: "绑定费用",
|
|
|
+ },
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getSupplyClass('mz').then(res => {
|
|
|
+ store.supplyClass = res;
|
|
|
+ });
|
|
|
+ handleGetData();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="layout_container">
|
|
|
+ <header>
|
|
|
+ <el-input v-model="store.search" style="width: 220px" clearable />
|
|
|
+ <el-button @click="handleAdd">新增</el-button>
|
|
|
+ <el-button @click="handleSave">保存</el-button>
|
|
|
+ <el-divider direction="vertical" />
|
|
|
+ <el-button @click="handleGetData">重置</el-button>
|
|
|
+ </header>
|
|
|
+ <div class="layout_main">
|
|
|
+ <vxe-table
|
|
|
+ ref="tableRef"
|
|
|
+ keep-source
|
|
|
+ height="100%"
|
|
|
+ :data="store.data"
|
|
|
+ :edit-rules="validRules"
|
|
|
+ :edit-config="{
|
|
|
+ mode: 'row',
|
|
|
+ trigger: 'click',
|
|
|
+ autoClear: false,
|
|
|
+ showStatus: true,
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <vxe-column field="delFlag" title="停用" width="50">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-checkbox
|
|
|
+ :model-value="row.delFlag === '1'"
|
|
|
+ @update:modelValue="
|
|
|
+ value => {
|
|
|
+ handleDel(row, value);
|
|
|
+ }
|
|
|
+ "
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+ <vxe-column field="supplyCode" title="编码" width="100" />
|
|
|
+ <vxe-column
|
|
|
+ field="supplyName"
|
|
|
+ title="名称"
|
|
|
+ width="200"
|
|
|
+ :edit-render="{}"
|
|
|
+ >
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-input v-model="row.supplyName" @blur="handleGetPyDode(row)" />
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+ <vxe-column
|
|
|
+ field="className"
|
|
|
+ title="分类"
|
|
|
+ width="100"
|
|
|
+ :edit-render="{}"
|
|
|
+ >
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-select v-model="row.classCode">
|
|
|
+ <xc-el-option :data="store.supplyClass" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+
|
|
|
+ <vxe-column field="printName" title="打印名" :edit-render="{}">
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-input v-model="row.printName" />
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+
|
|
|
+ <vxe-column
|
|
|
+ field="childName"
|
|
|
+ title="子给药方式"
|
|
|
+ :edit-render="{}"
|
|
|
+ >
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-select v-model="row.supplyChild">
|
|
|
+ <xc-el-option :data="store.supplyChild" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+
|
|
|
+ <vxe-column field="tryFlagName" title="皮试标志" :edit-render="{}">
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-select
|
|
|
+ clearable
|
|
|
+ @clear="
|
|
|
+ () => {
|
|
|
+ row.tryFlag = null;
|
|
|
+ }
|
|
|
+ "
|
|
|
+ :model-value="row.tryFlag"
|
|
|
+ @update:model-value="
|
|
|
+ val => {
|
|
|
+ row.tryFlag = val;
|
|
|
+ }
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <xc-el-option :data="tryFlags" />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+
|
|
|
+ <vxe-column field="pyCode" title="拼音" :edit-render="{}">
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-input v-model="row.pyCode" />
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+ <vxe-column field="dcode" title="五笔" :edit-render="{}">
|
|
|
+ <template #edit="{ row }">
|
|
|
+ <el-input v-model="row.dcode" />
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+ <vxe-column title="绑定费用" fixed="right">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-button @click="handleOpenCharge(row.supplyCode)"
|
|
|
+ >绑定
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </vxe-column>
|
|
|
+ </vxe-table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss"></style>
|