123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 |
- <template>
- <div class="app-container">
- <div class="page-header">
- 轮播图管理
- </div>
- <el-divider></el-divider>
- <div class="btn-group">
- <el-button
- type="primary"
- size="small"
- @click="(dialogVisible = true), (type = 1)"
- >新增</el-button>
- <el-button size="small" type="danger" @click="batchDelete()">删除</el-button>
- </div>
- <div class="mymain-container">
- <el-table
- v-loading="listLoading"
- :data="dataList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- @selection-change="handleSelectionChange"
- >
- <el-table-column type="selection" width="55" align="center">
- </el-table-column>
- <template v-for="col in columns">
- <el-table-column
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- v-if="col.prop == 'status'"
- >
- <template slot-scope="scope">
- <div style="z-index: 99">
- <el-tag type="success" v-if="scope.row.status == '1'" >显示</el-tag>
- <el-tag type="danger" v-else-if="scope.row.status == '0'">隐藏 </el-tag>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- v-if="col.prop == 'imgCarouselUrl'"
- >
- <template slot-scope="scope">
- <a :href="scope.row.imgCarouselUrl" >
- <img :src="scope.row.imgCarouselUrl" alt="轮播图" class="el-image__inner el-image__preview"/>
- </a>
- </template>
- </el-table-column>
- <el-table-column
- v-else
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- </el-table-column>
- </template>
- <el-table-column
- align="center"
- fixed="right"
- label="操作"
- min-width="160"
- >
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="hanleEdit(scope.row)"
- >编辑</el-button
- >
- <el-button type="text" size="small" @click="hanleStatus(scope.row.id)" v-if="scope.row.status === '1'">隐藏</el-button>
- <el-button type="text" size="small" @click="hanleStatus(scope.row.id)" v-if="scope.row.status === '0'">显示</el-button>
- <el-popconfirm
- title="确定要删除这张轮播图吗?"
- style="margin-left: 10px"
- @onConfirm="hanleDelete(scope.row.id)"
- >
- <el-button slot="reference" type="text" size="small"
- >删除</el-button
- >
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <!-- <div style="margin: 20px 0">-->
- <!-- <el-pagination-->
- <!-- @size-change="handleSizeChange"-->
- <!-- @current-change="handleCurrentChange"-->
- <!-- :current-page="currentPage"-->
- <!-- :page-sizes="[10, 20, 30, 50]"-->
- <!-- :page-size="10"-->
- <!-- layout="total, sizes, prev, pager, next, jumper"-->
- <!-- :total="listTotal"-->
- <!-- >-->
- <!-- </el-pagination>-->
- <!-- </div>-->
- </div>
- <!-- 添加公司备案信息 -->
- <div>
- <div class="setting_title">备案管理</div>
- <el-divider></el-divider>
- <el-card shadow="never" class="my-card">
- <el-form
- class="my-form"
- ref="mainForm"
- :model="comPanyDialogForm"
- label-width="120px"
- label-position="right"
- >
- <el-form-item label="ICP备案:" prop="nickName">
- <el-input
- autocomplete="off"
- placeholder="请输入"
- v-model="comPanyDialogForm.icpRecord"
- ></el-input
- >
- </el-form-item>
- <el-form-item label="ICP备案链接:" prop="nickName">
- <el-input
- autocomplete="off"
- placeholder="请输入"
- v-model="comPanyDialogForm.icpRecordLink"
- ></el-input
- > (填写链接,可跳转至链接页面)
- </el-form-item>
- <el-form-item label="公网安备案:" prop="nickName">
- <el-input
- autocomplete="off"
- placeholder="请输入"
- v-model="comPanyDialogForm.pubSecurityRecord"
- ></el-input
- >
- </el-form-item>
- <el-form-item label="公网安备案链接:" prop="nickName">
- <el-input
- autocomplete="off"
- placeholder="请输入"
- v-model="comPanyDialogForm.pubSecurityRecordLink"
- ></el-input
- > (填写链接,可跳转至链接页面)
- </el-form-item>
- <div class="setting_title">公司名称管理</div>
- <el-divider></el-divider>
- <el-form-item label="公司名称:" prop="nickName">
- <el-input
- autocomplete="off"
- placeholder="单行输入"
- v-model="comPanyDialogForm.companyName"
- ></el-input
- >
- </el-form-item>
- </el-form>
- </el-card>
- </div>
- <div class="page-footer">
- <div class="footer">
- <!-- <el-button type="primary" @click="editFn">修改</el-button>-->
- <el-button type="primary" @click="addComPany">确定</el-button>
- </div>
- </div>
- <div>
- <el-dialog
- :visible.sync="dialogVisible"
- width="50%"
- @close="resetForm"
- :close-on-click-modal="false"
- >
- <el-form
- ref="dialogForm"
- :model="dialogForm"
- :rules="type == 1 ? rules : ''"
- label-width="120px"
- size="normal"
- >
- <el-form-item label="轮播图名称" prop="saleCode">
- <el-input v-model="dialogForm.imgCarouselName"></el-input>
- </el-form-item>
- <el-form-item label="轮播图" prop="fileUrl">
- <ImageUpload :fileList="fileList" :multiple="true" />
- </el-form-item>
- <el-form-item label="排序" prop="mainId">
- <el-input v-model="dialogForm.imgCarouselOrder"></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="(dialogVisible = false), resetForm()"
- >取 消</el-button
- >
- <el-button type="primary" @click="addImgCarousel">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import Mixin from "@/mixin/index";
- import Pagination from "@/components/Pagination";
- import ImageUpload from '@/components/Common/image-upload.vue';
- import {
- getProductList,
- getImgCarouseList,
- handleImgIsShow,
- addImgCarousel,
- delImgData,
- addCompany,
- editImgCarousel,
- } from "@/api/policy_list";
- export default {
- mixins: [Mixin],
- data() {
- return {
- type: 0, // 0,1
- screenForm: {
- companyRecordManageId: "",
- imgCarouselName: "",
- imgCarouselUrl: "",
- imgCarouselOrder: "",
- status: "",
- },
- dialogForm: {
- id: "",
- companyRecordManageId: "",
- imgCarouselName: "",
- imgCarouselUrl: "",
- imgCarouselOrder: "",
- status: "1",
- },
- comPanyDialogForm: {
- id: "",
- icpRecord: "",
- icpRecordLink: "",
- pubSecurityRecord: "",
- pubSecurityRecordLink: "",
- companyName: "",
- },
- dataList: [
- {
- date: "2016-05-02",
- name: "王小虎",
- label: "姓名",
- address: "上海市普陀区金沙江路 1518 弄",
- },
- ],
- columns: [
- {
- prop: "imgCarouselName",
- lable: "轮播图名称",
- widht: 160,
- },
- {
- prop: "imgCarouselUrl",
- lable: "轮播图",
- widht: 160,
- },
- {
- prop: "imgCarouselOrder",
- lable: "排序",
- widht: 160,
- },
- {
- prop: "createTime",
- lable: "创建时间",
- widht: 160,
- },
- {
- prop: "status",
- lable: "状态",
- widht: 160,
- },
- ],
- rules: {
- imgCarouselName: [
- { required: true, message: "请输入轮播图名称", trigger: "blur" },
- ],
- // saleName: [
- // { required: true, message: "请输入销售类型名称", trigger: "blur" },
- // ],
- // mainName: [
- // { required: true, message: "请输入品类名称", trigger: "blur" },
- // ],
- },
- productList: [],
- fileList: [],
- multipleSelection: [],
- };
- },
- methods: {
- getList() {
- this.listLoading = true;
- const params = {
- pageNum: this.currentPage,
- pageSize: this.pageSize,
- saleCode: this.screenForm.saleCode,
- saleName: this.screenForm.saleName,
- mainId: "",
- status: this.screenForm.status,
- };
- // getTypeList(params).then((res) => {
- // this.dataList = res.data.records;
- // this.listTotal = res.data.total;
- // this.listLoading = false;
- // });
- getImgCarouseList(params).then((res) => {
- this.dataList = res.data;
- this.listLoading = false;
- });
- getProductList({
- productCategoryName: "",
- productCategoryNumber: "",
- }).then((res) => {
- this.productList = res.data;
- });
- },
- handleChange(e) {
- this.productList.find((k) => {
- if (k.productCategoryNumber == e) {
- this.dialogForm.mainId = k.productCategoryNumber;
- this.dialogForm.mainName = k.productCategoryName;
- this.screenForm.mainId = k.productCategoryNumber;
- this.screenForm.mainName = k.productCategoryName;
- }
- });
- },
- hanleDelete(id) {
- this.hanleDeleteAllPromise(id).then((ids) => {
- delImgData({
- ids: ids[0],
- }).then((res) => {
- this.$successMsg("删除成功");
- this.hanleReset();
- });
- });
- },
- hanleEdit(item) {
- this.dialogForm = {
- id: item.id,
- companyRecordManageId: item.companyRecordManageId,
- imgCarouselName: item.imgCarouselName,
- imgCarouselUrl: item.imgCarouselUrl,
- imgCarouselOrder: item.imgCarouselOrder,
- status: item.status,
- };
- this.type = 0;
- this.dialogVisible = true;
- },
- hanleDateil(item) {
- this.dialogVisible = true;
- this.dialogForm = {
- ...item,
- };
- this.type = 3;
- },
- hanleStatus(id){
- handleImgIsShow({
- id:id
- }).then((res) => {
- this.$successMsg("状态已更改");
- this.hanleReset();
- });
- },
- addImgCarousel(){
- if (this.type == 1) {
- this.$refs.dialogForm.validate((valid) => {
- //console.log(...this.dialogForm)
- if (valid) {
- this.dialogForm.imgCarouselUrl = "http://hg.zfire.top/api/img/get?key=" + this.fileList[0].url
- const params = {
- ...this.dialogForm,
- };
- addImgCarousel(params).then((res) => {
- this.$successMsg("添加成功");
- this.hanleReset();
- });
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- } else if (this.type == 0) {
- const upParams = {
- ...this.dialogForm,
- };
- editImgCarousel(upParams).then((res) => {
- this.$successMsg("修改成功");
- this.hanleReset();
- });
- } else {
- this.dialogVisible = false;
- }
- },
- // 表格选择
- handleSelectionChange(val) {
- this.multipleSelection = val;
- },
- //添加公司信息
- addComPany(){
- const params = {
- ...this.comPanyDialogForm,
- };
- addCompany(params).then((res) => {
- this.$successMsg("添加成功");
- this.hanleReset();
- });
- },
- resetForm(formName) {
- this.$refs.dialogForm.resetFields();
- },
- hanleReset() {
- this.dialogForm = {
- companyRecordManageId: "",
- imgCarouselName: "",
- imgCarouselUrl: "",
- imgCarouselOrder: "",
- status: "1"
- };
- // this.$refs.dialogForm.resetFields()
- this.dialogVisible = false;
- this.getList();
- },
- batchDelete() {
- if(this.multipleSelection.length < 1) {
- return this.$errorMsg('请选择信息');
- }
- this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- let ids = [];
- this.multipleSelection.forEach(item => {
- ids.push(item.id);
- });
- delImgData({ids: ids.join(',')}).then(res => {
- this.$successMsg('删除成功');
- this.hanleReset();
- })
- }).catch(() => {});
- },
- },
- components: {
- Pagination,
- ImageUpload
- },
- };
- </script>
- <style scoped>
- .el-switch.is-disabled {
- opacity: inherit;
- }
- .page-header{
- font-size: 18px;
- padding-bottom: 10px;
- font-weight: 600;
- }
- .cname-footer{
- margin-top: 15px;
- }
- .my-form{
- width :60%
- }
- </style>
|