完善产品管理
This commit is contained in:
@@ -22,12 +22,10 @@ export function selAllByOrgSidPath(data) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/oms/apiadmin/sysstafforg/selByOrgPath',
|
url: '/oms/apiadmin/sysstafforg/selByOrgPath',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params: data,
|
params: data
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 根据部门sid获取客户信息
|
// 根据部门sid获取客户信息
|
||||||
export function chooseCustomerList(data) {
|
export function chooseCustomerList(data) {
|
||||||
return request({
|
return request({
|
||||||
@@ -107,7 +105,6 @@ export function getWarehouseareas(data) {
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询商品分页列表
|
// 查询商品分页列表
|
||||||
@@ -121,3 +118,13 @@ export function getGoodsListAllByOrg(params) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询商品管理中的信息(商品名称、商品编码)
|
||||||
|
export function getGoodsForProduct(params) {
|
||||||
|
return request({
|
||||||
|
url: '/oms/apiadmin/base/basegoodsspu/getGoodsForProduct',
|
||||||
|
method: 'post',
|
||||||
|
data: params,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
36
src/api/goods/product/product.js
Normal file
36
src/api/goods/product/product.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
// 查询分页列表
|
||||||
|
listPage: function(params) {
|
||||||
|
return request({
|
||||||
|
url: '/oms/v1/product/listPage',
|
||||||
|
method: 'post',
|
||||||
|
data: params,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fetchBySid: function(data) {
|
||||||
|
return request({
|
||||||
|
url: '/oms/v1/product/fetchBySid',
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
deleteBySids: function(data) {
|
||||||
|
return request({
|
||||||
|
url: '/oms/v1/product/delBySids',
|
||||||
|
method: 'DELETE',
|
||||||
|
data: data,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
saveOrUpdate: function(data) {
|
||||||
|
return request({
|
||||||
|
url: '/oms/v1/product/saveOrUpdate',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -172,7 +172,16 @@ export const constantRoutes = [
|
|||||||
},
|
},
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/product/product',
|
||||||
|
name: 'Product',
|
||||||
|
component: () => import('@/views/goods/product/product'),
|
||||||
|
meta: {
|
||||||
|
title: '产品管理',
|
||||||
|
icon: 'product-add'
|
||||||
|
},
|
||||||
|
hidden: true
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
307
src/views/goods/product/product.vue
Normal file
307
src/views/goods/product/product.vue
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<!--列表页面-->
|
||||||
|
<div v-show="viewState == 1">
|
||||||
|
<button-bar view-title="产品管理" ref="btnbar" :btndisabled="btndisabled" @btnhandle="btnHandle"/>
|
||||||
|
<!--Start查询列表部分-->
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="searchcon">
|
||||||
|
<el-button size="small" class="searchbtn" @click="clicksearchShow">{{ searchxianshitit }}</el-button>
|
||||||
|
<div v-show="isSearchShow" class="search">
|
||||||
|
<el-form ref="listQueryform" :inline="true" :model="listQuery" label-width="100px" class="tab-header">
|
||||||
|
<el-form-item label="产品名称">
|
||||||
|
<el-input v-model="listQuery.params.productName" placeholder="" clearable/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="比例类别">
|
||||||
|
<el-select class="addinputInfo" v-model="listQuery.params.rateType" placeholder="请选择" clearable filterable>
|
||||||
|
<el-option v-for="item in rateType_list" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div class="btn" style="text-align: center;">
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="small" @click="handleFilter">查询</el-button>
|
||||||
|
<el-button type="primary" icon="el-icon-refresh" size="small" @click="handleReset">重置</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--End查询列表部分-->
|
||||||
|
<div class="listtop">
|
||||||
|
<div class="tit">产品列表</div>
|
||||||
|
<pageye v-show="list.length > 0" :total="listQuery.total" :page.sync="listQuery.current" :limit.sync="listQuery.size" class="pagination" @pagination="getList"/>
|
||||||
|
</div>
|
||||||
|
<!--Start 主页面主要部分 -->
|
||||||
|
<div class="">
|
||||||
|
<el-table :key="tableKey" v-loading="listLoading" :data="list" border style="width: 100%;" row-key="csid" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" :cell-class-name="cellcb" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" align="center" width="50" />
|
||||||
|
<el-table-column label="序号" prop="parentIndex" align="center" width="100"/>
|
||||||
|
<el-table-column prop="productCode" label="产品编码" align="center" min-width="120" />
|
||||||
|
<el-table-column prop="productName" label="产品名称" align="center" min-width="160" />
|
||||||
|
<el-table-column prop="rateType" label="比例类别" align="center" min-width="100">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ scope.row.rateType == '0' ? '产出率' : scope.row.rateType == '1' ? '配比' :'' }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="materialName" label="原料编码" align="center" min-width="120" />
|
||||||
|
<el-table-column prop="materialCode" label="原料名称" align="center" min-min-width="160" />
|
||||||
|
<el-table-column prop="rate" label="比例(%)" align="center" min-width="60" />
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<!--End 主页面主要部分-->
|
||||||
|
<div class="pages">
|
||||||
|
<div class="tit"/>
|
||||||
|
<!-- 翻页 -->
|
||||||
|
<pagination v-show="list.length > 0" :total="listQuery.total" :page.sync="listQuery.current" :limit.sync="listQuery.size" class="pagination" @pagination="getList"/>
|
||||||
|
</div>
|
||||||
|
<!--End查询列表部分-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--新增及修改 -->
|
||||||
|
<productAdd v-show="viewState == 2 || viewState == 3" ref="divAdd" @doback="resetState" @reloadlist="getList"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Pagination from '@/components/pagination'
|
||||||
|
import pageye from '@/components/pagination/pageye'
|
||||||
|
import ButtonBar from '@/components/ButtonBar'
|
||||||
|
import req from '@/api/goods/product/product'
|
||||||
|
import productAdd from './productAdd'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'SalesOrder',
|
||||||
|
components: {
|
||||||
|
Pagination,
|
||||||
|
pageye,
|
||||||
|
ButtonBar,
|
||||||
|
productAdd
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
btndisabled: false,
|
||||||
|
btnList: [
|
||||||
|
{
|
||||||
|
type: 'primary',
|
||||||
|
size: 'small',
|
||||||
|
icon: 'plus',
|
||||||
|
btnKey: 'toAdd',
|
||||||
|
btnLabel: '新增'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'primary',
|
||||||
|
size: 'small',
|
||||||
|
icon: 'edit',
|
||||||
|
btnKey: 'toEdit',
|
||||||
|
btnLabel: '编辑'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'danger',
|
||||||
|
size: 'small',
|
||||||
|
icon: 'del',
|
||||||
|
btnKey: 'doDel',
|
||||||
|
btnLabel: '删除'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'info',
|
||||||
|
size: 'small',
|
||||||
|
icon: 'cross',
|
||||||
|
btnKey: 'doClose',
|
||||||
|
btnLabel: '关闭'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
isSearchShow: false,
|
||||||
|
searchxianshitit: '显示查询条件',
|
||||||
|
viewState: 1, // 1、列表 2、新增 3、编辑 4、查看
|
||||||
|
tableKey: 0,
|
||||||
|
list: [],
|
||||||
|
sids: [], // 用于导出的时候保存已选择的SIDs
|
||||||
|
rateType_list: [
|
||||||
|
{
|
||||||
|
dictKey: '0',
|
||||||
|
dictValue: '产出率'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dictKey: '1',
|
||||||
|
dictValue: '配比'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
FormLoading: false,
|
||||||
|
listLoading: false,
|
||||||
|
// 翻页
|
||||||
|
listQuery: {
|
||||||
|
current: 1,
|
||||||
|
size: 5,
|
||||||
|
total: 0,
|
||||||
|
params: {
|
||||||
|
productName: '',
|
||||||
|
rateType: '',
|
||||||
|
menuUrl: '',
|
||||||
|
orgPath: '',
|
||||||
|
userSid: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
// 初始化变量
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$refs['btnbar'].setButtonList(this.btnList)
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 搜索条件效果
|
||||||
|
clicksearchShow() {
|
||||||
|
this.isSearchShow = !this.isSearchShow
|
||||||
|
if (this.isSearchShow) {
|
||||||
|
this.searchxianshitit = '隐藏查询条件'
|
||||||
|
} else {
|
||||||
|
this.searchxianshitit = '显示查询条件'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
btnHandle(btnKey) {
|
||||||
|
console.log('XXXXXXXXXXXXXXX ' + btnKey)
|
||||||
|
switch (btnKey) {
|
||||||
|
case 'toAdd':
|
||||||
|
this.toAdd()
|
||||||
|
break
|
||||||
|
case 'toEdit':
|
||||||
|
this.toEdit()
|
||||||
|
break
|
||||||
|
case 'doDel':
|
||||||
|
this.doDel()
|
||||||
|
break
|
||||||
|
case 'doClose':
|
||||||
|
this.doClose()
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 信息条数 获取点击时当前的sid
|
||||||
|
handleSelectionChange(row) {
|
||||||
|
const aa = []
|
||||||
|
row.forEach(element => {
|
||||||
|
aa.push(element.sid)
|
||||||
|
})
|
||||||
|
this.sids = aa
|
||||||
|
},
|
||||||
|
// 设置表格中的复选框是否显示
|
||||||
|
cellcb({ row }) {
|
||||||
|
return row.productName === '' ? 'myCell' : ''
|
||||||
|
},
|
||||||
|
// 表中序号
|
||||||
|
indexMethod(index) {
|
||||||
|
var pagestart = (this.listQuery.current - 1) * this.listQuery.size
|
||||||
|
var pageindex = index + 1 + pagestart
|
||||||
|
return pageindex
|
||||||
|
},
|
||||||
|
// 查询列表信息
|
||||||
|
getList() {
|
||||||
|
this.listLoading = true
|
||||||
|
this.listQuery.params.userSid = window.sessionStorage.getItem('userSid')
|
||||||
|
this.listQuery.params.orgPath = window.sessionStorage.getItem('defaultOrgPath')
|
||||||
|
this.listQuery.params.menuUrl = this.$route.path
|
||||||
|
req.listPage(this.listQuery).then(response => {
|
||||||
|
this.listLoading = false
|
||||||
|
if (response.success) {
|
||||||
|
this.list = response.data.records
|
||||||
|
this.listQuery.total = response.data.total
|
||||||
|
if (this.list.length > 0) {
|
||||||
|
this.list.forEach((item, index) => {
|
||||||
|
item.parentIndex = index + 1
|
||||||
|
if (item.children) {
|
||||||
|
item.children.forEach((it, ind) => {
|
||||||
|
it.parentIndex = item.parentIndex + '-' + (ind + 1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.list = []
|
||||||
|
this.listQuery.total = 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 查询按钮
|
||||||
|
handleFilter() {
|
||||||
|
this.listQuery.current = 1
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
// 点击重置
|
||||||
|
handleReset() {
|
||||||
|
this.listQuery = {
|
||||||
|
current: 1,
|
||||||
|
size: 5,
|
||||||
|
total: 0,
|
||||||
|
params: {
|
||||||
|
productName: '',
|
||||||
|
rateType: '',
|
||||||
|
menuUrl: '',
|
||||||
|
orgPath: '',
|
||||||
|
userSid: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
toAdd() {
|
||||||
|
this.viewState = 2
|
||||||
|
this.$refs['divAdd'].showAdd()
|
||||||
|
},
|
||||||
|
toEdit() {
|
||||||
|
if (this.sids.length === 1) {
|
||||||
|
this.viewState = 3
|
||||||
|
this.$refs['divAdd'].showEdit(this.sids[0])
|
||||||
|
} else {
|
||||||
|
this.$message({ showClose: true, type: 'error', message: '请选择一条记录进行操作' })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toInfo(row) {
|
||||||
|
this.viewState = 4
|
||||||
|
this.$refs['divInfo'].showInfo(row)
|
||||||
|
},
|
||||||
|
// 删除
|
||||||
|
doDel() {
|
||||||
|
if (this.sids.length === 0) {
|
||||||
|
this.$message({ showClose: true, type: 'error', message: '请选择至少一条记录进行删除操作' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const tip = '请确认是否删除所选 ' + this.sids.length + ' 条记录?'
|
||||||
|
this.$confirm(tip, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
const loading = this.$loading({
|
||||||
|
lock: true,
|
||||||
|
text: 'Loading',
|
||||||
|
spinner: 'el-icon-loading',
|
||||||
|
background: 'rgba(0, 0, 0, 0.7)'
|
||||||
|
})
|
||||||
|
req.deleteBySids(this.sids).then((resp) => {
|
||||||
|
if (resp.success) {
|
||||||
|
this.$message({ type: 'success', message: resp.msg, showClose: true })
|
||||||
|
}
|
||||||
|
this.getList()
|
||||||
|
loading.close()
|
||||||
|
}).catch(e => {
|
||||||
|
loading.close()
|
||||||
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 修改、编辑、详情返回列表页面
|
||||||
|
resetState() {
|
||||||
|
this.viewState = 1
|
||||||
|
},
|
||||||
|
doClose() {
|
||||||
|
this.$store.dispatch('tagsView/delView', this.$route)
|
||||||
|
this.$router.go(-1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
/deep/ .myCell .el-checkbox__input {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
250
src/views/goods/product/productAdd.vue
Normal file
250
src/views/goods/product/productAdd.vue
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<div v-show="viewState == 1">
|
||||||
|
<div class="tab-header webtop">
|
||||||
|
<div>{{ viewTitle }}</div>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" size="small" :disabled="submitdisabled" @click="handleSave()">保存</el-button>
|
||||||
|
<el-button type="info" size="small" @click="handleReturn()">关闭</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="listconadd">
|
||||||
|
<el-form ref="form_obj" :model="formobj" :rules="rules" class="formaddcopy02">
|
||||||
|
<el-row style="border-top: 1px solid #e0e3eb">
|
||||||
|
<el-col :span="12">
|
||||||
|
<div class="span-sty"><span class="icon">*</span>产品名称</div>
|
||||||
|
<el-form-item prop="goodsSid">
|
||||||
|
<el-select class="addinputInfo" v-model="formobj.goodsSid" placeholder="请选择" @change="productChange" clearable filterable>
|
||||||
|
<el-option v-for="item in product_list" :key="item.sid" :label="item.goodsName" :value="item.sid"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<div class="span-sty">比例类型</div>
|
||||||
|
<el-form-item>
|
||||||
|
<el-radio-group class="addinputInfo" v-model="formobj.rateType">
|
||||||
|
<el-radio label="0">产出率</el-radio>
|
||||||
|
<el-radio label="1">配比</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<div class="title titleOne">
|
||||||
|
<div>原料列表</div>
|
||||||
|
<div>
|
||||||
|
<el-button style="margin-left: 10px" type="primary" class="btntopblueline" size="small" @click="productAdd">添加</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<el-table :key="tableKey" :data="formobj.list" :index="index" border style="width: 100%">
|
||||||
|
<el-table-column fixed width="60" label="序号" type="index" :index="index + 1" align="center" />
|
||||||
|
<el-table-column label="操作" align="center" width="80">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="danger" size="small" @click="productDelete(scope.$index)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="materialName" label="原料名称" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-select v-model="scope.row.materialSid" placeholder="请选择" @change="materialChange(scope.row, $event)" clearable filterable>
|
||||||
|
<el-option v-for="item in product_list" :disabled="item.goodsCode == formobj.productCode" :key="item.sid" :label="item.goodsName" :value="item.sid"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="materialCode" label="原料编码" align="center" />
|
||||||
|
<el-table-column v-if="formobj.rateType == '0'" label="产出率(%)" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input @keyup.native="scope.row.rate = getNumber(scope.row.rate, 2)" v-model="scope.row.rate" clearable placeholder="" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column v-if="formobj.rateType == '1'" label="配比(%)" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input @keyup.native="scope.row.rate = getNumber(scope.row.rate, 2)" v-model="scope.row.rate" clearable placeholder="" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import req from '@/api/goods/product/product'
|
||||||
|
import { getGoodsForProduct } from '@/api/Common/dictcommons'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ProductAdd',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
viewTitle: '',
|
||||||
|
viewState: 1,
|
||||||
|
submitdisabled: false,
|
||||||
|
tableKey: 1,
|
||||||
|
index: 0,
|
||||||
|
product_list: [],
|
||||||
|
formobj: {
|
||||||
|
sid: '',
|
||||||
|
createBySid: '',
|
||||||
|
createOrgSid: '',
|
||||||
|
useOrgSid: '',
|
||||||
|
goodsSid: '',
|
||||||
|
productName: '',
|
||||||
|
productCode: '',
|
||||||
|
rateType: '',
|
||||||
|
list: []
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
goodsSid: [{ required: true, message: '产品名称不能为空', trigger: 'change' }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
getGoodsForProduct({ queryName: '', useOrgSid: window.sessionStorage.getItem('defaultDeptSid') }).then((res) => {
|
||||||
|
if (res.success) {
|
||||||
|
this.product_list = res.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getNumber(val, limit) {
|
||||||
|
val = val.replace(/[^0-9.]/g, '') // 保留数字
|
||||||
|
val = val.replace(/^00/, '0.') // 开头不能有两个0
|
||||||
|
val = val.replace(/^\./g, '0.') // 开头为小数点转换为0.
|
||||||
|
val = val.replace(/\.{2,}/g, '.') // 两个以上的小数点转换成一个
|
||||||
|
val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.'); // 只保留一个小数点
|
||||||
|
/^0\d+/.test(val) ? val = val.slice(1) : '' // 两位以上数字开头不能为0
|
||||||
|
const str = '^(\\d+)\\.(\\d{' + limit + '}).*$'
|
||||||
|
const reg = new RegExp(str)
|
||||||
|
if (limit === 0) {
|
||||||
|
// 不需要小数点
|
||||||
|
val = val.replace(reg, '$1')
|
||||||
|
} else {
|
||||||
|
// 通过正则保留小数点后指定的位数
|
||||||
|
val = val.replace(reg, '$1.$2')
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
},
|
||||||
|
showAdd() {
|
||||||
|
this.viewTitle = '【新增】产品'
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['form_obj'].clearValidate()
|
||||||
|
})
|
||||||
|
this.init()
|
||||||
|
this.formobj.createBySid = window.sessionStorage.getItem('userSid')
|
||||||
|
this.formobj.createOrgSid = window.sessionStorage.getItem('orgSid')
|
||||||
|
this.formobj.useOrgSid = window.sessionStorage.getItem('defaultDeptSid')
|
||||||
|
this.formobj.rateType = '0'
|
||||||
|
},
|
||||||
|
showEdit(sid) {
|
||||||
|
this.viewTitle = '【编辑】产品'
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['form_obj'].clearValidate()
|
||||||
|
})
|
||||||
|
this.init()
|
||||||
|
req.fetchBySid({ sid: sid }).then((res) => {
|
||||||
|
if (res.success) {
|
||||||
|
this.formobj = res.data
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
productChange(value) {
|
||||||
|
const choose = this.product_list.filter((item) => item.sid === value)
|
||||||
|
if (choose !== null && choose.length > 0) {
|
||||||
|
this.formobj.productName = choose[0].goodsName
|
||||||
|
this.formobj.productCode = choose[0].goodsCode
|
||||||
|
} else {
|
||||||
|
this.formobj.productName = ''
|
||||||
|
this.formobj.productCode = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
productAdd() {
|
||||||
|
this.formobj.list.push({
|
||||||
|
sid: '',
|
||||||
|
materialSid: '',
|
||||||
|
materialName: '',
|
||||||
|
materialCode: '',
|
||||||
|
rate: ''
|
||||||
|
})
|
||||||
|
},
|
||||||
|
materialChange(row, value) {
|
||||||
|
const choose = this.product_list.filter((item) => item.sid === value)
|
||||||
|
if (choose !== null && choose.length > 0) {
|
||||||
|
row.materialName = choose[0].goodsName
|
||||||
|
row.materialCode = choose[0].goodsCode
|
||||||
|
} else {
|
||||||
|
row.materialName = ''
|
||||||
|
row.materialCode = ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
productDelete(index) {
|
||||||
|
this.formobj.list.splice(index, 1)
|
||||||
|
},
|
||||||
|
handleSave() {
|
||||||
|
this.$refs['form_obj'].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.formobj.list.length === 0) {
|
||||||
|
this.$message({ showClose: true, type: 'error', message: '原料列表不能为空' })
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < this.formobj.list.length; i++) {
|
||||||
|
if (this.formobj.list[i].materialCode === this.formobj.list[this.formobj.list.length - 1].materialCode) {
|
||||||
|
this.$message({ showClose: true, type: 'error', message: '原料列表中需选择不同的原料进行操作' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.submitdisabled = true
|
||||||
|
req.saveOrUpdate(this.formobj).then((res) => {
|
||||||
|
if (res.success) {
|
||||||
|
this.$message({ showClose: true, type: 'success', message: '保存成功' })
|
||||||
|
this.handleReturn('true')
|
||||||
|
} else {
|
||||||
|
this.submitdisabled = false
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.submitdisabled = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleReturn(isreload) {
|
||||||
|
if (isreload === 'true') this.$emit('reloadlist')
|
||||||
|
this.formobj = {
|
||||||
|
sid: '',
|
||||||
|
createBySid: '',
|
||||||
|
createOrgSid: '',
|
||||||
|
useOrgSid: '',
|
||||||
|
goodsSid: '',
|
||||||
|
productName: '',
|
||||||
|
productCode: '',
|
||||||
|
rateType: '',
|
||||||
|
list: []
|
||||||
|
}
|
||||||
|
this.$emit('doback')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.span-sty {
|
||||||
|
width: 130px !important;
|
||||||
|
}
|
||||||
|
.addinputInfo {
|
||||||
|
margin-left: 120px !important;
|
||||||
|
}
|
||||||
|
.titleOne {
|
||||||
|
padding: 7px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
/deep/ .el-form-item__error {
|
||||||
|
margin-left: 120px !important;
|
||||||
|
}
|
||||||
|
.formaddcopy02 .el-row .el-col /deep/ .el-form-item .el-radio-group {
|
||||||
|
display: inline;
|
||||||
|
line-height: 1px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user