| | |
| | | <template> |
| | | <win-md :title="setting.title" @close="close" :width="'800px'"> |
| | | <win-md :title="setting.title" @close="close" :width="'800px'" :loading="loading"> |
| | | <el-form ref="ruleForm" :model="formData" :rules="rules" class="demo-ruleForm" label-width="100px"> |
| | | <el-form-item label="物品编号"> |
| | | <el-input v-model="formData.goodsCode" disabled clearable maxlength="20" show-word-limit style="width: 100%"/> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="物品编号"> |
| | | <el-input v-model="formData.goodsCode" disabled clearable maxlength="20" show-word-limit style="width: 100%"/> |
| | | </el-form-item>--> |
| | | <el-form-item label="物品名称" prop="goodsName"> |
| | | <el-input v-model="formData.goodsName" clearable maxlength="20" show-word-limit style="width: 100%"/> |
| | | <el-input v-model="formData.goodsName" placeholder="请输入物品名称" clearable maxlength="20" show-word-limit |
| | | style="width: 100%"/> |
| | | </el-form-item> |
| | | <el-form-item label="分类" prop="categoryId"> |
| | | <el-select v-model="formData.categoryId" clearable placeholder="请选择" style="width: 100%"> |
| | | <el-option v-for="item in categoryList" :key="item.id" :label="item.categoryName" :value="item.id"></el-option> |
| | | </el-select> |
| | | <el-form-item label="物品分类" prop="categoryId"> |
| | | <el-cascader |
| | | clearable |
| | | filterable |
| | | placeholder="请选择物品分类" |
| | | v-model="formData.categoryId" |
| | | :options="categoryList" |
| | | :props="{emitPath: false,value: 'id'}" |
| | | style="width: 100%"/> |
| | | </el-form-item> |
| | | <el-form-item style="margin-left: -100px;" v-for="(m, i) in formData.models"> |
| | | <el-form-item label="规格型号" prop="modelName" style="float: left;"> |
| | | <el-input v-model="m.modelName" clearable maxlength="20" show-word-limit style="width: 100%"/> |
| | | </el-form-item> |
| | | <el-form-item label="单位" prop="unit" style="float: left;"> |
| | | <el-input v-model="m.unit" clearable maxlength="20" show-word-limit style="width: 100%"/> |
| | | </el-form-item> |
| | | <my-button name="新增型号" type="" @click="addCode"/> |
| | | <my-button name="删除" type="" @click="delCode(i)"/> |
| | | </el-form-item> |
| | | <el-row :gutter="20" v-for="(m, i) in formData.models"> |
| | | <el-col :span="9"> |
| | | <el-form-item label="规格型号" :prop="`models.${i}.modelName`" :rules="rules.modelName"> |
| | | <el-input :disabled="!!setting.id" v-model="m.modelName" placeholder="请输入规格型号名称" clearable maxlength="20" show-word-limit |
| | | style="width: 100%"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="9"> |
| | | <el-form-item label="单位" :prop="`models.${i}.unit`" :rules="rules.unit"> |
| | | <el-input v-model="m.unit" placeholder="请输入单位" clearable maxlength="20" show-word-limit |
| | | style="width: 100%"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <my-button :key="'d'+i" v-if="formData.models.length>1" name="删除" type="danger" @click="delCode(i)"/> |
| | | <my-button :key="'a'+i" v-if="i===formData.models.length-1" name="新增型号" type="" @click="addCode"/> |
| | | </el-col> |
| | | </el-row> |
| | | <el-form-item label="状态" prop="states"> |
| | | <el-radio-group v-model="formData.states"> |
| | | <el-radio :label="1" border>启用</el-radio> |
| | |
| | | <script> |
| | | import winMd from '@/components/win/win-md' |
| | | import myButton from '@/components/myButton/myButton' |
| | | import * as finsystenant from '@/api/baseSetting/finsystenant' |
| | | import {addGoods,editGoods,goodsDetail} from "@/api/foudation/material"; |
| | | import {getTree} from '@/api/foudation/classification'; |
| | | import {mapGetters} from 'vuex' |
| | | |
| | | export default { |
| | | components: {winMd, myButton}, |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | categoryList:[], |
| | | loading: true, |
| | | categoryList: [], |
| | | checkAll: false, |
| | | checkedList: [], |
| | | formData: { |
| | | radio1: '', |
| | | code: '', |
| | | name: '', |
| | | goodsName: '', |
| | | states: 1, |
| | | summary: '', |
| | | categoryId: null, |
| | | models:[ |
| | | agencyId: '', |
| | | agencyName: '', |
| | | models: [ |
| | | { |
| | | modelName:'', |
| | | unit:'' |
| | | modelName: '', |
| | | unit: '' |
| | | } |
| | | ] |
| | | }, |
| | | rules: { |
| | | name: [ |
| | | goodsName: [ |
| | | {required: true, message: '请输入物品名称', trigger: 'blur'} |
| | | ], |
| | | categoryId: [ |
| | | {required: true, message: '请选择物品分类', trigger: 'blur'} |
| | | ], |
| | | modelName: [ |
| | | {required: true, message: '请输入规格名称', trigger: 'blur'} |
| | | ], |
| | | unit: [ |
| | | {required: true, message: '请输入单位', trigger: 'blur'} |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | this.tree_List() |
| | | if(this.setting.info){ |
| | | this.formData = Object.assign({},JSON.parse(this.setting.info)) |
| | | computed: { |
| | | ...mapGetters(['userInfo']) |
| | | }, |
| | | async created() { |
| | | if (this.setting.id) { |
| | | await goodsDetail(this.setting.id).then(res => { |
| | | this.formData = res |
| | | if (!this.formData.agencyId) { |
| | | this.formData.agencyId = this.userInfo.tenantId |
| | | this.formData.agencyName = this.userInfo.tenantName |
| | | } |
| | | }) |
| | | } |
| | | await this.tree_List() |
| | | this.loading = false |
| | | }, |
| | | methods: { |
| | | tree_List (){ |
| | | finsystenant.treeList().then(res => { |
| | | async tree_List() { |
| | | await getTree().then(res => { |
| | | if (res) { |
| | | console.log(res,'res'); |
| | | this.categoryList = res |
| | | } |
| | | }) |
| | | }, |
| | | addCode(){ |
| | | addCode() { |
| | | this.formData.models.push( |
| | | { |
| | | modelName:'', |
| | | unit:'' |
| | | } |
| | | { |
| | | modelName: '', |
| | | unit: '' |
| | | } |
| | | ) |
| | | }, |
| | | delCode(index){ |
| | | delCode(index) { |
| | | this.formData.models.splice(index, 1) |
| | | }, |
| | | getEditInfo(id){ |
| | | getEditInfo(id) { |
| | | |
| | | }, |
| | | close() { |
| | |
| | | this.$refs.ruleForm.validate((valid) => { |
| | | if (valid) { |
| | | const params = Object.assign({}, this.formData) |
| | | if(this.setting.id){ |
| | | if (this.loading) return |
| | | this.loading = true |
| | | if (this.setting.id) { |
| | | // 编辑接口 |
| | | finsystenant.editcode(params).then(res => { |
| | | editGoods(params).then(res => { |
| | | this.loading = false |
| | | if (res) { |
| | | this.$message.success('保存成功!') |
| | | this.close() |
| | |
| | | this.$message.error('保存失败') |
| | | } |
| | | }) |
| | | }else{ |
| | | } else { |
| | | params.orgId = this.setting.orgId |
| | | finsystenant.addcode(params).then(res => { |
| | | addGoods(params).then(res => { |
| | | this.loading = false |
| | | if (res) { |
| | | this.$message.success('保存成功!') |
| | | this.close() |