|
@@ -1,461 +1,462 @@
|
|
|
-<template>
|
|
|
- <el-dialog
|
|
|
- :close-on-click-modal="false"
|
|
|
- :close-on-press-escape="false"
|
|
|
- :title="title"
|
|
|
- :append-to-body="true"
|
|
|
- :visible.sync="isVisible"
|
|
|
- width="960px"
|
|
|
- top="50px"
|
|
|
- >
|
|
|
- <el-form ref="form" :model="tenant" :rules="rules" label-position="right" label-width="130px">
|
|
|
-
|
|
|
- <!-- 搜索模块 -->
|
|
|
- <!--<div class="filter-container">
|
|
|
- <span>
|
|
|
- <span>{{$t("prepare.searchForm.model")}}:</span>
|
|
|
- <el-input v-model="queryParams.model.specification" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
|
|
|
- </span>
|
|
|
- <span style="margin-left: 15px;">
|
|
|
- <span>{{$t("prepare.searchForm.brand")}}:</span>
|
|
|
- <el-select style="width:150px;" :placeholder='$t("common.pleaseSelect")' v-model="brand.key" value size="medium">
|
|
|
- <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.METERIAL_BRAND" />
|
|
|
- </el-select>
|
|
|
- </span>
|
|
|
- <span style="margin-left: 15px;">
|
|
|
- <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
|
|
|
- {{ $t("table.search") }}
|
|
|
- </el-button>
|
|
|
- <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
|
|
|
- {{ $t("table.reset") }}
|
|
|
- </el-button>
|
|
|
- </span>
|
|
|
- </div>-->
|
|
|
-
|
|
|
- <!-- 列表数据 -->
|
|
|
- <el-table
|
|
|
- :key="tableKey"
|
|
|
- ref="table"
|
|
|
- v-loading="loading"
|
|
|
- :data="tableData.records"
|
|
|
- border
|
|
|
- fit
|
|
|
- row-key="id"
|
|
|
- style="width: 100%;"
|
|
|
- @selection-change="onSelectChange"
|
|
|
- @cell-click="cellClick"
|
|
|
- >
|
|
|
- <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
|
|
|
- <template slot-scope="scope">
|
|
|
- <div>
|
|
|
- {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
|
|
|
- <el-table-column prop="no" :label='$t("prepare.table.tools.no")' :show-overflow-tooltip="true"></el-table-column>
|
|
|
- <el-table-column prop="name" :label='$t("prepare.table.tools.name")' :show-overflow-tooltip="true" width="180px"></el-table-column>
|
|
|
- <el-table-column prop="brand.data" :label='$t("prepare.table.tools.brand")' :show-overflow-tooltip="true" width="180px"></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.selected")' effect="dark" placement="top-start">
|
|
|
- <i
|
|
|
- class="el-icon-check table-operation"
|
|
|
- style="color: #2db7f5;"
|
|
|
- @click="selected(row)"
|
|
|
- ><span style="margin-left: 5px;">{{$t("common.selected")}}</span></i>
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
-
|
|
|
- <!-- 【分页组件】-->
|
|
|
- <pagination
|
|
|
- v-show="tableData.total > 0"
|
|
|
- :limit.sync="queryParams.size"
|
|
|
- :page.sync="queryParams.current"
|
|
|
- :total="Number(tableData.total)"
|
|
|
- @pagination="mToolPageList"
|
|
|
- />
|
|
|
-
|
|
|
- </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 trayMgrApi from "@/api/prepareProductMgr/trayMgr"
|
|
|
-// 【分页】组件
|
|
|
-import Pagination from "@/components/Pagination"
|
|
|
-// 【工具原材料管理】-API
|
|
|
-import toolsMaterialApi from "@/api/prepareProductMgr/toolsMaterial"
|
|
|
-// 【共通】函数
|
|
|
-import { initQueryParams, initDicts } from '@/utils/commons'
|
|
|
-export default {
|
|
|
- name: 'TenantEdit',
|
|
|
- components: { Pagination },
|
|
|
- props: {
|
|
|
- dialogVisible: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- default: ''
|
|
|
- }
|
|
|
- },
|
|
|
- data () {
|
|
|
- return {
|
|
|
- audioStatus: [],
|
|
|
- brand: {
|
|
|
- key: ''
|
|
|
- },
|
|
|
- category: { // 02:夹具,03:托盘,04:原材料
|
|
|
- key: '02'
|
|
|
- },
|
|
|
- dicts: {
|
|
|
- METERIAL_BRAND: {}, //工具材料品牌
|
|
|
- METERIAL_CATEGORY: {} //工具材料分类
|
|
|
- },
|
|
|
- queryParams: initQueryParams({}),
|
|
|
- selection: [],
|
|
|
- loading: false,
|
|
|
- tableKey: 0,
|
|
|
- type: 'add',
|
|
|
- keys: '',
|
|
|
- tableData: {
|
|
|
- total: 0
|
|
|
- },
|
|
|
- tenant: this.initTenant(),
|
|
|
- screenWidth: 0,
|
|
|
- width: this.initWidth(),
|
|
|
- confirmDisabled: false,
|
|
|
- roles: [],
|
|
|
- rules: {
|
|
|
- name: [
|
|
|
- { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
- created() {
|
|
|
- // 调用常量-审核状态
|
|
|
- this.audioStatus = this.$constWKS.STATUSORTHERLIST
|
|
|
- // 加载【字典】
|
|
|
- initDicts(['METERIAL_BRAND', 'METERIAL_CATEGORY'], this.dicts);
|
|
|
- // 加载列表数据
|
|
|
- // this.fetch();
|
|
|
- // 加载夹具数据
|
|
|
- this.mToolPageList();
|
|
|
- },
|
|
|
- computed: {
|
|
|
- isVisible: {
|
|
|
- get () {
|
|
|
- return this.dialogVisible
|
|
|
- },
|
|
|
- set () {
|
|
|
- this.close()
|
|
|
- this.reset()
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- mounted () {
|
|
|
- window.onresize = () => {
|
|
|
- return (() => {
|
|
|
- this.width = this.initWidth()
|
|
|
- })()
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- // 【选择】按钮-事件
|
|
|
- selected(row){
|
|
|
- // 赋值数据
|
|
|
- this.giveParent(row)
|
|
|
- },
|
|
|
- // 【确定】按钮-事件
|
|
|
- submitForm () {
|
|
|
- if (this.selection.length <= 0) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.noDataSelected"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.selection.length > 1) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.mustOne"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // console.log("表单数据:", this.tenant)
|
|
|
- this.$refs.form.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- // 赋值数据
|
|
|
- this.giveParent(this.selection[0])
|
|
|
- } else {
|
|
|
- return false
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 把【选择、确定】的数据给父组件
|
|
|
- giveParent(obj){
|
|
|
- console.log("列表的数据111:", obj);
|
|
|
- if(this.type == "add"){
|
|
|
- // 赋值唯一值
|
|
|
- obj.key = ''+ Math.random();
|
|
|
- } else {
|
|
|
- obj.key = this.keys;
|
|
|
- }
|
|
|
- // 夹具唯一id
|
|
|
- obj.trayId = obj.id
|
|
|
- // 把选择的数据提交到父组件
|
|
|
- this.$emit("success", JSON.stringify(obj), this.type);
|
|
|
- // 关闭弹出框
|
|
|
- this.$emit("close")
|
|
|
- },
|
|
|
- // 【搜索】按钮-事件
|
|
|
- search () {
|
|
|
- this.fetch({
|
|
|
- ...this.queryParams
|
|
|
- })
|
|
|
- },
|
|
|
- // Table的选择事件
|
|
|
- onSelectChange (selection) {
|
|
|
- this.selection = selection
|
|
|
- },
|
|
|
- cellClick (row, column) {
|
|
|
- if (column['columnKey'] === "operation") {
|
|
|
- return
|
|
|
- }
|
|
|
- let flag = false
|
|
|
- this.selection.forEach((item) => {
|
|
|
- if (item.id === row.id) {
|
|
|
- flag = true
|
|
|
- this.$refs.table.toggleRowSelection(row)
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- if (!flag) {
|
|
|
- this.$refs.table.toggleRowSelection(row, true)
|
|
|
- }
|
|
|
- },
|
|
|
- // 【修改】按钮事件
|
|
|
- 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'
|
|
|
- }
|
|
|
- },
|
|
|
- initWidth () {
|
|
|
- this.screenWidth = document.body.clientWidth
|
|
|
- if (this.screenWidth < 991) {
|
|
|
- return '90%'
|
|
|
- } else if (this.screenWidth < 1400) {
|
|
|
- return '45%'
|
|
|
- } else {
|
|
|
- return '800px'
|
|
|
- }
|
|
|
- },
|
|
|
- setTenant (val) {
|
|
|
- if(val){
|
|
|
- this.tenant = { ...val }
|
|
|
- }
|
|
|
- },
|
|
|
- close () {
|
|
|
- this.$emit('close')
|
|
|
- },
|
|
|
- // 【重置】按钮-事件
|
|
|
- reset () {
|
|
|
- // 初始化表单
|
|
|
- this.queryParams = initQueryParams({})
|
|
|
- // 清空列表选中的数据
|
|
|
- this.$refs.table.clearSelection()
|
|
|
- },
|
|
|
- submitForm () {
|
|
|
- if (!this.selection.length) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.noDataSelected"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.selection.length > 1) {
|
|
|
- this.$message({
|
|
|
- message: this.$t("tips.mustOne"),
|
|
|
- type: "warning"
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- // 【选择】按钮-事件
|
|
|
- this.giveParent(this.selection[0])
|
|
|
- /*// 把选择的数据提交到父组件
|
|
|
- this.$emit("success", this.selection)
|
|
|
- // 关闭弹出框
|
|
|
- this.isVisible = false*/
|
|
|
- },
|
|
|
- save () {
|
|
|
- trayMgrApi.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 () {
|
|
|
- trayMgrApi.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
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- // 工装夹具列表
|
|
|
- mToolPageList(params = {}) {
|
|
|
- this.loading = true
|
|
|
- // 分页信息
|
|
|
- this.queryParams.current = params.current ? params.current : this.queryParams.current;
|
|
|
- this.queryParams.size = params.size ? params.size : this.queryParams.size;
|
|
|
- // 搜索条件添加
|
|
|
- //this.queryParams.model.brand = this.brand;
|
|
|
- // 分类,【原材料】固定,查询原材,分类就是:04
|
|
|
- //this.queryParams.model.category = this.category;
|
|
|
- trayMgrApi.mToolPageList(this.queryParams).then(response => {
|
|
|
- const res = response.data;
|
|
|
- console.log("工装夹具列表 = ", res);
|
|
|
- if (res.isSuccess) {
|
|
|
- // 数据存在,规格改成下拉数据结构
|
|
|
- /*if(res.data.records && res.data.records.length > 0){
|
|
|
- res.data.records.forEach((item, index) => {
|
|
|
- // 如果规格存在
|
|
|
- if(!!item.specification){
|
|
|
- let arr = item.specification.split(",");
|
|
|
- // 赋值一个新数组属性,供列表使用
|
|
|
- item.spList = arr;
|
|
|
- }
|
|
|
- })
|
|
|
- }*/
|
|
|
- this.tableData = res.data;
|
|
|
- }
|
|
|
- // eslint-disable-next-line no-return-assign
|
|
|
- }).finally(() => this.loading = false)
|
|
|
- },
|
|
|
-
|
|
|
- // 夹具分页列表
|
|
|
- fetch (params = {}) {
|
|
|
- this.loading = true
|
|
|
- // 分页信息
|
|
|
- this.queryParams.current = params.current ? params.current : this.queryParams.current
|
|
|
- this.queryParams.size = params.size ? params.size : this.queryParams.size
|
|
|
- // 搜索条件添加
|
|
|
- this.queryParams.model.brand = this.brand
|
|
|
- // 分类,【原材料】固定,查询原材,分类就是:04
|
|
|
- this.queryParams.model.category = this.category
|
|
|
-
|
|
|
- toolsMaterialApi.page(this.queryParams).then(response => {
|
|
|
- const res = response.data
|
|
|
- if (res.isSuccess) {
|
|
|
- // 数据存在,规格改成下拉数据结构
|
|
|
- if(res.data.records && res.data.records.length > 0){
|
|
|
- res.data.records.forEach((item, index) => {
|
|
|
- console.log("ddddd = ", item)
|
|
|
- // 如果规格存在
|
|
|
- if(!!item.specification){
|
|
|
- let arr = item.specification.split(",")
|
|
|
- // 赋值一个新数组属性,供列表使用
|
|
|
- item.spList = arr
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- this.tableData = res.data
|
|
|
- }
|
|
|
- // eslint-disable-next-line no-return-assign
|
|
|
- }).finally(() => this.loading = false)
|
|
|
- },
|
|
|
- }
|
|
|
-}
|
|
|
-</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="960px"
|
|
|
+ top="50px"
|
|
|
+ >
|
|
|
+ <el-form ref="form" :model="tenant" :rules="rules" label-position="right" label-width="130px">
|
|
|
+
|
|
|
+ <!-- 搜索模块 -->
|
|
|
+ <!--<div class="filter-container">
|
|
|
+ <span>
|
|
|
+ <span>{{$t("prepare.searchForm.model")}}:</span>
|
|
|
+ <el-input v-model="queryParams.model.specification" :placeholder='$t("common.pleaseEnter")' style="width: 150px;" size="medium"/>
|
|
|
+ </span>
|
|
|
+ <span style="margin-left: 15px;">
|
|
|
+ <span>{{$t("prepare.searchForm.brand")}}:</span>
|
|
|
+ <el-select style="width:150px;" :placeholder='$t("common.pleaseSelect")' v-model="brand.key" value size="medium">
|
|
|
+ <el-option :key="index" :label="item" :value="key" v-for="(item, key, index) in dicts.METERIAL_BRAND" />
|
|
|
+ </el-select>
|
|
|
+ </span>
|
|
|
+ <span style="margin-left: 15px;">
|
|
|
+ <el-button plain type="primary" icon="el-icon-search" size="medium" @click="search">
|
|
|
+ {{ $t("table.search") }}
|
|
|
+ </el-button>
|
|
|
+ <el-button plain type="warning" icon="el-icon-refresh" size="medium" @click="reset">
|
|
|
+ {{ $t("table.reset") }}
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </div>-->
|
|
|
+
|
|
|
+ <!-- 列表数据 -->
|
|
|
+ <el-table
|
|
|
+ :key="tableKey"
|
|
|
+ ref="table"
|
|
|
+ v-loading="loading"
|
|
|
+ :data="tableData.records"
|
|
|
+ border
|
|
|
+ fit
|
|
|
+ row-key="id"
|
|
|
+ style="width: 100%;"
|
|
|
+ @selection-change="onSelectChange"
|
|
|
+ @cell-click="cellClick"
|
|
|
+ >
|
|
|
+ <el-table-column :label='$t("common.serialNo")' width="55px" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <div>
|
|
|
+ {{scope.$index+(queryParams.current - 1) * queryParams.size + 1}}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" type="selection" width="50" :reserve-selection="true" />
|
|
|
+ <el-table-column prop="no" :label='$t("prepare.table.tools.no")' :show-overflow-tooltip="true"></el-table-column>
|
|
|
+ <el-table-column prop="name" :label='$t("prepare.table.tools.name")' :show-overflow-tooltip="true" width="180px"></el-table-column>
|
|
|
+ <el-table-column prop="materialType" label='物料类型' :show-overflow-tooltip="true" width="100px"></el-table-column>
|
|
|
+ <el-table-column prop="brand.data" :label='$t("prepare.table.tools.brand")' :show-overflow-tooltip="true" width="180px"></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.selected")' effect="dark" placement="top-start">
|
|
|
+ <i
|
|
|
+ class="el-icon-check table-operation"
|
|
|
+ style="color: #2db7f5;"
|
|
|
+ @click="selected(row)"
|
|
|
+ ><span style="margin-left: 5px;">{{$t("common.selected")}}</span></i>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 【分页组件】-->
|
|
|
+ <pagination
|
|
|
+ v-show="tableData.total > 0"
|
|
|
+ :limit.sync="queryParams.size"
|
|
|
+ :page.sync="queryParams.current"
|
|
|
+ :total="Number(tableData.total)"
|
|
|
+ @pagination="mToolPageList"
|
|
|
+ />
|
|
|
+
|
|
|
+ </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 trayMgrApi from "@/api/prepareProductMgr/trayMgr"
|
|
|
+// 【分页】组件
|
|
|
+import Pagination from "@/components/Pagination"
|
|
|
+// 【工具原材料管理】-API
|
|
|
+import toolsMaterialApi from "@/api/prepareProductMgr/toolsMaterial"
|
|
|
+// 【共通】函数
|
|
|
+import { initQueryParams, initDicts } from '@/utils/commons'
|
|
|
+export default {
|
|
|
+ name: 'TenantEdit',
|
|
|
+ components: { Pagination },
|
|
|
+ props: {
|
|
|
+ dialogVisible: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ audioStatus: [],
|
|
|
+ brand: {
|
|
|
+ key: ''
|
|
|
+ },
|
|
|
+ category: { // 02:夹具,03:托盘,04:原材料
|
|
|
+ key: '02'
|
|
|
+ },
|
|
|
+ dicts: {
|
|
|
+ METERIAL_BRAND: {}, //工具材料品牌
|
|
|
+ METERIAL_CATEGORY: {} //工具材料分类
|
|
|
+ },
|
|
|
+ queryParams: initQueryParams({}),
|
|
|
+ selection: [],
|
|
|
+ loading: false,
|
|
|
+ tableKey: 0,
|
|
|
+ type: 'add',
|
|
|
+ keys: '',
|
|
|
+ tableData: {
|
|
|
+ total: 0
|
|
|
+ },
|
|
|
+ tenant: this.initTenant(),
|
|
|
+ screenWidth: 0,
|
|
|
+ width: this.initWidth(),
|
|
|
+ confirmDisabled: false,
|
|
|
+ roles: [],
|
|
|
+ rules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: this.$t("rules.require"), trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 实例已经在内存中创建好,此时data和methods已将ok,如果要操作data中的数据或是调用methods中的方法,最早只能在created中操作
|
|
|
+ created() {
|
|
|
+ // 调用常量-审核状态
|
|
|
+ this.audioStatus = this.$constWKS.STATUSORTHERLIST
|
|
|
+ // 加载【字典】
|
|
|
+ initDicts(['METERIAL_BRAND', 'METERIAL_CATEGORY'], this.dicts);
|
|
|
+ // 加载列表数据
|
|
|
+ // this.fetch();
|
|
|
+ // 加载夹具数据
|
|
|
+ this.mToolPageList();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ isVisible: {
|
|
|
+ get () {
|
|
|
+ return this.dialogVisible
|
|
|
+ },
|
|
|
+ set () {
|
|
|
+ this.close()
|
|
|
+ this.reset()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ window.onresize = () => {
|
|
|
+ return (() => {
|
|
|
+ this.width = this.initWidth()
|
|
|
+ })()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 【选择】按钮-事件
|
|
|
+ selected(row){
|
|
|
+ // 赋值数据
|
|
|
+ this.giveParent(row)
|
|
|
+ },
|
|
|
+ // 【确定】按钮-事件
|
|
|
+ submitForm () {
|
|
|
+ if (this.selection.length <= 0) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.selection.length > 1) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.mustOne"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // console.log("表单数据:", this.tenant)
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // 赋值数据
|
|
|
+ this.giveParent(this.selection[0])
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 把【选择、确定】的数据给父组件
|
|
|
+ giveParent(obj){
|
|
|
+ console.log("列表的数据111:", obj);
|
|
|
+ if(this.type == "add"){
|
|
|
+ // 赋值唯一值
|
|
|
+ obj.key = ''+ Math.random();
|
|
|
+ } else {
|
|
|
+ obj.key = this.keys;
|
|
|
+ }
|
|
|
+ // 夹具唯一id
|
|
|
+ obj.trayId = obj.id
|
|
|
+ // 把选择的数据提交到父组件
|
|
|
+ this.$emit("success", JSON.stringify(obj), this.type);
|
|
|
+ // 关闭弹出框
|
|
|
+ this.$emit("close")
|
|
|
+ },
|
|
|
+ // 【搜索】按钮-事件
|
|
|
+ search () {
|
|
|
+ this.fetch({
|
|
|
+ ...this.queryParams
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // Table的选择事件
|
|
|
+ onSelectChange (selection) {
|
|
|
+ this.selection = selection
|
|
|
+ },
|
|
|
+ cellClick (row, column) {
|
|
|
+ if (column['columnKey'] === "operation") {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let flag = false
|
|
|
+ this.selection.forEach((item) => {
|
|
|
+ if (item.id === row.id) {
|
|
|
+ flag = true
|
|
|
+ this.$refs.table.toggleRowSelection(row)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (!flag) {
|
|
|
+ this.$refs.table.toggleRowSelection(row, true)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 【修改】按钮事件
|
|
|
+ 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'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ initWidth () {
|
|
|
+ this.screenWidth = document.body.clientWidth
|
|
|
+ if (this.screenWidth < 991) {
|
|
|
+ return '90%'
|
|
|
+ } else if (this.screenWidth < 1400) {
|
|
|
+ return '45%'
|
|
|
+ } else {
|
|
|
+ return '800px'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setTenant (val) {
|
|
|
+ if(val){
|
|
|
+ this.tenant = { ...val }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close () {
|
|
|
+ this.$emit('close')
|
|
|
+ },
|
|
|
+ // 【重置】按钮-事件
|
|
|
+ reset () {
|
|
|
+ // 初始化表单
|
|
|
+ this.queryParams = initQueryParams({})
|
|
|
+ // 清空列表选中的数据
|
|
|
+ this.$refs.table.clearSelection()
|
|
|
+ },
|
|
|
+ submitForm () {
|
|
|
+ if (!this.selection.length) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.noDataSelected"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.selection.length > 1) {
|
|
|
+ this.$message({
|
|
|
+ message: this.$t("tips.mustOne"),
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 【选择】按钮-事件
|
|
|
+ this.giveParent(this.selection[0])
|
|
|
+ /*// 把选择的数据提交到父组件
|
|
|
+ this.$emit("success", this.selection)
|
|
|
+ // 关闭弹出框
|
|
|
+ this.isVisible = false*/
|
|
|
+ },
|
|
|
+ save () {
|
|
|
+ trayMgrApi.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 () {
|
|
|
+ trayMgrApi.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
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 工装夹具列表
|
|
|
+ mToolPageList(params = {}) {
|
|
|
+ this.loading = true
|
|
|
+ // 分页信息
|
|
|
+ this.queryParams.current = params.current ? params.current : this.queryParams.current;
|
|
|
+ this.queryParams.size = params.size ? params.size : this.queryParams.size;
|
|
|
+ // 搜索条件添加
|
|
|
+ //this.queryParams.model.brand = this.brand;
|
|
|
+ // 分类,【原材料】固定,查询原材,分类就是:04
|
|
|
+ //this.queryParams.model.category = this.category;
|
|
|
+ trayMgrApi.mToolPageList(this.queryParams).then(response => {
|
|
|
+ const res = response.data;
|
|
|
+ console.log("工装夹具列表 = ", res);
|
|
|
+ if (res.isSuccess) {
|
|
|
+ // 数据存在,规格改成下拉数据结构
|
|
|
+ /*if(res.data.records && res.data.records.length > 0){
|
|
|
+ res.data.records.forEach((item, index) => {
|
|
|
+ // 如果规格存在
|
|
|
+ if(!!item.specification){
|
|
|
+ let arr = item.specification.split(",");
|
|
|
+ // 赋值一个新数组属性,供列表使用
|
|
|
+ item.spList = arr;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }*/
|
|
|
+ this.tableData = res.data;
|
|
|
+ }
|
|
|
+ // eslint-disable-next-line no-return-assign
|
|
|
+ }).finally(() => this.loading = false)
|
|
|
+ },
|
|
|
+
|
|
|
+ // 夹具分页列表
|
|
|
+ fetch (params = {}) {
|
|
|
+ this.loading = true
|
|
|
+ // 分页信息
|
|
|
+ this.queryParams.current = params.current ? params.current : this.queryParams.current
|
|
|
+ this.queryParams.size = params.size ? params.size : this.queryParams.size
|
|
|
+ // 搜索条件添加
|
|
|
+ this.queryParams.model.brand = this.brand
|
|
|
+ // 分类,【原材料】固定,查询原材,分类就是:04
|
|
|
+ this.queryParams.model.category = this.category
|
|
|
+
|
|
|
+ toolsMaterialApi.page(this.queryParams).then(response => {
|
|
|
+ const res = response.data
|
|
|
+ if (res.isSuccess) {
|
|
|
+ // 数据存在,规格改成下拉数据结构
|
|
|
+ if(res.data.records && res.data.records.length > 0){
|
|
|
+ res.data.records.forEach((item, index) => {
|
|
|
+ console.log("ddddd = ", item)
|
|
|
+ // 如果规格存在
|
|
|
+ if(!!item.specification){
|
|
|
+ let arr = item.specification.split(",")
|
|
|
+ // 赋值一个新数组属性,供列表使用
|
|
|
+ item.spList = arr
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.tableData = res.data
|
|
|
+ }
|
|
|
+ // eslint-disable-next-line no-return-assign
|
|
|
+ }).finally(() => this.loading = false)
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+</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>
|