|
@@ -1,453 +1,453 @@
|
|
|
-<template>
|
|
|
- <el-dialog
|
|
|
- :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="false"
|
|
|
- :title="title"
|
|
|
- :append-to-body="true"
|
|
|
- :visible.sync="isVisible"
|
|
|
- :width="width"
|
|
|
- top="50px"
|
|
|
- >
|
|
|
- <el-form ref="form" :model="tenant" :rules="rules" label-position="right" label-width="130px">
|
|
|
- <el-form-item :label='$t("prepare.table.tools.no")+":"' prop="no">
|
|
|
- <el-input v-model="tenant.no" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.name")+":"' prop="name">
|
|
|
- <el-input v-model="tenant.name" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
-<!-- <el-form-item :label='$t("prepare.table.tools.category")+":"' prop="category" >-->
|
|
|
-<!-- <el-select style="width:100%" :placeholder='$t("common.pleaseSelect")' v-model="tenant.category.key" value @change="selectCategory($event)">-->
|
|
|
-<!-- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.METERIAL_CATEGORY" />-->
|
|
|
-<!-- </el-select>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
-<!-- <el-form-item :label='$t("prepare.table.tools.materialType")+":"' prop="materialType" v-show="materialTypeShowFlag">-->
|
|
|
-<!-- <el-select style="width:100%" :placeholder='$t("common.pleaseSelect")' v-model="tenant.materialType.key" value>-->
|
|
|
-<!-- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.MATERIAL_TYPE" />-->
|
|
|
-<!-- </el-select>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
-<!-- <el-form-item :label='$t("prepare.table.tools.brand")+":"' prop="brand">-->
|
|
|
-<!-- <el-select style="width:100%" :placeholder='$t("common.pleaseSelect")' v-model="tenant.brand.key" value>-->
|
|
|
-<!-- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.METERIAL_BRAND" />-->
|
|
|
-<!-- </el-select>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
- <el-form-item :label='$t("prepare.table.tools.materialType")+":"' prop="materialType">
|
|
|
- <el-input v-model="tenant.materialType" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.mapNo")+":"' prop="mapNo">
|
|
|
- <el-input v-model="tenant.mapNo" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.factory")+":"' prop="factory">
|
|
|
- <el-input v-model="tenant.factory" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.joinDate")+":"' prop="joinDate">
|
|
|
- <el-date-picker
|
|
|
- v-model="tenant.joinDate"
|
|
|
- type="date"
|
|
|
- value-format="yyyy-MM-dd"
|
|
|
- placeholder="">
|
|
|
- </el-date-picker>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.period")+":"' prop="period">
|
|
|
- <el-input-number v-model="tenant.period" :min="1" :max="1000" label="12"></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label="$t('prepare.table.tools.expiryDate')+':'" prop="expiryDate">
|
|
|
- <el-input-number v-model="tenant.expiryDate" :min="1" :max="1000" label="12"></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.num")+":"' prop="num">
|
|
|
- <el-input-number v-model="tenant.num" :min="1" :max="1000" label="1"></el-input-number>
|
|
|
- </el-form-item>
|
|
|
-
|
|
|
- <el-form-item :label='$t("prepare.table.tools.specification")+":"' v-show="false">
|
|
|
- <!-- 功能按钮 -->
|
|
|
- <el-row class="filter-container">
|
|
|
- <el-col>
|
|
|
- <el-button type="primary" icon="el-icon-plus" size="medium" @click="addRes">新增</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <!-- Table数据 -->
|
|
|
- <el-table
|
|
|
- ref="table"
|
|
|
- v-loading="loading"
|
|
|
- :data="tableData"
|
|
|
- border
|
|
|
- fit
|
|
|
- style="width: 100%;"
|
|
|
- @selection-change="onSelectChange"
|
|
|
- >
|
|
|
- <el-table-column prop="tradeMark" :label='$t("prepare.table.tools.tradeMark")' align="center" width="180px">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-input size="small" v-model="row.tradeMark" v-if="row.isEdit" :placeholder='$t("common.pleaseEnter")'></el-input>
|
|
|
- <span v-else>{{row.tradeMark}}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <!--<el-table-column prop="type" label="类型" width="120px">
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-select v-model="row.type" size="small" v-if="row.isEdit" placeholder="请选择类型">
|
|
|
- <el-option
|
|
|
- v-for="item in typeList"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- <span v-else="">{{row.type}}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>-->
|
|
|
- <el-table-column prop="specification" :label='$t("prepare.table.tools.specification")'>
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-input size="small" v-model="row.specification" v-if="row.isEdit" :placeholder='$t("common.pleaseEnter")'></el-input>
|
|
|
- <span v-else>{{row.specification}}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
- :label="$t('table.operation')"
|
|
|
- fixed="right"
|
|
|
- align="center"
|
|
|
- column-key="operation"
|
|
|
- width="100px"
|
|
|
- >
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <el-tooltip class="item" :content='$t("common.edit")' effect="dark" placement="top-start">
|
|
|
- <i
|
|
|
- class="el-icon-edit table-operation"
|
|
|
- style="color: #2db7f5;"
|
|
|
- @click="edit(row)"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
- <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
|
|
|
- <i
|
|
|
- class="el-icon-delete table-operation"
|
|
|
- style="color: #f50;"
|
|
|
- @click="singleDelete(row)"
|
|
|
- />
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item :label='$t("prepare.table.tools.status")+":"' prop="status">
|
|
|
- <template>
|
|
|
- <el-radio v-model="tenant.status" label="1">{{$t("common.status.valid")}}</el-radio>
|
|
|
- <el-radio v-model="tenant.status" label="0">{{$t("common.frozen")}}</el-radio>
|
|
|
- </template>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button plain type="warning" @click="isVisible = false">{{ $t('common.cancel') }}</el-button>
|
|
|
- <el-button plain type="primary" :disabled="confirmDisabled" @click="submitForm">{{ $t('common.confirm') }}</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
-</template>
|
|
|
-<script>
|
|
|
-// 【工具原材料管理】-API
|
|
|
-import frockMgrApi from "@/api/prepareProductMgr/frockMgr"
|
|
|
-
|
|
|
-export default {
|
|
|
- name: 'TenantEdit',
|
|
|
- props: {
|
|
|
- dialogVisible: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- default: ''
|
|
|
- }
|
|
|
- },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- loading: false,
|
|
|
- type: 'add',
|
|
|
- tableData: [],
|
|
|
- tenant: this.initTenant(),
|
|
|
- screenWidth: 0,
|
|
|
- width: this.initWidth(),
|
|
|
- confirmDisabled: false,
|
|
|
- materialTypeShowFlag: false,
|
|
|
- dicts: {
|
|
|
- METERIAL_BRAND: {}, //工具材料品牌
|
|
|
- METERIAL_CATEGORY: {}, //工具材料分类
|
|
|
- MATERIAL_TYPE: {} //工具材料毛坯成品分类
|
|
|
- },
|
|
|
- roles: [],
|
|
|
- rules: {
|
|
|
- no: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- ],
|
|
|
- name: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- ],
|
|
|
- // model: [
|
|
|
- // { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- // ],
|
|
|
- // category: [
|
|
|
- // { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- // ],
|
|
|
- joinDate: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- ],
|
|
|
- materialType: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- ],
|
|
|
- num: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- ],
|
|
|
- // brand: [
|
|
|
- // { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
- // ],
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- computed: {
|
|
|
- isVisible: {
|
|
|
- get () {
|
|
|
- return this.dialogVisible
|
|
|
- },
|
|
|
- set () {
|
|
|
- this.close()
|
|
|
- this.reset()
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- window.onresize = () => {
|
|
|
- return (() => {
|
|
|
- this.width = this.initWidth()
|
|
|
- })()
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 【新增】按钮-事件
|
|
|
- addRes(){
|
|
|
- this.tableData.push({
|
|
|
- key: "WKS_"+ Math.random(),
|
|
|
- id: "",
|
|
|
- tradeMark: "",
|
|
|
- specification: "",
|
|
|
- isEdit: true
|
|
|
- })
|
|
|
- },
|
|
|
- // Table的选择事件
|
|
|
- onSelectChange (selection) {
|
|
|
- this.selection = selection
|
|
|
- },
|
|
|
- // 【删除】按钮事件
|
|
|
- singleDelete(row){
|
|
|
- this.$confirm("删除数据后,将会消失,您的努力将白费,请确认删除?", this.$t("common.tips"), {
|
|
|
- distinguishCancelAndClose: true,
|
|
|
- confirmButtonText: "确认",
|
|
|
- cancelButtonText: "取消",
|
|
|
- type: "warning"
|
|
|
- }).then(() => {
|
|
|
- // 过滤符合条件的数据
|
|
|
- let arr = this.tableData.filter(item => item.key != row.key || item.id != row.id)
|
|
|
- // 给新的数据赋值
|
|
|
- this.tableData = arr;
|
|
|
- }).catch(() => {})
|
|
|
- },
|
|
|
- // 【修改】按钮事件
|
|
|
- edit(row){
|
|
|
- let list = new Array();
|
|
|
- this.tableData.forEach((item, index) => {
|
|
|
- // 当前编辑行
|
|
|
- if(!!item.id && item.id == row.id){
|
|
|
- item.isEdit = true
|
|
|
- }
|
|
|
- list.push(item)
|
|
|
- })
|
|
|
- // 赋值给当前
|
|
|
- this.tableData = list
|
|
|
- },
|
|
|
- initTenant () {
|
|
|
- return {
|
|
|
- model: '',
|
|
|
- name: '',
|
|
|
- category: {
|
|
|
- key: ''
|
|
|
- },
|
|
|
- brand: {
|
|
|
- key: ''
|
|
|
- },
|
|
|
- status: '1',
|
|
|
- period:12,
|
|
|
- expiryDate:12,
|
|
|
- num:1
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- selectCategory(id){
|
|
|
- if("04" === id){
|
|
|
- this.materialTypeShowFlag = true
|
|
|
- }else{
|
|
|
- this.materialTypeShowFlag = false
|
|
|
- }
|
|
|
- },
|
|
|
- initWidth () {
|
|
|
- this.screenWidth = document.body.clientWidth
|
|
|
- if (this.screenWidth < 991) {
|
|
|
- return '90%'
|
|
|
- } else if (this.screenWidth < 1400) {
|
|
|
- return '45%'
|
|
|
- } else {
|
|
|
- return '800px'
|
|
|
- }
|
|
|
- },
|
|
|
- setTenant (val, dicts) {
|
|
|
- if(val){
|
|
|
- this.tenant = { ...val }
|
|
|
- if("04" === this.tenant.category.key){
|
|
|
- this.materialTypeShowFlag = true
|
|
|
- }else{
|
|
|
- this.materialTypeShowFlag = false
|
|
|
- }
|
|
|
- // 根据id,查询规格列表数据
|
|
|
- //this.getSpecsList(val)
|
|
|
- }
|
|
|
- // 字典表
|
|
|
- this.dicts = dicts
|
|
|
- },
|
|
|
- close () {
|
|
|
- this.$emit('close')
|
|
|
- },
|
|
|
- reset () {
|
|
|
- // 先清除校验,再清除表单,不然有奇怪的bug
|
|
|
- this.$refs.form.clearValidate()
|
|
|
- this.$refs.form.resetFields()
|
|
|
- this.tenant = this.initTenant()
|
|
|
- this.tableData = [] //清空【规格】数据
|
|
|
- },
|
|
|
- submitForm () {
|
|
|
- // 验证规格必填
|
|
|
- /*let flag = false
|
|
|
-
|
|
|
- if(this.tableData.length > 0){
|
|
|
- this.tableData.map(item => {
|
|
|
- if(!item.specification){
|
|
|
- flag = true
|
|
|
- }
|
|
|
- })
|
|
|
- if(this.tenant.model ==''){
|
|
|
- flag = true
|
|
|
- }else{
|
|
|
- console.log(this.tenant.model)
|
|
|
- this.$message({
|
|
|
- message: this.$t("prepare.tips.addGg"),
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
- return
|
|
|
- } */
|
|
|
- // if(this.tenant.model ==''){
|
|
|
- // console.log(this.$t("prepare.tips.inputGg"))
|
|
|
- // this.$message({
|
|
|
- // message: this.$t("prepare.tips.inputGg"),
|
|
|
- // type: 'warning'
|
|
|
- // })
|
|
|
- // return
|
|
|
- // }
|
|
|
- // 添加规格数据
|
|
|
- // this.tenant.mtoolMeterialSpecsList = this.tableData
|
|
|
- //console.log("Form数据:", this.tenant)
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- this.confirmDisabled = true
|
|
|
- if (this.type === 'add') {
|
|
|
- this.save()
|
|
|
- } else {
|
|
|
- this.update()
|
|
|
- }
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- save () {
|
|
|
- console.log(this.tenant)
|
|
|
- frockMgrApi.save(this.tenant)
|
|
|
- .then((response) => {
|
|
|
- const res = response.data
|
|
|
- if (res.isSuccess) {
|
|
|
- this.isVisible = false
|
|
|
- this.$message({
|
|
|
- message: this.$t('tips.createSuccess'),
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- // 通知列表
|
|
|
- this.$emit("success");
|
|
|
- // 通知列表-并关闭弹出框
|
|
|
- this.$emit("close");
|
|
|
- }
|
|
|
- }).finally(() => {
|
|
|
- this.confirmDisabled = false
|
|
|
- return true
|
|
|
- })
|
|
|
- },
|
|
|
- update () {
|
|
|
- frockMgrApi.update(this.tenant)
|
|
|
- .then((response) => {
|
|
|
- const res = response.data
|
|
|
- if (res.isSuccess) {
|
|
|
- this.isVisible = false
|
|
|
- this.$message({
|
|
|
- message: this.$t('tips.updateSuccess'),
|
|
|
- type: 'success'
|
|
|
- })
|
|
|
- // 通知列表
|
|
|
- this.$emit("success");
|
|
|
- // 通知列表-并关闭弹出框
|
|
|
- this.$emit("close");
|
|
|
- }
|
|
|
- }).finally(() => {
|
|
|
- this.confirmDisabled = false
|
|
|
- return true
|
|
|
- })
|
|
|
- },
|
|
|
- // 根据【工具原材料】的id,查询,规格列表数据
|
|
|
- getSpecsList(row){
|
|
|
- /*let obj = {
|
|
|
- current: 1,
|
|
|
- size: 1000,
|
|
|
- model: {
|
|
|
- meterialId: row.id
|
|
|
- }
|
|
|
- }*/
|
|
|
- frockMgrApi.listSpecs({meterialId: row.id}).then(res => {
|
|
|
- res = res.data
|
|
|
- console.log("规格数据:", res)
|
|
|
- if(res.isSuccess){
|
|
|
- this.tableData = res.data
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</script>
|
|
|
-<style lang="scss" >
|
|
|
-.avatar-uploader .el-upload {
|
|
|
- border: 1px dashed #d9d9d9;
|
|
|
- border-radius: 6px;
|
|
|
- cursor: pointer;
|
|
|
- position: relative;
|
|
|
- overflow: hidden;
|
|
|
-}
|
|
|
-.avatar-uploader .el-upload:hover {
|
|
|
- border-color: #409eff;
|
|
|
-}
|
|
|
-.avatar-uploader-icon {
|
|
|
- font-size: 28px;
|
|
|
- color: #8c939d;
|
|
|
- width: 100px;
|
|
|
- height: 100px;
|
|
|
- line-height: 100px;
|
|
|
- text-align: center;
|
|
|
-}
|
|
|
-.avatar {
|
|
|
- width: 100px;
|
|
|
- height: 100px;
|
|
|
- display: block;
|
|
|
-}
|
|
|
-.checkUsed{
|
|
|
- display: inline-block;
|
|
|
- margin-left: 10px;
|
|
|
- color: #1890ff;
|
|
|
-}
|
|
|
-</style>
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ :title="title"
|
|
|
+ :append-to-body="true"
|
|
|
+ :visible.sync="isVisible"
|
|
|
+ :width="width"
|
|
|
+ top="50px"
|
|
|
+ >
|
|
|
+ <el-form ref="form" :model="tenant" :rules="rules" label-position="right" label-width="150px">
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.no")+":"' prop="no">
|
|
|
+ <el-input v-model="tenant.no" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.name")+":"' prop="name">
|
|
|
+ <el-input v-model="tenant.name" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+<!-- <el-form-item :label='$t("prepare.table.tools.category")+":"' prop="category" >-->
|
|
|
+<!-- <el-select style="width:100%" :placeholder='$t("common.pleaseSelect")' v-model="tenant.category.key" value @change="selectCategory($event)">-->
|
|
|
+<!-- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.METERIAL_CATEGORY" />-->
|
|
|
+<!-- </el-select>-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
+<!-- <el-form-item :label='$t("prepare.table.tools.materialType")+":"' prop="materialType" v-show="materialTypeShowFlag">-->
|
|
|
+<!-- <el-select style="width:100%" :placeholder='$t("common.pleaseSelect")' v-model="tenant.materialType.key" value>-->
|
|
|
+<!-- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.MATERIAL_TYPE" />-->
|
|
|
+<!-- </el-select>-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
+<!-- <el-form-item :label='$t("prepare.table.tools.brand")+":"' prop="brand">-->
|
|
|
+<!-- <el-select style="width:100%" :placeholder='$t("common.pleaseSelect")' v-model="tenant.brand.key" value>-->
|
|
|
+<!-- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.METERIAL_BRAND" />-->
|
|
|
+<!-- </el-select>-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.materialType")+":"' prop="materialType">
|
|
|
+ <el-input v-model="tenant.materialType" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.mapNo")+":"' prop="mapNo">
|
|
|
+ <el-input v-model="tenant.mapNo" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.factory")+":"' prop="factory">
|
|
|
+ <el-input v-model="tenant.factory" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.joinDate")+":"' prop="joinDate">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="tenant.joinDate"
|
|
|
+ type="date"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ placeholder="">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.period")+":"' prop="period">
|
|
|
+ <el-input-number v-model="tenant.period" :min="1" :max="1000" label="12"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="$t('prepare.table.tools.expiryDate')+':'" prop="expiryDate">
|
|
|
+ <el-input-number v-model="tenant.expiryDate" :min="1" :max="1000" label="12"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.num")+":"' prop="num">
|
|
|
+ <el-input-number v-model="tenant.num" :min="1" :max="1000" label="1"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.specification")+":"' v-show="false">
|
|
|
+ <!-- 功能按钮 -->
|
|
|
+ <el-row class="filter-container">
|
|
|
+ <el-col>
|
|
|
+ <el-button type="primary" icon="el-icon-plus" size="medium" @click="addRes">新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <!-- Table数据 -->
|
|
|
+ <el-table
|
|
|
+ ref="table"
|
|
|
+ v-loading="loading"
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ style="width: 100%;"
|
|
|
+ @selection-change="onSelectChange"
|
|
|
+ >
|
|
|
+ <el-table-column prop="tradeMark" :label='$t("prepare.table.tools.tradeMark")' align="center" width="180px">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input size="small" v-model="row.tradeMark" v-if="row.isEdit" :placeholder='$t("common.pleaseEnter")'></el-input>
|
|
|
+ <span v-else>{{row.tradeMark}}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!--<el-table-column prop="type" label="类型" width="120px">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-select v-model="row.type" size="small" v-if="row.isEdit" placeholder="请选择类型">
|
|
|
+ <el-option
|
|
|
+ v-for="item in typeList"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <span v-else="">{{row.type}}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>-->
|
|
|
+ <el-table-column prop="specification" :label='$t("prepare.table.tools.specification")'>
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-input size="small" v-model="row.specification" v-if="row.isEdit" :placeholder='$t("common.pleaseEnter")'></el-input>
|
|
|
+ <span v-else>{{row.specification}}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :label="$t('table.operation')"
|
|
|
+ fixed="right"
|
|
|
+ align="center"
|
|
|
+ column-key="operation"
|
|
|
+ width="100px"
|
|
|
+ >
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-tooltip class="item" :content='$t("common.edit")' effect="dark" placement="top-start">
|
|
|
+ <i
|
|
|
+ class="el-icon-edit table-operation"
|
|
|
+ style="color: #2db7f5;"
|
|
|
+ @click="edit(row)"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip class="item" :content='$t("common.delete")' effect="dark" placement="top-start">
|
|
|
+ <i
|
|
|
+ class="el-icon-delete table-operation"
|
|
|
+ style="color: #f50;"
|
|
|
+ @click="singleDelete(row)"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label='$t("prepare.table.tools.status")+":"' prop="status">
|
|
|
+ <template>
|
|
|
+ <el-radio v-model="tenant.status" label="1">{{$t("common.status.valid")}}</el-radio>
|
|
|
+ <el-radio v-model="tenant.status" label="0">{{$t("common.frozen")}}</el-radio>
|
|
|
+ </template>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button plain type="warning" @click="isVisible = false">{{ $t('common.cancel') }}</el-button>
|
|
|
+ <el-button plain type="primary" :disabled="confirmDisabled" @click="submitForm">{{ $t('common.confirm') }}</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+// 【工具原材料管理】-API
|
|
|
+import frockMgrApi from "@/api/prepareProductMgr/frockMgr"
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'TenantEdit',
|
|
|
+ props: {
|
|
|
+ dialogVisible: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ type: 'add',
|
|
|
+ tableData: [],
|
|
|
+ tenant: this.initTenant(),
|
|
|
+ screenWidth: 0,
|
|
|
+ width: this.initWidth(),
|
|
|
+ confirmDisabled: false,
|
|
|
+ materialTypeShowFlag: false,
|
|
|
+ dicts: {
|
|
|
+ METERIAL_BRAND: {}, //工具材料品牌
|
|
|
+ METERIAL_CATEGORY: {}, //工具材料分类
|
|
|
+ MATERIAL_TYPE: {} //工具材料毛坯成品分类
|
|
|
+ },
|
|
|
+ roles: [],
|
|
|
+ rules: {
|
|
|
+ no: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ name: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ // model: [
|
|
|
+ // { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ // ],
|
|
|
+ // category: [
|
|
|
+ // { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ // ],
|
|
|
+ joinDate: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ materialType: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ num: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ // brand: [
|
|
|
+ // { required: true, message: this.$t("rules.require"), trigger: 'blur' },
|
|
|
+ // ],
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isVisible: {
|
|
|
+ get () {
|
|
|
+ return this.dialogVisible
|
|
|
+ },
|
|
|
+ set () {
|
|
|
+ this.close()
|
|
|
+ this.reset()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ window.onresize = () => {
|
|
|
+ return (() => {
|
|
|
+ this.width = this.initWidth()
|
|
|
+ })()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 【新增】按钮-事件
|
|
|
+ addRes(){
|
|
|
+ this.tableData.push({
|
|
|
+ key: "WKS_"+ Math.random(),
|
|
|
+ id: "",
|
|
|
+ tradeMark: "",
|
|
|
+ specification: "",
|
|
|
+ isEdit: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // Table的选择事件
|
|
|
+ onSelectChange (selection) {
|
|
|
+ this.selection = selection
|
|
|
+ },
|
|
|
+ // 【删除】按钮事件
|
|
|
+ singleDelete(row){
|
|
|
+ this.$confirm("删除数据后,将会消失,您的努力将白费,请确认删除?", this.$t("common.tips"), {
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ confirmButtonText: "确认",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ // 过滤符合条件的数据
|
|
|
+ let arr = this.tableData.filter(item => item.key != row.key || item.id != row.id)
|
|
|
+ // 给新的数据赋值
|
|
|
+ this.tableData = arr;
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+ // 【修改】按钮事件
|
|
|
+ edit(row){
|
|
|
+ let list = new Array();
|
|
|
+ this.tableData.forEach((item, index) => {
|
|
|
+ // 当前编辑行
|
|
|
+ if(!!item.id && item.id == row.id){
|
|
|
+ item.isEdit = true
|
|
|
+ }
|
|
|
+ list.push(item)
|
|
|
+ })
|
|
|
+ // 赋值给当前
|
|
|
+ this.tableData = list
|
|
|
+ },
|
|
|
+ initTenant () {
|
|
|
+ return {
|
|
|
+ model: '',
|
|
|
+ name: '',
|
|
|
+ category: {
|
|
|
+ key: ''
|
|
|
+ },
|
|
|
+ brand: {
|
|
|
+ key: ''
|
|
|
+ },
|
|
|
+ status: '1',
|
|
|
+ period:12,
|
|
|
+ expiryDate:12,
|
|
|
+ num:1
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ selectCategory(id){
|
|
|
+ if("04" === id){
|
|
|
+ this.materialTypeShowFlag = true
|
|
|
+ }else{
|
|
|
+ this.materialTypeShowFlag = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initWidth () {
|
|
|
+ this.screenWidth = document.body.clientWidth
|
|
|
+ if (this.screenWidth < 991) {
|
|
|
+ return '90%'
|
|
|
+ } else if (this.screenWidth < 1400) {
|
|
|
+ return '45%'
|
|
|
+ } else {
|
|
|
+ return '800px'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setTenant (val, dicts) {
|
|
|
+ if(val){
|
|
|
+ this.tenant = { ...val }
|
|
|
+ if("04" === this.tenant.category.key){
|
|
|
+ this.materialTypeShowFlag = true
|
|
|
+ }else{
|
|
|
+ this.materialTypeShowFlag = false
|
|
|
+ }
|
|
|
+ // 根据id,查询规格列表数据
|
|
|
+ //this.getSpecsList(val)
|
|
|
+ }
|
|
|
+ // 字典表
|
|
|
+ this.dicts = dicts
|
|
|
+ },
|
|
|
+ close () {
|
|
|
+ this.$emit('close')
|
|
|
+ },
|
|
|
+ reset () {
|
|
|
+ // 先清除校验,再清除表单,不然有奇怪的bug
|
|
|
+ this.$refs.form.clearValidate()
|
|
|
+ this.$refs.form.resetFields()
|
|
|
+ this.tenant = this.initTenant()
|
|
|
+ this.tableData = [] //清空【规格】数据
|
|
|
+ },
|
|
|
+ submitForm () {
|
|
|
+ // 验证规格必填
|
|
|
+ /*let flag = false
|
|
|
+
|
|
|
+ if(this.tableData.length > 0){
|
|
|
+ this.tableData.map(item => {
|
|
|
+ if(!item.specification){
|
|
|
+ flag = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(this.tenant.model ==''){
|
|
|
+ flag = true
|
|
|
+ }else{
|
|
|
+ console.log(this.tenant.model)
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("prepare.tips.addGg"),
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } */
|
|
|
+ // if(this.tenant.model ==''){
|
|
|
+ // console.log(this.$t("prepare.tips.inputGg"))
|
|
|
+ // this.$message({
|
|
|
+ // message: this.$t("prepare.tips.inputGg"),
|
|
|
+ // type: 'warning'
|
|
|
+ // })
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // 添加规格数据
|
|
|
+ // this.tenant.mtoolMeterialSpecsList = this.tableData
|
|
|
+ //console.log("Form数据:", this.tenant)
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.confirmDisabled = true
|
|
|
+ if (this.type === 'add') {
|
|
|
+ this.save()
|
|
|
+ } else {
|
|
|
+ this.update()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ save () {
|
|
|
+ console.log(this.tenant)
|
|
|
+ frockMgrApi.save(this.tenant)
|
|
|
+ .then((response) => {
|
|
|
+ const res = response.data
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.isVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: this.$t('tips.createSuccess'),
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ // 通知列表
|
|
|
+ this.$emit("success");
|
|
|
+ // 通知列表-并关闭弹出框
|
|
|
+ this.$emit("close");
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.confirmDisabled = false
|
|
|
+ return true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ update () {
|
|
|
+ frockMgrApi.update(this.tenant)
|
|
|
+ .then((response) => {
|
|
|
+ const res = response.data
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.isVisible = false
|
|
|
+ this.$message({
|
|
|
+ message: this.$t('tips.updateSuccess'),
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ // 通知列表
|
|
|
+ this.$emit("success");
|
|
|
+ // 通知列表-并关闭弹出框
|
|
|
+ this.$emit("close");
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.confirmDisabled = false
|
|
|
+ return true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 根据【工具原材料】的id,查询,规格列表数据
|
|
|
+ getSpecsList(row){
|
|
|
+ /*let obj = {
|
|
|
+ current: 1,
|
|
|
+ size: 1000,
|
|
|
+ model: {
|
|
|
+ meterialId: row.id
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ frockMgrApi.listSpecs({meterialId: row.id}).then(res => {
|
|
|
+ res = res.data
|
|
|
+ console.log("规格数据:", res)
|
|
|
+ if(res.isSuccess){
|
|
|
+ this.tableData = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" >
|
|
|
+.avatar-uploader .el-upload {
|
|
|
+ border: 1px dashed #d9d9d9;
|
|
|
+ border-radius: 6px;
|
|
|
+ cursor: pointer;
|
|
|
+ position: relative;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
+.avatar-uploader .el-upload:hover {
|
|
|
+ border-color: #409eff;
|
|
|
+}
|
|
|
+.avatar-uploader-icon {
|
|
|
+ font-size: 28px;
|
|
|
+ color: #8c939d;
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ line-height: 100px;
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+.avatar {
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+.checkUsed{
|
|
|
+ display: inline-block;
|
|
|
+ margin-left: 10px;
|
|
|
+ color: #1890ff;
|
|
|
+}
|
|
|
+</style>
|