|
@@ -1,363 +1,363 @@
|
|
|
-<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 v-if="$store.state.account.user.roles.indexOf('舱体') < 0 && $store.state.account.user.roles.indexOf('框体') < 0" label='所属产线:' prop="zoneId">
|
|
|
- <el-select
|
|
|
- v-model="tenant.zoneId"
|
|
|
- :placeholder='$t("common.pleaseSelect")'
|
|
|
- style="width: 50%"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="(item, index) in zoneList"
|
|
|
- :key="index"
|
|
|
- :label="item.name"
|
|
|
- :value="item.id"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label='物料编码:' prop="meterialCode">
|
|
|
- <el-input v-model.trim="tenant.meterialCode" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <!--<el-form-item label='材料牌号:' 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='材料牌号:' prop="tradeMark">
|
|
|
- <el-input v-model.trim="tenant.tradeMark" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label='器材名称:' prop="equipmentName">
|
|
|
- <el-input v-model.trim="tenant.equipmentName" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label='规格型号:' prop="specification">
|
|
|
- <el-input v-model.trim="tenant.specification" :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='处理状态:' prop="handleStatus">
|
|
|
- <el-input v-model.trim="tenant.handleStatus" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
- </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 MaterialApi from "@/api/prepareProductMgr/material"
|
|
|
- //【所属产线】-API
|
|
|
- import areaMgrApi from "@/api/resourceProductMgr/areaMgr"
|
|
|
- export default {
|
|
|
- name: 'TenantEdit',
|
|
|
- props: {
|
|
|
- dialogVisible: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- default: ''
|
|
|
- }
|
|
|
- },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- loading: false,
|
|
|
- type: 'add',
|
|
|
- tableData: [],
|
|
|
- zoneList: [],
|
|
|
- materialTypeShowFlag: false,
|
|
|
- tenant: this.initTenant(),
|
|
|
- screenWidth: 0,
|
|
|
- width: this.initWidth(),
|
|
|
- confirmDisabled: false,
|
|
|
- dicts: {
|
|
|
- METERIAL_BRAND: {}, //工具材料品牌
|
|
|
- METERIAL_CATEGORY: {}, //工具材料分类
|
|
|
- MATERIAL_TYPE: {} //工具材料毛坯成品分类
|
|
|
- },
|
|
|
- roles: [],
|
|
|
- rules: {
|
|
|
- meterialCode: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
- ],
|
|
|
- tradeMark: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
- ],
|
|
|
- specification: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
- created() {
|
|
|
- // 加载列表数据
|
|
|
- this.getZoneList();
|
|
|
- // console.log("用户登录的信息:",this.$store.state.account.user.roles.indexOf("舱体") < 0);
|
|
|
- },
|
|
|
- computed: {
|
|
|
- isVisible: {
|
|
|
- get () {
|
|
|
- return this.dialogVisible
|
|
|
- },
|
|
|
- set () {
|
|
|
- this.close()
|
|
|
- this.reset()
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- window.onresize = () => {
|
|
|
- return (() => {
|
|
|
- this.width = this.initWidth()
|
|
|
- })()
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 获取【所属产线】下拉数据
|
|
|
- getZoneList() {
|
|
|
- areaMgrApi.getList({ status: 1 }).then((res) => {
|
|
|
- res = res.data;
|
|
|
- if (res.isSuccess) {
|
|
|
- this.zoneList = res.data;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- // 【新增】按钮-事件
|
|
|
- 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 {
|
|
|
- userId: this.$store.state.account.user.id, // 默认添加登录用户ID
|
|
|
- meterialCode: '',
|
|
|
- tradeMark: '',
|
|
|
- equipmentName: '',
|
|
|
- specification: '',
|
|
|
- handleStatus: '',
|
|
|
- status: '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 () {
|
|
|
- //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)
|
|
|
- MaterialApi.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 () {
|
|
|
- MaterialApi.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
|
|
|
- }
|
|
|
- }*/
|
|
|
- MaterialApi.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="130px">
|
|
|
+ <!--所属产线-->
|
|
|
+ <el-form-item v-if="$store.state.account.user.roles.indexOf('舱体') < 0 && $store.state.account.user.roles.indexOf('框体') < 0" label='所属产线:' prop="zoneId">
|
|
|
+ <el-select
|
|
|
+ v-model="tenant.zoneId"
|
|
|
+ :placeholder='$t("common.pleaseSelect")'
|
|
|
+ style="width: 50%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in zoneList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label='物料编码:' prop="meterialCode">
|
|
|
+ <el-input v-model.trim="tenant.meterialCode" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <!--<el-form-item label='材料牌号:' 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='材料牌号:' prop="tradeMark">
|
|
|
+ <el-input v-model.trim="tenant.tradeMark" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label='器材名称:' prop="equipmentName">
|
|
|
+ <el-input v-model.trim="tenant.equipmentName" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label='规格型号:' prop="specification">
|
|
|
+ <el-input v-model.trim="tenant.specification" :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='处理状态:' prop="handleStatus">
|
|
|
+ <el-input v-model.trim="tenant.handleStatus" :placeholder='$t("common.pleaseEnter")'/>
|
|
|
+ </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 MaterialApi from "@/api/prepareProductMgr/material"
|
|
|
+ //【所属产线】-API
|
|
|
+ import areaMgrApi from "@/api/resourceProductMgr/areaMgr"
|
|
|
+ export default {
|
|
|
+ name: 'TenantEdit',
|
|
|
+ props: {
|
|
|
+ dialogVisible: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ type: 'add',
|
|
|
+ tableData: [],
|
|
|
+ zoneList: [],
|
|
|
+ materialTypeShowFlag: false,
|
|
|
+ tenant: this.initTenant(),
|
|
|
+ screenWidth: 0,
|
|
|
+ width: this.initWidth(),
|
|
|
+ confirmDisabled: false,
|
|
|
+ dicts: {
|
|
|
+ METERIAL_BRAND: {}, //工具材料品牌
|
|
|
+ METERIAL_CATEGORY: {}, //工具材料分类
|
|
|
+ MATERIAL_TYPE: {} //工具材料毛坯成品分类
|
|
|
+ },
|
|
|
+ roles: [],
|
|
|
+ rules: {
|
|
|
+ meterialCode: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ tradeMark: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ specification: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
+ created() {
|
|
|
+ // 加载列表数据
|
|
|
+ this.getZoneList();
|
|
|
+ // console.log("用户登录的信息:",this.$store.state.account.user.roles.indexOf("舱体") < 0);
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isVisible: {
|
|
|
+ get () {
|
|
|
+ return this.dialogVisible
|
|
|
+ },
|
|
|
+ set () {
|
|
|
+ this.close()
|
|
|
+ this.reset()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ window.onresize = () => {
|
|
|
+ return (() => {
|
|
|
+ this.width = this.initWidth()
|
|
|
+ })()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 获取【所属产线】下拉数据
|
|
|
+ getZoneList() {
|
|
|
+ areaMgrApi.zoneListExceptBz({ status: 1 }).then((res) => {
|
|
|
+ res = res.data;
|
|
|
+ if (res.isSuccess) {
|
|
|
+ this.zoneList = res.data;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 【新增】按钮-事件
|
|
|
+ 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 {
|
|
|
+ userId: this.$store.state.account.user.id, // 默认添加登录用户ID
|
|
|
+ meterialCode: '',
|
|
|
+ tradeMark: '',
|
|
|
+ equipmentName: '',
|
|
|
+ specification: '',
|
|
|
+ handleStatus: '',
|
|
|
+ status: '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 () {
|
|
|
+ //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)
|
|
|
+ MaterialApi.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 () {
|
|
|
+ MaterialApi.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
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ MaterialApi.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>
|