2d0b4959 by lihua

添加新的计算定价页面

1 parent 71fa1604
...@@ -121,6 +121,36 @@ const routes: RouteRecordRaw[] = [ ...@@ -121,6 +121,36 @@ const routes: RouteRecordRaw[] = [
121 } 121 }
122 } 122 }
123 }, 123 },
124 {
125 path: 'price-calculate-new',
126 name: 'priceCalculateNew',
127 component: () => import('@/views/data_pricing/priceCalculateNew.vue'),
128 meta: {
129 title: '数据定价(新)',
130 breadcrumb: false,
131 cache: true
132 }
133 },
134 {
135 path: 'calculate-config-new',
136 name: 'calculateConfigNew',
137 component: () => import('@/views/data_pricing/calculateConfigNew.vue'),
138 meta: {
139 title: '新增数据定价',
140 sidebar: false,
141 breadcrumb: false,
142 cache: true,
143 editPage: true,
144 activeMenu: '/data-pricing/pricing-manage/price-calculate-new'
145 },
146 beforeEnter: (to, from) => {
147 if (to.query.guid) {
148 to.meta.title = `编辑-${to.query.name}`;
149 } else {
150 to.meta.title = `新增数据定价`;
151 }
152 }
153 },
124 ], 154 ],
125 }, 155 },
126 ] 156 ]
......
...@@ -313,7 +313,7 @@ const setDictFormItems = (dictList) => { ...@@ -313,7 +313,7 @@ const setDictFormItems = (dictList) => {
313 required: true, 313 required: true,
314 }); 314 });
315 baseConfigFormRules.value[dictField] = [{ required: true, trigger: 'change', message: `请选择${dictName}` }]; 315 baseConfigFormRules.value[dictField] = [{ required: true, trigger: 'change', message: `请选择${dictName}` }];
316 dictName == '数据用途' && (dataUsage.value.field = dictField); 316 d.dictionaryName == '数据用途' && (dataUsage.value.field = dictField);
317 (() => { 317 (() => {
318 if (typeMap.value[dictField] == undefined) { 318 if (typeMap.value[dictField] == undefined) {
319 getDataType(d.dictionaryName, dictField) 319 getDataType(d.dictionaryName, dictField)
......
1 <route lang="yaml">
2 name: priceCalculate
3 </route>
4
5 <script lang="ts" setup name="priceCalculate">
6 import { ref } from 'vue';
7 import TableTools from '@/components/Tools/table_tools.vue';
8 import { TableColumnWidth, commonPageConfig } from '@/utils/enum';
9 import { ElMessage, ElMessageBox } from "element-plus";
10 import { CirclePlus } from "@element-plus/icons-vue";
11 import { useRouter, useRoute } from "vue-router";
12 import useUserStore from "@/store/modules/user";
13 import useDataAssetStore from "@/store/modules/dataAsset";
14 import { getAllFlowData } from '@/api/modules/queryService';
15 import { changeNum } from "@/utils/common";
16 import {
17 getDiseaseAll,
18 getPriceList,
19 deletePrice,
20 } from '@/api/modules/dataPricing';
21
22 const router = useRouter();
23 const userStore = useUserStore()
24 const assetStore = useDataAssetStore();
25 const userData = JSON.parse(userStore.userData)
26 const { proxy } = getCurrentInstance() as any;
27
28 const searchItemList = ref([
29 {
30 type: "input",
31 label: "",
32 field: "dataResourceName",
33 default: "",
34 placeholder: "数据资源名称",
35 clearable: true,
36 },
37 {
38 type: "cascader",
39 label: "",
40 field: "diseaseName",
41 placeholder: "疾病名称",
42 default: "",
43 options: [],
44 showAllLevels: false,
45 props: {
46 checkStrictly: true,
47 label: "diseaseName",
48 value: "guid",
49 children: 'childList',
50 emitPath: false
51 },
52 filterable: true,
53 clearable: true,
54 }
55 ]);
56
57 const typeMap: any = ref({});
58 const selectRowData: any = ref([])
59 const currTableData: any = ref({});
60 const page: any = ref({
61 ...commonPageConfig,
62 dataResourceName: '',
63 diseaseName: ''
64 });
65 const tableField: any = ref([
66 { label: "序号", type: "index", width: TableColumnWidth.INDEX, align: "center" },
67 { label: "定价模型名称", field: "modelName", width: 200 },
68 { label: "数据资源名称", field: "dataResourceName", width: 200 },
69 { label: "疾病名称", field: "diseaseName", width: 200 },
70 {
71 label: "交易价格(元)", field: "dataTransactionPrice", width: 120, align: 'right', getName: (scope) => {
72 return scope.row.dataTransactionPrice ? changeNum(parseFloat(scope.row.dataTransactionPrice), 2) : '-';
73 }
74 },
75 { label: "创建人", field: "createUserName", width: 120 },
76 { label: "创建时间", field: "createTime", width: TableColumnWidth.DATETIME },
77 ]);
78 const tableInfo = ref({
79 id: 'api-data-table',
80 rowKey: 'guid',
81 loading: false,
82 fields: tableField.value,
83 data: [],
84 page: {
85 type: "normal",
86 rows: 0,
87 ...page.value,
88 },
89 actionInfo: {
90 label: "操作",
91 type: "btn",
92 isMore: false,
93 width: 120,
94 btns: [
95 { label: "编辑", value: "edit" },
96 { label: "删除", value: "del" }
97 ]
98 }
99 });
100
101 const setTableField = () => {
102 tableField.value.splice(4, 0, {
103 label: "交易用途", field: "dataUsage", width: 120, getName: (scope) => {
104 return typeMap.value['dataUsage'].find((item) => item.value == scope.row['dataUsage'])?.label || '-';
105 }
106 });
107 tableInfo.value.fields = tableField.value;
108 }
109
110 // 获取所有疾病数据
111 const getDiseaseData = () => {
112 getDiseaseAll().then((res: any) => {
113 if (res.code == proxy.$passCode) {
114 const data = res.data || [];
115 searchItemList.value[1].options = data;
116 }
117 })
118 }
119
120 // 获取数据字典
121 const getDataType = (dictType, fieldName) => {
122 getAllFlowData({ dictType }).then((res: any) => {
123 if (res.code == proxy.$passCode) {
124 const data = res.data || [];
125 typeMap.value[fieldName] = JSON.parse(JSON.stringify(data));
126 setTableField()
127 } else {
128 proxy.$ElMessage.error(res.msg);
129 }
130 })
131 }
132
133 const toSearch = (val: any, clear: boolean = false) => {
134 page.value.curr = 1;
135 if (clear) {
136 searchItemList.value.map((item) => (item.default = ""));
137 page.value.dataResourceName = ''
138 page.value.diseaseName = '';
139 } else {
140 page.value.dataResourceName = val.dataResourceName || '';
141 page.value.diseaseName = val.diseaseName || '';
142 }
143 getTableData();
144 };
145
146 const getTableData = () => {
147 tableInfo.value.loading = true;
148 getPriceList({
149 pageSize: page.value.limit,
150 pageIndex: page.value.curr,
151 dataResourceName: page.value.dataResourceName,
152 diseaseName: page.value.diseaseName,
153 }).then((res: any) => {
154 tableInfo.value.loading = false;
155 if (res.code == proxy.$passCode) {
156 const data = res.data || {};
157 tableInfo.value.data = data.records || [];
158 tableInfo.value.page.limit = data.pageSize
159 tableInfo.value.page.curr = data.pageIndex
160 tableInfo.value.page.rows = data.totalRows
161 } else {
162 proxy.$ElMessage.error(res.msg);
163 }
164 })
165 }
166
167 const tablePageChange = (info) => {
168 page.value.curr = Number(info.curr);
169 page.value.limit = Number(info.limit);
170 tableInfo.value.page.limit = page.value.limit;
171 tableInfo.value.page.curr = page.value.curr;
172 getTableData();
173 };
174
175 const tableBtnClick = (scope, btn) => {
176 const type = btn.value;
177 const row = scope.row;
178 currTableData.value = row;
179 if (type === 'edit') { // 编辑
180 if (row.belongingTheme) {
181 router.push(
182 {
183 name: 'calculateConfig',
184 query: {
185 guid: row.guid,
186 name: row.modelName,
187 type: 'edit'
188 }
189 }
190 );
191 } else {
192 router.push(
193 {
194 name: 'calculateConfigNew',
195 query: {
196 guid: row.guid,
197 name: row.modelName,
198 type: 'edit'
199 }
200 }
201 );
202 }
203 } else if (type === 'del') { // 删除
204 open('确定要删除该条数据吗?', 'warning');
205 }
206 };
207
208 const open = (msg, type, isBatch = false) => {
209 ElMessageBox.confirm(msg, "提示", {
210 confirmButtonText: "确定",
211 cancelButtonText: "取消",
212 type: type,
213 }).then(() => {
214 let guids = [currTableData.value.guid]
215 if (isBatch) {
216 guids = selectRowData.value
217 }
218 deletePrice(guids).then((res: any) => {
219 if (res.code == proxy.$passCode) {
220 getTableData();
221 ElMessage({
222 type: "success",
223 message: "删除成功",
224 });
225 } else {
226 proxy.$ElMessage.error(res.msg);
227 }
228 });
229 });
230 };
231
232 const addDisease = () => {
233 router.push(
234 {
235 name: 'calculateConfigNew',
236 query: {
237 type: 'create'
238 }
239 }
240 );
241 }
242
243 onBeforeMount(() => {
244 getDiseaseData();
245 getDataType('数据用途', 'dataUsage')
246 });
247
248 onActivated(() => {
249 if (assetStore.isRefresh) {//如果是首次加载,则不需要调用
250 toSearch(null, true);
251 assetStore.set(false);
252 }
253 })
254
255 </script>
256
257 <template>
258 <div class="container_wrap">
259 <div class="table_tool_wrap">
260 <TableTools :searchItems="searchItemList" :searchId="'data-source-search'" @search="toSearch" />
261 <div class="tools_btns">
262 <el-button type="primary" @click="addDisease" v-preReClick>新增</el-button>
263 </div>
264 </div>
265 <div class="table_panel_wrap">
266 <Table :tableInfo="tableInfo" @tablePageChange="tablePageChange" @tableBtnClick="tableBtnClick" />
267 </div>
268 </div>
269 </template>
270
271 <style lang="scss" scoped>
272 .table_tool_wrap {
273 width: 100%;
274 height: 84px !important;
275 padding: 0 8px;
276
277 .tools_btns {
278 padding: 0px 0 0;
279 }
280 }
281
282 .table_panel_wrap {
283 width: 100%;
284 height: calc(100% - 84px);
285 padding: 0px 8px 0;
286 }
287 </style>
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!