recommend application

master
lion 1 year ago
parent b59a28455f
commit 1ea14113b9

@ -2,9 +2,9 @@
ENV='development'
# base api
#VUE_APP_BASE_API = https://saifen.ali251.langye.net
#VUE_APP_UPLOAD_API = https://saifen.ali251.langye.net/api/admin/upload-file
VUE_APP_BASE_API = https://saifen.ali251.langye.net
VUE_APP_UPLOAD_API = https://saifen.ali251.langye.net/api/admin/upload-file
#VUE_APP_PREVIEW_API=http://view.ali251.langye.net:8012/onlinePreview
VUE_APP_BASE_API = https://sepax-pdm-test.langye.net
VUE_APP_UPLOAD_API = https://sepax-pdm-test.langye.net/api/admin/upload-file
#VUE_APP_BASE_API = https://sepax-pdm-test.langye.net
#VUE_APP_UPLOAD_API = https://sepax-pdm-test.langye.net/api/admin/upload-file

@ -0,0 +1,60 @@
import request from "@/utils/request";
function customParamsSerializer(params) {
let result = '';
for (let key in params) {
if (params.hasOwnProperty(key)) {
if (Array.isArray(params[key])) {
params[key].forEach((item,index) => {
if(item.key){
result += `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`;
}else{
result +=`${key}[${index}]=${item}&`
}
});
} else {
result += `${key}=${params[key]}&`;
}
}
}
return result.slice(0, -1);
}
export function index(params,isLoading = false) {
return request({
method: "get",
url: "/api/admin/recommend-application/index",
params,
paramsSerializer: customParamsSerializer,
isLoading
})
}
export function show(params, isLoading = true) {
return request({
method: "get",
url: "/api/admin/recommend-application/show",
params,
isLoading
})
}
export function save(data) {
return request({
method: "post",
url: "/api/admin/recommend-application/save",
data
})
}
export function destroy(params) {
return request({
method: "get",
url: "/api/admin/recommend-application/destroy",
params
})
}

@ -128,7 +128,7 @@
</div>
</div>
</template>
<template v-slot:icon_id>
<!-- <template v-slot:icon_id>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Icon
@ -155,7 +155,7 @@
</el-upload>
</div>
</div>
</template>
</template> -->
</xy-dialog>

