优化搜索热词管理

master
paulGao 2021-12-24 16:09:57 +08:00
parent 649f983990
commit 75e7bc2d9c
1 changed files with 32 additions and 15 deletions

View File

@ -14,14 +14,19 @@
<div class="card-list"> <div class="card-list">
<Card v-for="words in data" class="card-item" :key="words" onclick=""> <Card v-for="words in data" class="card-item" :key="words" onclick="">
<p><a href="#" slot="extra" @click.prevent="add(words)">{{ words }}</a></p> <p>
<a href="#" slot="extra" @click.prevent="add(words)">{{ words }}</a>
</p>
<p slot="extra">
<a @click="deleteWords(words)">
<Icon type="md-close" />
</a>
</p>
</Card> </Card>
</div> </div>
</Card> </Card>
<Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500"> <Modal :title="modalTitle" v-model="modalVisible" :mask-closable="false" :width="500">
<Form ref="form" :model="form" :label-width="100" <Form ref="form" :model="form" :label-width="100" :rules="formValidate">
:rules="formValidate">
<FormItem label="热词" prop="keywords"> <FormItem label="热词" prop="keywords">
<Input v-model="form.keywords" clearable style="width: 100%" /> <Input v-model="form.keywords" clearable style="width: 100%" />
</FormItem> </FormItem>
@ -31,14 +36,16 @@
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button> <Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="handleSubmit"></Button> <Button type="primary" :loading="submitLoading" @click="handleSubmit"
>提交</Button
>
</div> </div>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import { getHotWords, setHotWords } from "@/api/index"; import { getHotWords, setHotWords, deleteHotWords } from "@/api/index";
import { regular } from "@/utils"; import { regular } from "@/utils";
export default { export default {
@ -58,14 +65,8 @@ export default {
// //
formValidate: { formValidate: {
keywords:[ keywords: [regular.REQUIRED, regular.VARCHAR20],
regular.REQUIRED, point: [regular.REQUIRED, regular.NUMBER],
regular.VARCHAR20,
],
point:[
regular.REQUIRED,
regular.NUMBER
]
}, },
}; };
}, },
@ -110,6 +111,22 @@ export default {
this.form.point = 1; this.form.point = 1;
this.modalVisible = true; this.modalVisible = true;
}, },
deleteWords(words) {
this.$Modal.confirm({
title: "是否确定删除热词",
content: "<p>您确定要删除此热词吗?</p>",
okText: "确实",
cancelText: "取消",
onOk: () => {
deleteHotWords(words).then((res) => {
if (res.success) {
this.$Message.success("删除成功");
this.getDataList();
}
});
},
});
},
}, },
mounted() { mounted() {
this.init(); this.init();