产品关联政策

master
lion 3 months ago
parent 6e1233cbc2
commit 2a85fae4da

@ -0,0 +1,104 @@
<template>
<div>
<Modal :value="isShow" :title="title" @on-visible-change="$emit('update:isShow',$event)">
<div class="searchPolicies">
<el-input
type="text"
@keyup.enter.native="searchPolicies"
v-model="keyword"
placeholder="请输入关键词查找政策"
></el-input>
<el-button type="primary" @click="searchPolicies"></el-button>
</div>
<Table
size="small"
highlight-row
:columns="policyTable"
:data="policies"
@on-current-change="policySelect"
/>
<Page
:current="pageIndex"
:total="total"
simple
style="padding-top: 14px;display: flex;justify-content: center;"
@on-change="pageChange"
/>
</Modal>
</div>
</template>
<script>
import { index as policyIndex } from '@/api/policy'
export default {
props: {
isShow: {
type: Boolean,
default: false
},
title: {
type: String,
default: '政策选择'
}
},
data() {
return {
keyword: '',
pageIndex: 1,
total: 0,
policies: [],
policyTable: [
{ title: '政策名称', key: 'name', align: 'left' }
]
}
},
methods: {
async getPolicies() {
const res = await policyIndex({
page_size: 10,
page: this.pageIndex,
keyword: this.keyword
})
this.total = res.total || 0
this.policies = res.data || res.rows || []
},
searchPolicies() {
this.pageIndex = 1
this.getPolicies()
},
pageChange(e) {
this.pageIndex = e
this.getPolicies()
},
policySelect(row) {
if (!row) return
this.$emit('select', row)
this.$emit('update:isShow', false)
}
},
watch: {
isShow(newVal) {
if (newVal) {
this.keyword = ''
this.pageIndex = 1
this.getPolicies()
}
}
}
}
</script>
<style scoped lang="scss">
.searchPolicies{
display: flex;
justify-content: space-between;
margin-bottom:16px;
.el-input{
width:80%
}
}
</style>

@ -157,6 +157,11 @@
<!-- <orderEdit :id="selectId" :is-show.sync="isShowEdit" @refresh="getOrders"></orderEdit> -->
<orderEdit :id="selectId" :is-show.sync="isShowEdit" @refresh="getOrders"></orderEdit>
<policy-select-modal
title="选择关联政策"
:is-show.sync="isShowPolicySelect"
@select="selectPolicy"
/>
</div>
</template>
@ -164,7 +169,8 @@
import {
getList,
index as getTypes,
clone as cloneOrder
clone as cloneOrder,
save as saveOrder
} from "@/api/order"
import {
parseTime
@ -180,17 +186,21 @@
import orderLog from '@/views/order/component/orderLog'
import actions from '@/views/order/component/actions'
import orderEdit from '@/views/order/component/orderEdit'
import policySelectModal from '@/views/order/component/PolicySelectModal'
export default {
components: {
orderLog,
actions,
orderEdit
orderEdit,
policySelectModal
},
data() {
return {
selectId: null,
isShowLog: false,
isShowEdit: false,
isShowPolicySelect: false,
currentOrderId: null,
memberId:"",
merchants: [],
orderItemStates: [],
@ -398,6 +408,30 @@
label: "预产期",
width: 120
},
{
label: "关联政策",
prop: 'order_policy.name',
width: 150,
align: 'left',
customFn: (row) => {
const policyName = row.order_policy?.name || ''
return (
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
<span>{policyName}</span>
<i
class="el-icon-edit"
style={{ cursor: 'pointer', color: '#409EFF', fontSize: '16px' }}
on={{
['click']: () => {
this.currentOrderId = row.order?.id
this.isShowPolicySelect = true
}
}}
></i>
</div>
)
}
},
{
prop: "product_type.name",
label: "产品类型",
@ -408,6 +442,12 @@
label: "产品型号",
width: 100
},
{
prop: "product.merchant.username",
label: "商品商家",
align: "left",
width: 160
},
{
prop: "merchant.username",
label: "服务商家",
@ -706,6 +746,26 @@
//
})
},
selectPolicy(row) {
if (!this.currentOrderId || !row) {
return
}
saveOrder({
id: this.currentOrderId,
policy_id: row.id
}).then(res => {
Message({
type: 'success',
message: '更新关联政策成功'
})
this.getOrders()
}).catch(err => {
Message({
type: 'error',
message: err?.errmsg || '更新关联政策失败'
})
})
},
downloadExel() {

@ -25,7 +25,7 @@ module.exports = {
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: '/admin/',
outputDir: '/Users/mac/Documents/朗业/2022/y-孕育邦/后端代码/yunyubang/public/admin_test',
outputDir: '/Users/mac/Documents/朗业/2022/y-孕育邦/后端代码/yunyubang/public/admin',
assetsDir: 'static',
css: {
loaderOptions: { // 向 CSS 相关的 loader 传递选项

Loading…
Cancel
Save