123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <template>
- <div class="tenant">
- <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
- :selectConfig="selectConfig" :table-events="{
- select: select,
- }" :action-list="[
- {
- text: '添加祝福语',
- action: () => openModal('add'),
- },
- ]" @get-list="getList">
- </byTable>
- <el-dialog z-index="1100" :title="modalType == 'add' ? '添加祝福语' : '编辑祝福语'" v-if="dialogVisible" v-model="dialogVisible" width="800px"
- v-loading="loading">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm" size="large" :loading="submitLoading">确 定</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { ElMessage, ElMessageBox } from "element-plus";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import { computed, nextTick, reactive, ref } from "vue";
- const { proxy } = getCurrentInstance();
- const router = useRouter();
- const loading = ref(false);
- const blessingTypeList = ref([]);
- const submitLoading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- },
- });
- let rules = ref({
- blessingType: [
- { required: true, message: "请选择祝福语类型", trigger: "change" },
- ],
- blessingContent: [
- { required: true, message: "请输入祝福内容", trigger: "blur" },
- ],
- });
- let dialogVisible = ref(false);
- let modalType = ref("add");
- const selectConfig = computed(() => {
- return [
- {
- label: "祝福语类型",
- prop: "blessingType",
- data: blessingTypeList.value,
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "祝福语类型",
- prop: "blessingType",
- width: "240",
- align: "left",
- },
- render(type) {
- return proxy.dictValueLabel(type, blessingTypeList.value);
- },
- },
- {
- attrs: {
- label: "祝福内容",
- prop: "blessingContent",
- align: "left",
- },
- },
- {
- attrs: {
- label: "操作",
- width: "120",
- align: "center",
- },
- renderHTML(row) {
- return [
- {
- attrs: {
- label: "修改",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- getDtl(row);
- },
- },
- {
- attrs: {
- label: "删除",
- type: "danger",
- text: true,
- },
- el: "button",
- click() {
- ElMessageBox.confirm(
- "此操作将永久删除该数据, 是否继续?",
- "提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- ).then(() => {
- //删除
- proxy
- .post("/blessingLanguage/delete", {
- id: row.id,
- })
- .then((res) => {
- ElMessage({
- message: "删除成功",
- type: "success",
- });
- getList();
- });
- });
- },
- },
- ];
- },
- },
- ];
- });
- let formData = reactive({
- data: {
- coverList: [],
- audioList: [],
- },
- });
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const byform = ref(null);
- const formConfig = computed(() => {
- return [
- {
- type: "select",
- prop: "blessingType",
- label: "祝福语类型",
- data: blessingTypeList.value,
- required: true,
- },
- {
- type: "input",
- itemType: "textarea",
- rows: 10,
- prop: "blessingContent",
- label: "祝福内容",
- required: true,
- },
- ];
- });
- const getDictlist = async () => {
- proxy.getDictOne(["blessing_type"]).then((res) => {
- blessingTypeList.value = res["blessing_type"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- };
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy
- .post("/blessingLanguage/page", sourceList.value.pagination)
- .then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- const openModal = () => {
- dialogVisible.value = true;
- modalType.value = "add";
- formData.data = {
- content: "",
- };
- };
- const selection = ref({
- data: [],
- });
- const select = (_selection, row) => {
- selection.value.data = _selection;
- };
- const getDtl = (row) => {
- modalType.value = "edit";
- proxy.post("/blessingLanguage/detail", { id: row.id }).then((res) => {
- formData.data = res;
- dialogVisible.value = true;
- });
- };
- const submitForm = () => {
- byform.value.handleSubmit(() => {
- submitLoading.value = true;
- proxy.post("/blessingLanguage/" + modalType.value, formData.data).then(
- () => {
- ElMessage({
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
- type: "success",
- });
- dialogVisible.value = false;
- submitLoading.value = false;
- getList();
- },
- (err) => {
- submitLoading.value = false;
- }
- );
- });
- };
- getDictlist();
- getList();
- </script>
- <style lang='scss' scoped>
- .tenant {
- padding: 20px;
- .delete-btn {
- margin-top: 10px;
- margin-left: 25px;
- }
- }
- .avatar-uploader .avatar {
- width: 110px;
- height: 110px;
- display: block;
- background-color: black;
- }
- .avatar-uploader .el-upload {
- border: 1px dashed var(--el-border-color);
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- transition: var(--el-transition-duration-fast);
- }
- .avatar-uploader .el-upload:hover {
- border-color: var(--el-color-primary);
- }
- .el-icon.avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 110px;
- height: 110px;
- text-align: center;
- border: 1px dashed var(--el-border-color);
- }
- .pic {
- object-fit: contain;
- width: 50px;
- height: 50px;
- cursor: pointer;
- vertical-align: middle;
- }
- .blessingClass {
- background-image: url("../../../assets/victoria/sjk.jpg");
- background-size: cover;
- height: 600px;
- width: 300px;
- padding: 40px 19px;
- }
- </style>
|