
9 changed files with 236 additions and 225 deletions
@ -1,208 +1,207 @@ |
|||
<template> |
|||
<div> |
|||
|
|||
<div class="tab-header webtop"> |
|||
<!-- 标题 --> |
|||
<div>{{ viewTitle }}</div> |
|||
<!-- start 添加修改按钮 --> |
|||
<div> |
|||
<el-button type="primary" size="small" @click="saveOrUpdate">保存</el-button> |
|||
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button> |
|||
</div> |
|||
<!-- end 添加修改按钮 --> |
|||
<!-- end 详情按钮 --> |
|||
</div> |
|||
<div class="listconadd"> |
|||
|
|||
<el-card class="box-card"> |
|||
<div class="item"> |
|||
<span class="item_text">条码:</span> |
|||
<el-input v-model="locationForm.barCode" :disabled="disabledCode" placeholder="" class="item_inputs" clearable /> |
|||
<el-button type="primary" size="small" @click="createBarCode" :disabled="disabledCode">自动</el-button> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">商品名:</span> |
|||
<el-input v-model="locationForm.name" :disabled="disabledCode" placeholder="" class="item_input" clearable /> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">别名:</span> |
|||
<el-input v-model="locationForm.anotherName" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">价值:</span> |
|||
<el-input v-model="locationForm.value" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">净重:</span> |
|||
<el-input v-model="locationForm.netWeight" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">毛重:</span> |
|||
<el-input v-model="locationForm.roughWeight" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">有效天数:</span> |
|||
<el-input v-model="locationForm.effectiveDays" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">备注:</span> |
|||
<el-input v-model="locationForm.remarks" class="item_input" clearable></el-input> |
|||
</div> |
|||
</el-card> |
|||
</div> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
data() { |
|||
return { |
|||
submitdisabled: false, |
|||
disabledCode: false, |
|||
locationForm: { |
|||
barCode: "", |
|||
name: "", |
|||
anotherName: "", |
|||
value: "", |
|||
netWeight: "", |
|||
roughWeight: "", |
|||
effectiveDays: "", |
|||
remarks: "", |
|||
}, |
|||
viewTitle: "【新增】产品信息", |
|||
} |
|||
}, |
|||
created() { |
|||
|
|||
}, |
|||
methods: { |
|||
saveOrUpdate() { |
|||
if (this.viewTitle === "【新增】产品信息") return this.addProduct() |
|||
if (this.viewTitle === "【修改】产品信息") { |
|||
this.updataProduct() |
|||
} |
|||
|
|||
}, |
|||
handleReturn(isreload) { |
|||
if (isreload === 'true') this.$emit('reloadlist') |
|||
this.clearList() |
|||
this.$emit('doback') |
|||
}, |
|||
|
|||
showAdd() { |
|||
this.viewTitle = "【新增】产品信息"; |
|||
this.disabledCode=false |
|||
this.clearList() |
|||
}, |
|||
clearList(){ |
|||
this.locationForm = { |
|||
barCode: "", |
|||
name: "", |
|||
anotherName: "", |
|||
value: "", |
|||
netWeight: "", |
|||
roughWeight: "", |
|||
effectiveDays: "", |
|||
remarks: "", |
|||
} |
|||
}, |
|||
showEdit(row) { |
|||
this.viewTitle = "【修改】产品信息"; |
|||
this.disabledCode=true |
|||
this.locationForm=row |
|||
}, |
|||
async updataProduct () { |
|||
this.locationForm = { |
|||
name: "", |
|||
anotherName: "", |
|||
} |
|||
const { data: result } = await this.$http.put('/product/updataProduct', this.locationForm) |
|||
if (result.status !== 200) return this.$message.error('更新数据失败') |
|||
this.$message.success('更新成功') |
|||
this.handleReturn('true') |
|||
}, |
|||
async addProduct () { |
|||
const { data: result } = await this.$http.post('/product/addProduct', this.addProductForm) |
|||
if (result.status !== 200) return this.$message.error('添加产品失败') |
|||
this.$message.success('添加产品成功') |
|||
this.handleReturn('true') |
|||
}, |
|||
createBarCode () { |
|||
var now = new Date() |
|||
var nowstr = now.getTime() |
|||
this.locationForm.barCode = 'P' + now.getTime() |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
.box-card { |
|||
margin-left: 60px; |
|||
margin-right: 60px; |
|||
min-width: 70%; |
|||
margin-top: 20px; |
|||
|
|||
.item { |
|||
display: flex; |
|||
flex-direction: row; |
|||
align-items: center; |
|||
margin-top: 15px; |
|||
height: 40px; |
|||
line-height: 40px; |
|||
|
|||
.item_text { |
|||
flex: 0.8; |
|||
font-size: 18px; |
|||
text-align: right; |
|||
} |
|||
|
|||
.item_input { |
|||
flex: 4; |
|||
font-size: 16px; |
|||
margin-left: 10px; |
|||
margin-right: 80px; |
|||
} |
|||
.item_inputs { |
|||
flex: 4; |
|||
font-size: 16px; |
|||
margin-left: 10px; |
|||
margin-right: 28px; |
|||
} |
|||
|
|||
.item_left_input { |
|||
width: 20%; |
|||
} |
|||
|
|||
.item_left_text { |
|||
height: 30px; |
|||
margin-left: 20px; |
|||
line-height: 30px; |
|||
color: #018AD2; |
|||
padding: 0px 15px; |
|||
border: 1.5px solid #018AD2; |
|||
border-radius: 5px; |
|||
|
|||
} |
|||
|
|||
.item_right { |
|||
flex: 1; |
|||
justify-items: center; |
|||
|
|||
.item_right_list_text { |
|||
font-size: 16px; |
|||
} |
|||
|
|||
.item_right_list_delect { |
|||
color: #5E94FF; |
|||
margin-left: 20px; |
|||
font-size: 16px; |
|||
text-decoration: underline; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
</style> |
|||
|
|||
<template> |
|||
<div> |
|||
|
|||
<div class="tab-header webtop"> |
|||
<!-- 标题 --> |
|||
<div>{{ viewTitle }}</div> |
|||
<!-- start 添加修改按钮 --> |
|||
<div> |
|||
<el-button type="primary" size="small" @click="saveOrUpdate">保存</el-button> |
|||
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button> |
|||
</div> |
|||
<!-- end 添加修改按钮 --> |
|||
<!-- end 详情按钮 --> |
|||
</div> |
|||
<div class="listconadd"> |
|||
|
|||
<el-card class="box-card"> |
|||
<div class="item"> |
|||
<span class="item_text">条码:</span> |
|||
<el-input v-model="locationForm.barCode" :disabled="disabledCode" placeholder="" class="item_inputs" clearable /> |
|||
<el-button type="primary" size="small" @click="createBarCode" :disabled="disabledCode">自动</el-button> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">商品名:</span> |
|||
<el-input v-model="locationForm.name" :disabled="disabledCode" placeholder="" class="item_input" clearable /> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">别名:</span> |
|||
<el-input v-model="locationForm.anotherName" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">价值:</span> |
|||
<el-input v-model="locationForm.value" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">净重:</span> |
|||
<el-input v-model="locationForm.netWeight" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">毛重:</span> |
|||
<el-input v-model="locationForm.roughWeight" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">有效天数:</span> |
|||
<el-input v-model="locationForm.effectiveDays" class="item_input" clearable></el-input> |
|||
</div> |
|||
<div class="item"> |
|||
<span class="item_text">备注:</span> |
|||
<el-input v-model="locationForm.remarks" class="item_input" clearable></el-input> |
|||
</div> |
|||
</el-card> |
|||
</div> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
data() { |
|||
return { |
|||
submitdisabled: false, |
|||
disabledCode: false, |
|||
locationForm: { |
|||
barCode: "", |
|||
name: "", |
|||
anotherName: "", |
|||
value: "", |
|||
netWeight: "", |
|||
roughWeight: "", |
|||
effectiveDays: "", |
|||
remarks: "", |
|||
}, |
|||
viewTitle: "【新增】产品信息", |
|||
} |
|||
}, |
|||
created() { |
|||
|
|||
}, |
|||
methods: { |
|||
saveOrUpdate() { |
|||
if (this.viewTitle === "【新增】产品信息") return this.addProduct() |
|||
if (this.viewTitle === "【修改】产品信息") { |
|||
this.updataProduct() |
|||
} |
|||
|
|||
}, |
|||
handleReturn(isreload) { |
|||
if (isreload === 'true') this.$emit('reloadlist') |
|||
this.clearList() |
|||
this.$emit('doback') |
|||
}, |
|||
|
|||
showAdd() { |
|||
this.viewTitle = "【新增】产品信息"; |
|||
this.disabledCode=false |
|||
this.clearList() |
|||
}, |
|||
clearList(){ |
|||
this.locationForm = { |
|||
barCode: "", |
|||
name: "", |
|||
anotherName: "", |
|||
value: "", |
|||
netWeight: "", |
|||
roughWeight: "", |
|||
effectiveDays: "", |
|||
remarks: "", |
|||
} |
|||
}, |
|||
showEdit(row) { |
|||
this.viewTitle = "【修改】产品信息"; |
|||
this.disabledCode=true |
|||
this.locationForm=row |
|||
}, |
|||
async updataProduct () { |
|||
this.locationForm = { |
|||
name: "", |
|||
anotherName: "", |
|||
} |
|||
const { data: result } = await this.$http.put('/product/updataProduct', this.locationForm) |
|||
if (result.status !== 200) return this.$message.error('更新数据失败') |
|||
this.$message.success('更新成功') |
|||
this.handleReturn('true') |
|||
}, |
|||
async addProduct () { |
|||
const { data: result } = await this.$http.post('/product/addProduct', this.locationForm) |
|||
if (result.status !== 200) return this.$message.error('添加产品失败') |
|||
this.$message.success('添加产品成功') |
|||
this.handleReturn('true') |
|||
}, |
|||
createBarCode () { |
|||
var now = new Date() |
|||
var nowstr = now.getTime() |
|||
this.locationForm.barCode = 'P' + now.getTime() |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
.box-card { |
|||
margin-left: 60px; |
|||
margin-right: 60px; |
|||
min-width: 70%; |
|||
margin-top: 20px; |
|||
|
|||
.item { |
|||
display: flex; |
|||
flex-direction: row; |
|||
align-items: center; |
|||
margin-top: 15px; |
|||
height: 40px; |
|||
line-height: 40px; |
|||
|
|||
.item_text { |
|||
flex: 0.8; |
|||
font-size: 18px; |
|||
text-align: right; |
|||
} |
|||
|
|||
.item_input { |
|||
flex: 4; |
|||
font-size: 16px; |
|||
margin-left: 10px; |
|||
margin-right: 80px; |
|||
} |
|||
.item_inputs { |
|||
flex: 4; |
|||
font-size: 16px; |
|||
margin-left: 10px; |
|||
margin-right: 28px; |
|||
} |
|||
|
|||
.item_left_input { |
|||
width: 20%; |
|||
} |
|||
|
|||
.item_left_text { |
|||
height: 30px; |
|||
margin-left: 20px; |
|||
line-height: 30px; |
|||
color: #018AD2; |
|||
padding: 0px 15px; |
|||
border: 1.5px solid #018AD2; |
|||
border-radius: 5px; |
|||
|
|||
} |
|||
|
|||
.item_right { |
|||
flex: 1; |
|||
justify-items: center; |
|||
|
|||
.item_right_list_text { |
|||
font-size: 16px; |
|||
} |
|||
|
|||
.item_right_list_delect { |
|||
color: #5E94FF; |
|||
margin-left: 20px; |
|||
font-size: 16px; |
|||
text-decoration: underline; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
</style> |
|||
|
Loading…
Reference in new issue