@ -157,7 +157,7 @@
destroy({
id:id
}).then(response => {
this.$Message.success('操作成功');
this.$Message.success('Success');
this.getList()
}).catch(error => {
console.log(error)

@ -0,0 +1,256 @@
<template>
<div>
<xy-dialog ref="dialog" :width="50" :is-show.sync="isShow" :type="'form'" :title="$route.meta.title" :form="form"
:rules='rules' @submit="submit">
<template v-slot:name>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>Name
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" style="width:100%" v-model="form.name"></el-input>
</div>
</div>
</template>
<template v-slot:sort>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>Sort
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" style="width:100%" v-model="form.sort"></el-input>
</div>
</div>
</template>
<template v-slot:application_type_id>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>Application Sample
</div>
<div class="xy-table-item-content">
<el-select style="width:100%" filterable v-model="form.application_type_id" placeholder="Please Select">
<el-option v-for="(item,index) in categoryList" :key="index" :label="item.name" :value="item.id">
</el-option>
</el-select>
</div>
</div>
</template>
<template v-slot:icon_id>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Icon
</div>
<div class="xy-table-item-content">
<el-upload :action="action" class='upload-demo' :limit="1" list-type="picture-card"
accept=".PNG,.jpg,.jpeg,.bmp,.svg" :file-list="iconList" ref="pictureUpload" :auto-upload="true"
:on-success="handlesuccess" :on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload>
</div>
</div>
</template>
<template v-slot:icon_active_id>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Icon Active
</div>
<div class="xy-table-item-content">
<el-upload :action="action" class='upload-demo' :limit="1" list-type="picture-card"
accept=".PNG,.jpg,.jpeg,.bmp,.svg" :file-list="iconActiveList" ref="pictureUpload" :auto-upload="true"
:on-success="handlesuccessA" :on-remove="handleRemoveA">
<i class="el-icon-plus"></i>
</el-upload>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show
} from "@/api/recommend/application.js"
import {
getToken
} from '@/utils/auth'
import {
index as getCategory
} from "@/api/application/category.js"
export default {
data() {
return {
isShow: false,
id: '',
type: 'add',
categoryList: [],
uploadOther: {
token: ""
},
action: `${process.env.VUE_APP_UPLOAD_API}`,
iconList: [], // category id
iconActiveList: [],
form: {
name: "",
sort: 0,
application_type_id: '',
icon_id: '',
icon_active_id: ''
},
rules: {
name: [{
required: true,
message: 'Please Input'
}],
sort: [{
required: true,
message: 'Please Input'
}],
application_type_id: [{
required: true,
message: 'Please Select'
}]
}
}
},
created() {
this.getCategoryList()
},
methods: {
async getCategoryList() {
const res = await getCategory({
page: 1,
page_size: 999,
type: 2,
sort_name: 'sort',
sort_type: 'ASC'
})
this.categoryList = res.data
},
handleRemove(file, fileList) {
this.iconList = fileList
},
handlesuccess(response, file, fileList) {
if (response && response.hasOwnProperty('errcode')) {
this.$Message.warning(response.errmsg || '')
this.iconList = []
return
}
this.iconList = fileList
},
handleRemoveA(file, fileList) {
this.iconActiveList = fileList
},
handlesuccessA(response, file, fileList) {
if (response && response.hasOwnProperty('errcode')) {
this.$Message.warning(response.errmsg || '')
this.iconList = []
return
}
this.iconActiveList = fileList
},
submit() {
if (this.id) {
this.form.id = this.id
} else {
this.form.id = ''
}
if (this.iconList.length > 0) {
for (var h of this.iconList) {
if (h.response) {
this.form.icon_id = h.response.id
} else {
this.form.icon_id = h.id
}
}
} else {
this.form.icon_id = ''
}
if (this.iconActiveList.length > 0) {
for (var h of this.iconActiveList) {
if (h.response) {
this.form.icon_active_id = h.response.id
} else {
this.form.icon_active_id = h.id
}
}
} else {
this.form.icon_active_id = ''
}
// return
save({
...this.form
}).then(res => {
this.$message({
type: 'success',
message: 'Success'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
id: this.id,
show_relation: ['icon', 'applicationType', 'iconActive']
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
this.form.application_type_id = res.application_type_id ? res.application_type_id : ''
this.form.sort = res.sort ? res.sort : 0
if (res.icon) {
this.iconList.push({
name: res.icon.original_name,
id: res.icon.id,
url: res.icon.url
})
}
if (res.icon_active) {
this.iconActiveList.push({
name: res.icon_active.original_name,
id: res.icon_active.id,
url: res.icon_active.url
})
}
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
}
} else {
this.id = ''
this.iconList = []
this.iconActiveList = []
this.form = {
name: "",
sort: 0,
application_type_id: '',
icon_id: '',
icon_active_id: ''
}
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .name,
::v-deep .sort,
::v-deep .application_type_id,
::v-deep .icon_id,
::v-deep .icon_active_id {
flex-basis: 100%;
}
</style>

@ -131,7 +131,7 @@
deleteList(id) {
var that = this;
del(id).then(response => {
this.$Message.success('操作成功');
this.$Message.success('Success');
this.getList()
}).catch(error => {
console.log(error)

@ -122,7 +122,7 @@
destroy({
id:id
}).then(response => {
this.$Message.success('操作成功');
this.$Message.success('Success');
this.getList()
}).catch(error => {
console.log(error)

@ -0,0 +1,138 @@
<template>
<div>
<div>
<div ref="lxHeader">
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content">
<div class="searchwrap" style="display: flex;align-items: center;">
<div>
<el-input v-model="select.name" placeholder="Name"></el-input>
</div>
<div>
<el-button type="primary" size="small" @click="select.page=1,getList()">search</el-button>
</div>
<div>
<el-button type="primary" size="small" @click="resetSearch">reset</el-button>
</div>
<div>
<el-button type="primary" size="small" @click="editParameter('add')">add</el-button>
</div>
</div>
</div>
</lx-header>
</div>
</div>
<xy-table :list="list" :total="total" @pageIndexChange="pageIndexChange"
@pageSizeChange="pageSizeChange" :table-item="table_item">
<template v-slot:btns>
<el-table-column align='center' fixed="right" label="Operate" width="180" header-align="center">
<template slot-scope="scope">
<el-button type="primary" size="small" @click="editParameter('editor',scope.row.id)">edit</el-button>
<el-popconfirm confirm-button-text="confirm" cancel-button-text="cancel" style="margin:0 10px" @confirm="deleteList(scope.row.id)" title="Are you sure to delete it?">
<el-button type="danger" size="small" slot="reference">delete</el-button>
</el-popconfirm>
</template>
</el-table-column>
</template>
</xy-table>
<add-recommend-application ref="addRecommendApplication" @refresh="getList"></add-recommend-application>
</div>
</template>
<script>
import addRecommendApplication from './components/addRecommendApplication.vue';
import {
index,
destroy
} from "@/api/recommend/application.js";
export default {
components: {
addRecommendApplication
},
data() {
return {
select: {
name: '',
page: 1,
page_size: 10,
sort_name:'sort',
sort_type:'ASC',
},
total: 0,
list: [],
table_item: [{
type: 'index',
width: 50,
fixed: 'left'
}, {
prop: 'name',
label: 'Name',
align: 'left',
},
{
prop: 'sort',
label: 'Sort',
align: 'left',
width: 120
}
]
}
},
created() {
this.getList()
},
methods: {
editParameter(type, id) {
if (type == 'editor') {
this.$refs.addRecommendApplication.id = id
}
this.$refs.addRecommendApplication.type = type
this.$refs.addRecommendApplication.isShow = true
},
pageIndexChange(e) {
this.select.page = e
this.getList()
},
pageSizeChange(e) {
this.select.page_size = e
this.select.page = 1
this.getList()
},
resetSearch() {
this.select.page = 1
this.getList()
},
async getList() {
const res = await index({
...this.select,
filter:[{
key:'name',
op:'like',
value:this.select.name
}]
})
this.list = res.data
this.total = res.total
},
deleteList(id) {
var that = this;
destroy({
id:id
}).then(response => {
this.$Message.success('Success');
this.getList()
}).catch(error => {
console.log(error)
reject(error)
})
},
}
}
</script>
<style lang="scss" scoped>
</style>

@ -56,12 +56,12 @@
this.$refs["form"].validate((valid) => {
if (valid) {
save(that.form).then(response => {
this.$Message.success('操作成功');
this.$Message.success('Success');
}).catch(error => {
//reject(error)
})
} else {
this.$Message.error('数据校验失败');
this.$Message.error('Error');
console.log('error submit!!');
return false;
}

@ -25,7 +25,7 @@ module.exports = {
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: process.env.ENV === 'staging' ? '/admin_test' : '/admin',
outputDir: '/Users/mac/Documents/朗业/2024/s-美国赛分/saifen/public/admin_test',
outputDir: '/Users/mac/Documents/朗业/2024/s-美国赛分/saifen/public/admin',
assetsDir: 'static',
css: {
loaderOptions: { // 向 CSS 相关的 loader 传递选项

Loading…
Cancel
Save