From d848889b1326a4a790b68655d3628ed120661da6 Mon Sep 17 00:00:00 2001
From: 李喆(开发组) <lzhe@yxqiche.com>
Date: 星期四, 31 七月 2025 11:52:52 +0800
Subject: [PATCH] 1
---
src/views/basesetting/machine.vue | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 200 insertions(+), 39 deletions(-)
diff --git a/src/views/basesetting/machine.vue b/src/views/basesetting/machine.vue
index 756b75a..d03a7dc 100644
--- a/src/views/basesetting/machine.vue
+++ b/src/views/basesetting/machine.vue
@@ -16,13 +16,14 @@
@on-load="onLoad"
>
<template #menu-left>
- <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">瀵煎嚭</el-button>
- <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">瀵煎叆</el-button>
+ <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">瀵煎嚭</el-button>
+ <!-- <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">瀵煎叆</el-button> -->
+ <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleAdd">鏂板</el-button>
</template>
<template #menu="scope">
<el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleEdit(scope.row, scope.index)">缂栬緫</el-button>
- <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleView(scope.row, scope.index)">鍒犻櫎</el-button>
- <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleView(scope.row, scope.index)">浜х敓鏈哄簥鍥炰紶鏈烘瀯鏍�</el-button>
+ <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleDel(scope.row, scope.index)">鍒犻櫎</el-button>
+ <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleUp(scope.row, scope.index)">浜х敓鏈哄簥鍥炰紶鏈烘瀯鏍�</el-button>
</template>
<template #status="{ row }">
@@ -30,17 +31,29 @@
</template>
</avue-crud>
- <el-dialog title="缂栬緫" append-to-body v-model="editBox" width="60%">
- <avue-form ref="editFormModal" :option="editFormModal" v-model="form" @submit="formSubmit" />
+ <el-dialog :title="machineTitle" append-to-body v-model="editBox" width="60%">
+ <avue-form ref="editFormModal1" :option="editFormModal" v-model="editForm" @submit="formSubmit" @resetForm="resetForm">
+ <template #ownerDept="{}">
+ <el-tree-select v-model="editForm.ownerDept" :data="organizationTreeList"/>
+ </template>
+ </avue-form>
</el-dialog>
</basic-container>
</template>
<script>
+import { exportBlob } from '@/api/common';
+import { getToken } from '@/utils/auth';
+import NProgress from 'nprogress';
+import { downloadXls } from '@/utils/util';
+import 'nprogress/nprogress.css';
export default {
data() {
var that = this;
return {
+ organizationTreeList: [],
+ machineTitle: "鏂板",
+ isAdd: true,
editBox: false,
search: {
keyword: "",
@@ -52,6 +65,7 @@
current: 1,
total: 0,
},
+ editForm: {},
option: {
index: true,
addBtn: false,
@@ -69,7 +83,7 @@
hide: true
},
{
- label: '鏈哄簥缂栧彿',
+ label: '鏈哄簥缂栧彿4',
prop: 'code'
},
{
@@ -119,71 +133,86 @@
type: 'input',
span: 12,
dataType: 'string',
+ rules: [
+ {
+ required: true,
+ message: '璇疯緭鍏ユ満搴婄紪鍙�',
+ trigger: 'blur'
+ }
+ ]
},
{
label: '鏈哄簥鍨嬪彿',
- prop: '',
+ prop: 'name',
type: 'input',
span: 12,
dataType: 'string',
+ rules: [
+ {
+ required: true,
+ message: '璇疯緭鍏ユ満搴婂瀷鍙�',
+ trigger: 'blur'
+ }
+ ]
},
{
label: '鏈哄簥绫诲瀷',
- prop: '',
+ prop: 'machineSpec',
type: 'select',
span: 12,
- dicUrl: '/blade-system/dict-biz/dictionary?code=machine_group',
+ dicUrl: '/blade-system/dict-biz/dictionary?code=machine_spec',
props: {
label: 'dictValue',
value: 'dictKey',
- }
+ },
+ rules: [
+ {
+ required: true,
+ message: '璇烽�夋嫨鏈哄簥绫诲瀷',
+ trigger: 'change'
+ }
+ ]
},
{
label: '鎵�灞炴満搴婄粍',
- prop: '',
+ prop: 'machineGroupCode',
type: 'select',
span: 12,
dicUrl: '/blade-system/dict-biz/dictionary?code=machine_group',
props: {
label: 'dictValue',
value: 'dictKey',
- }
+ },
+ rules: [
+ {
+ required: true,
+ message: '璇烽�夋嫨鎵�灞炴満搴婄粍',
+ trigger: 'change'
+ }
+ ]
},
{
label: '鎿嶄綔鍛�',
- prop: '',
+ prop: 'operator',
type: 'input',
span: 12,
dataType: 'string',
},
{
label: '鎵�灞炵粍缁�',
- prop: '',
- type: 'select',
- span: 12,
- dicUrl: '/blade-system/dict-biz/dictionary?code=machine_group',
- props: {
- label: 'dictValue',
- value: 'dictKey',
- }
+ prop: 'ownerDept',
+ span: 12
},
{
label: '鐢熶骇鍟�',
- prop: '',
- type: 'input',
- span: 12,
- dataType: 'string',
- },
- {
- label: '杞鏃堕棿锛堝皬鏃讹級',
- prop: '',
+ prop: 'manufacturer',
type: 'input',
span: 12,
dataType: 'string',
},
{
label: '绯荤粺鎺у埗',
- prop: '',
+ prop: 'controlSystem',
type: 'select',
span: 12,
dicUrl: '/blade-system/dict-biz/dictionary?code=machine_control_system',
@@ -194,7 +223,7 @@
},
{
label: '鐘舵��',
- prop: 'checkbox',
+ prop: 'status',
type: 'checkbox',
span: 12,
dicData: [{
@@ -204,21 +233,21 @@
},
{
label: '绋嬪簭涓嬪彂鐩綍',
- prop: '',
+ prop: 'progSendDir',
type: 'input',
span: 12,
dataType: 'string',
},
{
label: '绋嬪簭鍥炰紶鐩綍',
- prop: '',
+ prop: 'progReceiveDir',
type: 'input',
span: 12,
dataType: 'string',
},
{
label: '澶囨敞',
- prop: '',
+ prop: 'remark',
type: 'textarea',
span: 24,
dataType: 'string',
@@ -229,11 +258,111 @@
};
},
methods: {
- handleEdit() {
+ handleAdd() {
+ this.machineTitle = "鏂板";
+ this.isAdd = true;
this.editBox = true;
+ this.$refs.editFormModal1.resetForm();
},
- formSubmit() {
-
+ handleEdit(row,index) {
+ this.machineTitle = "缂栬緫";
+ this.isAdd = false;
+ axios({
+ url: '/blade-mdm/machine/detail',
+ method: 'get',
+ params: {id: row.id},
+ }).then(
+ res => {
+ res.data.data.status = [res.data.data.status];
+ this.editForm = res.data.data;
+ this.editBox = true;
+ },
+ error => {
+ this.loading = false;
+ }
+ );
+ },
+ handleDel(row,index) {
+ this.loading = true;
+ axios({
+ url: '/blade-mdm/machine/remove',
+ method: 'post',
+ params: {ids: row.id},
+ }).then(
+ res => {
+ this.loading = false;
+ this.$message({
+ type: 'success',
+ message: '鎿嶄綔鎴愬姛!',
+ });
+ this.onLoad();
+ done();
+ },
+ error => {
+ this.loading = false;
+ }
+ );
+ },
+ handleUp(row,index) {
+ this.loading = true;
+ axios({
+ url: '/blade-mdm/machine/gen-fileback-dirs',
+ method: 'post',
+ params: {id: row.id},
+ }).then(
+ res => {
+ this.loading = false;
+ this.$message({
+ type: 'success',
+ message: '鎿嶄綔鎴愬姛!',
+ });
+ this.onLoad();
+ done();
+ },
+ error => {
+ this.loading = false;
+ }
+ );
+ },
+ handleExport() {
+ this.$confirm('鏄惁瀵煎嚭?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning',
+ }).then(() => {
+ NProgress.start();
+ exportBlob(
+ `/blade-mdm/machine/export?${this.website.tokenHeader}=${getToken()}`
+ ).then(res => {
+ downloadXls(res.data, `瀵煎嚭鏈哄簥${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`);
+ NProgress.done();
+ });
+ });
+ },
+ formSubmit(params, done) {
+ var obj = {...params};
+ if(params.status.length == 0) {
+ obj.status = "0";
+ }else {
+ obj.status = "1";
+ }
+ if(this.isAdd) { //鏂板
+ var url = '/blade-mdm/machine/save';
+ }else {
+ var url = '/blade-mdm/machine/update';
+ }
+ this.loading = true;
+ axios({url: url,method: 'post',data: obj}).then(res => {
+ this.loading = false;
+ if(res,res.data.success) {
+ this.editBox = false;
+ this.$message({type: 'success',message: '鎿嶄綔鎴愬姛!'});
+ this.onLoad();
+ }else {
+ this.$message({type: 'error',message: res.data.msg});
+ }
+ done();
+ });
},
handleView() {
@@ -255,7 +384,7 @@
refreshChange() {
},
- onLoad(page, params = {}) {
+ onLoad() {
this.loading = true;
var obj = {
keyword: this.search.keyword,
@@ -278,8 +407,40 @@
}
);
+ },
+ traversalLabelValueToTree(tree) { //閬嶅巻鏁扮粍
+ return tree.map(node => {
+ // 1. 娣诲姞 label 鍜� value 瀛楁
+ const newNode = {
+ ...node,
+ label: node.fullName,
+ value: node.id,
+ };
+ // 2. 濡傛灉鏈� children锛岄�掑綊澶勭悊
+ if (node.children && node.children.length > 0) {
+ newNode.children = this.traversalLabelValueToTree(node.children);
+ }
+ return newNode;
+ });
}
},
+ mounted() {
+ //鍒ゆ柇鐗堟湰 0:娑夊瘑缃戯紝1:宸ユ帶缃戯紱//宸ユ帶缃�5涓紝娑夊瘑缃�4涓� 宸ユ帶缃戜笉鍋氫簡
+ // 宸ユ帶缃戞槸/blade-mdm/system/dept/lazy-list
+ // 娑夊瘑缃戞槸/blade-mdm/dept/lazy-list
+ axios({url: '/blade-mdm/system/param/getValue?paramKey=networkType',method: 'get'}).then(res => {
+ // if(res.data.data === "0") {
+ // var aurl = "/blade-mdm/dept/lazy-list";
+ // }else {
+ // var aurl = "/blade-mdm/system/dept/lazy-list";
+ // }
+ var aurl = "/blade-mdm/system/dept/lazy-list";
+ axios({url: aurl,method: 'get'}).then(resp => {
+ this.organizationTreeList = this.traversalLabelValueToTree(resp.data.data);
+ })
+ }
+ );
+ }
};
</script>
--
Gitblit v1.9.3