|
@@ -2,141 +2,47 @@
|
|
|
import { PageSearch, usePageSearch } from "/@/components/PageSearch";
|
|
|
import searchConfig from "./config/search.config";
|
|
|
import contentConfig from "./config/content.config";
|
|
|
-// import PageAuth from "/@/components/PageAuth";
|
|
|
-import { PageModal, usePageModal } from "/@/components/PageModalShell";
|
|
|
-import modalConfig from "./config/modal.config";
|
|
|
+import { usePermission } from "/@/hooks/usePermission";
|
|
|
import { PageContent } from "/@/components/PageContent";
|
|
|
-import { ComCard } from "/@/components/RemoteSelect";
|
|
|
-import { projectFormConfig } from "./config/_details";
|
|
|
-import { projectFormRules } from "./config/_rules";
|
|
|
-import {
|
|
|
- BasicForm,
|
|
|
- transform,
|
|
|
- createDefaultData
|
|
|
-} from "/@/components/BasicForm";
|
|
|
-import LadderTable from "./cpns/ladder-table.vue";
|
|
|
-import { ElImage } from "element-plus";
|
|
|
-import { httpDetail } from "/@/api/operate/setComGood";
|
|
|
-import { ElForm } from "element-plus";
|
|
|
-import { ref, unref } from "vue";
|
|
|
-import dayjs from "dayjs";
|
|
|
-import { useResponseHandle } from "/@/hooks/useAsync";
|
|
|
-import OrderDialog from "/@/components/PageListModal";
|
|
|
-const responseHandle = useResponseHandle();
|
|
|
+import { ref } from "vue";
|
|
|
+import EditModel from "./components/edit-dialog.vue";
|
|
|
+const pageName = "setComGood";
|
|
|
const { pageContentRef, handleResetClick, handleSearchClick } = usePageSearch(
|
|
|
undefined,
|
|
|
undefined,
|
|
|
searchConfig
|
|
|
);
|
|
|
-const {
|
|
|
- pageModalRef,
|
|
|
- handleUpdateData,
|
|
|
- handleCreateData,
|
|
|
- handlePreviewData,
|
|
|
- handleConfrim,
|
|
|
- defaultInfo
|
|
|
-} = usePageModal({
|
|
|
- pageContentRef
|
|
|
-});
|
|
|
|
|
|
-const { formItems } = projectFormConfig;
|
|
|
-const modelRef = ref<InstanceType<typeof OrderDialog>>(null);
|
|
|
-const basicFormRef = ref<InstanceType<typeof ElForm>>(null);
|
|
|
-const formData = ref<Record<string, any>>(createDefaultData(formItems));
|
|
|
-function handleCreate() {
|
|
|
- basicFormRef.value.validate(isValid => {
|
|
|
- console.log(isValid);
|
|
|
- // if (!isValid) return;
|
|
|
-
|
|
|
- const { group_id, good_id } = formData.value;
|
|
|
- if (!group_id || good_id.length == 0) return;
|
|
|
- console.log(formData.value);
|
|
|
- const params = {
|
|
|
- group_id,
|
|
|
- good_id: []
|
|
|
- };
|
|
|
- good_id.forEach(si => {
|
|
|
- console.log(si);
|
|
|
- params.good_id.push(si.id);
|
|
|
- });
|
|
|
- handleConfrim("create", params);
|
|
|
- });
|
|
|
-}
|
|
|
-async function handleDetailData(row, type) {
|
|
|
- const { id } = row;
|
|
|
- const { code, data, message } = await httpDetail({ id: id });
|
|
|
- responseHandle({
|
|
|
- code,
|
|
|
- message,
|
|
|
- handler: () => {
|
|
|
- if (type === "preview") {
|
|
|
- handlePreviewData(data);
|
|
|
- }
|
|
|
- if (type === "update") {
|
|
|
- formData.value = transform(formItems, data, {});
|
|
|
- handleUpdateData(data);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-function handleAddOrder(list) {
|
|
|
- list.forEach(item => {
|
|
|
- const { id } = item;
|
|
|
- let findex = formData.value.good_id.findIndex(e => e.id + "" == id + "");
|
|
|
- if (findex == -1) {
|
|
|
- formData.value.good_id.push(item);
|
|
|
- }
|
|
|
- });
|
|
|
+const modelRef = ref<InstanceType<typeof EditModel>>(null);
|
|
|
+const { hasPermissionWithCode, permissions } = usePermission(pageName);
|
|
|
+function handleAddChangeCheck(item: any, id: string, type: string) {
|
|
|
+ modelRef.value.show(item, id, type);
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <!-- <PageAuth :pageName="pageName"> -->
|
|
|
- <PageSearch
|
|
|
- :form-config="searchConfig"
|
|
|
- @search-btn-click="handleSearchClick"
|
|
|
- @reset-btn-click="handleResetClick"
|
|
|
- />
|
|
|
- <PageContent
|
|
|
- ref="pageContentRef"
|
|
|
- :content-config="contentConfig"
|
|
|
- @create-btn-click="handleCreateData"
|
|
|
- @preview-btn-click="row => handleDetailData(row, 'preview')"
|
|
|
- @update-btn-click="row => handleDetailData(row, 'update')"
|
|
|
- />
|
|
|
- <PageModal
|
|
|
- ref="pageModalRef"
|
|
|
- :modal-config="modalConfig"
|
|
|
- :default-info="defaultInfo"
|
|
|
- @confirm-btn-click="handleConfrim"
|
|
|
- >
|
|
|
- <BasicForm
|
|
|
- ref="basicFormRef"
|
|
|
- v-bind="projectFormConfig"
|
|
|
- :form-data="formData"
|
|
|
- :rules="projectFormRules"
|
|
|
- :disabled="false"
|
|
|
- label-width="120px"
|
|
|
+ <PageAuth :pageName="pageName">
|
|
|
+ <PageSearch
|
|
|
+ :form-config="searchConfig"
|
|
|
+ @search-btn-click="handleSearchClick"
|
|
|
+ @reset-btn-click="handleResetClick"
|
|
|
>
|
|
|
- <template #group_id>
|
|
|
- <ComCard v-model="formData.group_id" placeholder="公司卡类型" />
|
|
|
- </template>
|
|
|
- <template #good_id>
|
|
|
- <LadderTable
|
|
|
- :readonly="false"
|
|
|
- :ladder="formData.good_id"
|
|
|
- @choose="() => modelRef.show('')"
|
|
|
- @delete="index => formData.good_id.splice(index, 1)"
|
|
|
- />
|
|
|
- </template>
|
|
|
- <template #footer>
|
|
|
- <div class="w-full flex justify-end">
|
|
|
- <ElButton type="primary" @click="handleCreate">保存</ElButton>
|
|
|
- </div>
|
|
|
+ <template #action>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="handleAddChangeCheck({}, '', 'create')"
|
|
|
+ v-if="hasPermissionWithCode('002')"
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </el-button>
|
|
|
</template>
|
|
|
- </BasicForm>
|
|
|
- </PageModal>
|
|
|
- <OrderDialog ref="modelRef" @save-btn-click="handleAddOrder" />
|
|
|
- <!-- </PageAuth> -->
|
|
|
+ </PageSearch>
|
|
|
+ <PageContent
|
|
|
+ ref="pageContentRef"
|
|
|
+ :powers="permissions"
|
|
|
+ :content-config="contentConfig"
|
|
|
+ @preview-btn-click="row => handleAddChangeCheck(row, row.id, 'view')"
|
|
|
+ />
|
|
|
+ <EditModel ref="modelRef" @reload="pageContentRef.onSearch()" />
|
|
|
+ </PageAuth>
|
|
|
</template>
|