|
@@ -1,5 +1,11 @@
|
|
|
<template>
|
|
|
- <a-button type="primary" :disabled="disabled" @click="addBtn" style="margin-right:10px">新建</a-button>
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="disabled"
|
|
|
+ @click="addBtn"
|
|
|
+ style="margin-right: 10px"
|
|
|
+ >新建</a-button
|
|
|
+ >
|
|
|
<a-drawer
|
|
|
v-model:visible="visible"
|
|
|
class="custom-class"
|
|
@@ -9,27 +15,52 @@
|
|
|
:closable="false"
|
|
|
@close="visible = false"
|
|
|
>
|
|
|
- <a-form ref="formRef" :model="form" size="small" layout="vertical" mode="multiple">
|
|
|
+ <a-form
|
|
|
+ ref="formRef"
|
|
|
+ :model="form"
|
|
|
+ size="small"
|
|
|
+ layout="vertical"
|
|
|
+ mode="multiple"
|
|
|
+ >
|
|
|
<a-row :gutter="16">
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="产品编码" name="prodnum" :rules="[{ required: true, message: '请输入产品编码' }]">
|
|
|
- <a-input v-model:value="form.prodnum" placeholder="请输入产品编码"></a-input>
|
|
|
+ <a-form-item
|
|
|
+ label="产品编码"
|
|
|
+ name="prodnum"
|
|
|
+ :rules="[{ required: true, message: '请输入产品编码' }]"
|
|
|
+ >
|
|
|
+ <a-input
|
|
|
+ v-model:value="form.prodnum"
|
|
|
+ placeholder="请输入产品编码"
|
|
|
+ ></a-input>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="产品名称" name="prodname" :rules="[{ required: true, message: '请输入产品名称' }]">
|
|
|
- <a-input v-model:value="form.prodname" placeholder="请输入产品名称"></a-input>
|
|
|
+ <a-form-item
|
|
|
+ label="产品名称"
|
|
|
+ name="prodname"
|
|
|
+ :rules="[{ required: true, message: '请输入产品名称' }]"
|
|
|
+ >
|
|
|
+ <a-input
|
|
|
+ v-model:value="form.prodname"
|
|
|
+ placeholder="请输入产品名称"
|
|
|
+ ></a-input>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="产品分类" name="prodclassname">
|
|
|
- <SelectModel
|
|
|
- ref="Class"
|
|
|
- @selectRowData="selectClass"
|
|
|
- rowKey="w_prodclassid"
|
|
|
- :param="classParam"
|
|
|
- :filterMultiple="true"
|
|
|
- :columns="utils.TBLayout('categoryTable').splice(0,utils.TBLayout('categoryTable').length - 1)" title="选择产品分类"
|
|
|
+ <a-form-item label="产品分类" name="prodclassname">
|
|
|
+ <SelectModel
|
|
|
+ ref="Class"
|
|
|
+ @selectRowData="selectClass"
|
|
|
+ rowKey="w_prodclassid"
|
|
|
+ :param="classParam"
|
|
|
+ :filterMultiple="true"
|
|
|
+ :columns="
|
|
|
+ utils
|
|
|
+ .TBLayout('categoryTable')
|
|
|
+ .splice(0, utils.TBLayout('categoryTable').length - 1)
|
|
|
+ "
|
|
|
+ title="选择产品分类"
|
|
|
@handleList="handleList"
|
|
|
>
|
|
|
<template v-slot:slot1>
|
|
@@ -37,28 +68,41 @@
|
|
|
v-model:value="form.prodclassname"
|
|
|
enter-button="添加"
|
|
|
readonly
|
|
|
- @search="$refs.Class.modeVisible=true"
|
|
|
+ @search="$refs.Class.modeVisible = true"
|
|
|
/>
|
|
|
</template>
|
|
|
</SelectModel>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="连接类型" name="prodtype" :rules="[{ required: true, message: '请选择连接类型' }]">
|
|
|
- <a-select
|
|
|
- v-model:value="form.prodtype"
|
|
|
-
|
|
|
- >
|
|
|
- <a-select-option :value="item.value" v-for="(item,index) in typeList" :key="index">{{ item.value }}</a-select-option>
|
|
|
+ <a-form-item
|
|
|
+ label="连接类型"
|
|
|
+ name="prodtype"
|
|
|
+ :rules="[{ required: true, message: '请选择连接类型' }]"
|
|
|
+ >
|
|
|
+ <a-select v-model:value="form.prodtype">
|
|
|
+ <a-select-option
|
|
|
+ :value="item.value"
|
|
|
+ v-for="(item, index) in typeList"
|
|
|
+ :key="index"
|
|
|
+ >{{ item.value }}</a-select-option
|
|
|
+ >
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="厂商" name="sys_enterpriseid" :rules="[{required:true,message:'请选择厂商'}]">
|
|
|
- <a-select
|
|
|
- v-model:value="form.sys_enterpriseid"
|
|
|
- >
|
|
|
- <a-select-option v-for="item in enterpriseList" :key="item.sys_enterpriseid" :value="item.sys_enterpriseid">{{ item.enterprisename }}</a-select-option>
|
|
|
+ <a-form-item
|
|
|
+ label="厂商"
|
|
|
+ name="sys_enterpriseid"
|
|
|
+ :rules="[{ required: true, message: '请选择厂商' }]"
|
|
|
+ >
|
|
|
+ <a-select v-model:value="form.sys_enterpriseid">
|
|
|
+ <a-select-option
|
|
|
+ v-for="item in enterpriseList"
|
|
|
+ :key="item.sys_enterpriseid"
|
|
|
+ :value="item.sys_enterpriseid"
|
|
|
+ >{{ item.enterprisename }}</a-select-option
|
|
|
+ >
|
|
|
</a-select>
|
|
|
<!-- <SelectModel
|
|
|
ref="Class"
|
|
@@ -81,194 +125,219 @@
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="描述" name="remarks">
|
|
|
- <a-textarea v-model:value="form.remarks" placeholder="请输入描述"></a-textarea>
|
|
|
+ <a-form-item label="描述" name="remarks">
|
|
|
+ <a-textarea
|
|
|
+ v-model:value="form.remarks"
|
|
|
+ placeholder="请输入描述"
|
|
|
+ ></a-textarea>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="是否指令反馈" name="isfeedback">
|
|
|
- <a-radio-group v-model:value="form.isfeedback" :options="feedbackList" />
|
|
|
+ <a-form-item label="是否指令反馈" name="isfeedback">
|
|
|
+ <a-radio-group
|
|
|
+ v-model:value="form.isfeedback"
|
|
|
+ :options="feedbackList"
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="是否支持蓝牙" name="issupportbluetooth">
|
|
|
- <a-radio-group v-model:value="form.issupportbluetooth" :options="feedbackList" />
|
|
|
+ <a-form-item label="是否支持蓝牙" name="issupportbluetooth">
|
|
|
+ <a-radio-group
|
|
|
+ v-model:value="form.issupportbluetooth"
|
|
|
+ :options="feedbackList"
|
|
|
+ />
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="是否启用" name="isused">
|
|
|
+ <a-form-item label="设备时间标准" name="tsfrom">
|
|
|
+ <a-radio-group v-model:value="form.tsfrom" :options="tsfrom" />
|
|
|
+ </a-form-item>
|
|
|
+ </a-col>
|
|
|
+ <a-col :span="24">
|
|
|
+ <a-form-item label="是否启用" name="isused">
|
|
|
<a-checkbox v-model:checked="form.isused"></a-checkbox>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
<a-col :span="24">
|
|
|
- <a-form-item label="图片" name="attinfos">
|
|
|
- <Upload2 accept="image/png, image/jpeg" :bindData="bindData" ref="upload" v-model:value="form.attinfos"></Upload2>
|
|
|
+ <a-form-item label="图片" name="attinfos">
|
|
|
+ <Upload2
|
|
|
+ accept="image/png, image/jpeg"
|
|
|
+ :bindData="bindData"
|
|
|
+ ref="upload"
|
|
|
+ v-model:value="form.attinfos"
|
|
|
+ ></Upload2>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
</a-form>
|
|
|
<template #extra>
|
|
|
<a-space>
|
|
|
- <a-button @click="visible=false">关闭</a-button>
|
|
|
- <a-button type="primary" @click="onSubmit" :loading="loading">保存</a-button>
|
|
|
+ <a-button @click="visible = false">关闭</a-button>
|
|
|
+ <a-button type="primary" @click="onSubmit" :loading="loading"
|
|
|
+ >保存</a-button
|
|
|
+ >
|
|
|
</a-space>
|
|
|
</template>
|
|
|
</a-drawer>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import {ref, defineProps, defineEmits, onMounted} from 'vue'
|
|
|
-import SelectModel from '@/components/selectModel/index.vue'
|
|
|
-import Upload2 from '@/components/upload2/index2.vue'
|
|
|
-import Api from '@/api/api'
|
|
|
-import utils from '@/utils/utils'
|
|
|
-import { useBaseStore } from '@/stores/modules/base'
|
|
|
-import { storeToRefs } from 'pinia'
|
|
|
+import { ref, defineProps, defineEmits, onMounted } from "vue";
|
|
|
+import SelectModel from "@/components/selectModel/index.vue";
|
|
|
+import Upload2 from "@/components/upload2/index2.vue";
|
|
|
+import Api from "@/api/api";
|
|
|
+import utils from "@/utils/utils";
|
|
|
+import { useBaseStore } from "@/stores/modules/base";
|
|
|
+import { storeToRefs } from "pinia";
|
|
|
|
|
|
-let base = useBaseStore()
|
|
|
-let emit = defineEmits(['onSuccess'])
|
|
|
-let props = defineProps(['disabled'])
|
|
|
-let searchType = ref([{label:'搜索',key:'condition',type:'input'}])
|
|
|
-let visible = ref(false)
|
|
|
-let upload = ref()
|
|
|
-let bindData = ref({})
|
|
|
-let loading = ref(false)
|
|
|
+let base = useBaseStore();
|
|
|
+let emit = defineEmits(["onSuccess"]);
|
|
|
+let props = defineProps(["disabled"]);
|
|
|
+let searchType = ref([{ label: "搜索", key: "condition", type: "input" }]);
|
|
|
+let visible = ref(false);
|
|
|
+let upload = ref();
|
|
|
+let bindData = ref({});
|
|
|
+let loading = ref(false);
|
|
|
let form = ref({
|
|
|
- "w_productid": 0,
|
|
|
- "w_prodclassid": 0,
|
|
|
- "prodclassname":'',
|
|
|
- "prodnum": "",
|
|
|
- "prodname": undefined,
|
|
|
- "prodtype": undefined,
|
|
|
- "sys_enterpriseid": undefined,
|
|
|
- "remarks": "",
|
|
|
- "isused": 0,
|
|
|
- "enterprisename":undefined,
|
|
|
- 'isfeedback':1,
|
|
|
- "attinfos":'',
|
|
|
- issupportbluetooth:0
|
|
|
-})
|
|
|
+ w_productid: 0,
|
|
|
+ w_prodclassid: 0,
|
|
|
+ prodclassname: "",
|
|
|
+ prodnum: "",
|
|
|
+ prodname: undefined,
|
|
|
+ prodtype: undefined,
|
|
|
+ sys_enterpriseid: undefined,
|
|
|
+ remarks: "",
|
|
|
+ isused: 0,
|
|
|
+ enterprisename: undefined,
|
|
|
+ isfeedback: 1,
|
|
|
+ attinfos: "",
|
|
|
+ issupportbluetooth: 0,
|
|
|
+ tsfrom: 1,
|
|
|
+});
|
|
|
let classParam = ref({
|
|
|
- "id": 20230609105302,
|
|
|
- "content": {},
|
|
|
-})
|
|
|
-let enterpriseList = ref([])
|
|
|
-let typeList = ref([])
|
|
|
-let formRef = ref()
|
|
|
-let feedbackList = ref([{label:'是',value:1},{label:'否',value:0}])
|
|
|
-
|
|
|
+ id: 20230609105302,
|
|
|
+ content: {},
|
|
|
+});
|
|
|
+let enterpriseList = ref([]);
|
|
|
+let typeList = ref([]);
|
|
|
+let formRef = ref();
|
|
|
+let feedbackList = ref([
|
|
|
+ { label: "是", value: 1 },
|
|
|
+ { label: "否", value: 0 },
|
|
|
+]);
|
|
|
+let tsfrom = ref([
|
|
|
+ { label: "设备时间", value: 1 },
|
|
|
+ { label: "接收时间", value: 0 },
|
|
|
+]);
|
|
|
let addBtn = async () => {
|
|
|
- visible.value = true
|
|
|
- getEnterpriseList()
|
|
|
- let res = await base.optiontypeselect('prodtype')
|
|
|
- typeList.value = res.data
|
|
|
-}
|
|
|
+ visible.value = true;
|
|
|
+ getEnterpriseList();
|
|
|
+ let res = await base.optiontypeselect("prodtype");
|
|
|
+ typeList.value = res.data;
|
|
|
+};
|
|
|
|
|
|
let onSubmit = async () => {
|
|
|
- form.value.attinfos = upload.value.fileList.length ? '1' : ''
|
|
|
- let isCheck = await formRef.value.validateFields()
|
|
|
- if (!isCheck) return
|
|
|
- form.value.isused = form.value.isused ? 1 : 0
|
|
|
- loading.value = true
|
|
|
+ form.value.attinfos = upload.value.fileList.length ? "1" : "";
|
|
|
+ let isCheck = await formRef.value.validateFields();
|
|
|
+ if (!isCheck) return;
|
|
|
+ form.value.isused = form.value.isused ? 1 : 0;
|
|
|
+ loading.value = true;
|
|
|
let res = await Api.requested({
|
|
|
- id:20230609150202,
|
|
|
- content: form.value
|
|
|
- })
|
|
|
+ id: 20230609150202,
|
|
|
+ content: form.value,
|
|
|
+ });
|
|
|
if (res.code) {
|
|
|
bindData.value = {
|
|
|
- "ownertable": 'w_product',
|
|
|
- "ownerid": res.data.w_productid,
|
|
|
- "usetype": 'previewImage',
|
|
|
- }
|
|
|
+ ownertable: "w_product",
|
|
|
+ ownerid: res.data.w_productid,
|
|
|
+ usetype: "previewImage",
|
|
|
+ };
|
|
|
if (form.value.attinfos) {
|
|
|
upload.value.toUpload(() => {
|
|
|
- utils.message(res,'操作成功',() => {
|
|
|
- visible.value = false
|
|
|
- emit('onSuccess')
|
|
|
- formRef.value.resetFields()
|
|
|
- bindData.value = {}
|
|
|
- upload.value.refresh()
|
|
|
- loading.value = false
|
|
|
- })
|
|
|
- })
|
|
|
+ utils.message(res, "操作成功", () => {
|
|
|
+ visible.value = false;
|
|
|
+ emit("onSuccess");
|
|
|
+ formRef.value.resetFields();
|
|
|
+ bindData.value = {};
|
|
|
+ upload.value.refresh();
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+ });
|
|
|
} else {
|
|
|
- utils.message(res,'操作成功',() => {
|
|
|
- visible.value = false
|
|
|
- emit('onSuccess')
|
|
|
- formRef.value.resetFields()
|
|
|
- bindData.value = {}
|
|
|
- loading.value = false
|
|
|
- })
|
|
|
+ utils.message(res, "操作成功", () => {
|
|
|
+ visible.value = false;
|
|
|
+ emit("onSuccess");
|
|
|
+ formRef.value.resetFields();
|
|
|
+ bindData.value = {};
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
}
|
|
|
} else {
|
|
|
- loading.value = false
|
|
|
- utils.message(res)
|
|
|
+ loading.value = false;
|
|
|
+ utils.message(res);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
let getEnterpriseList = async () => {
|
|
|
let res = await Api.requested({
|
|
|
- "id": 20230612091102,
|
|
|
- "content": {
|
|
|
- "pageNumber": 1,
|
|
|
- "pageSize": 9999999,
|
|
|
- "where": {
|
|
|
- "condition": ""
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- enterpriseList.value = res.data
|
|
|
- console.log(res,'企业res');
|
|
|
- console.log(enterpriseList.value,'企业')
|
|
|
-}
|
|
|
+ id: 20230612091102,
|
|
|
+ content: {
|
|
|
+ pageNumber: 1,
|
|
|
+ pageSize: 9999999,
|
|
|
+ where: {
|
|
|
+ condition: "",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ });
|
|
|
+ enterpriseList.value = res.data;
|
|
|
+ console.log(res, "企业res");
|
|
|
+ console.log(enterpriseList.value, "企业");
|
|
|
+};
|
|
|
|
|
|
let selectClass = (data) => {
|
|
|
console.log(data);
|
|
|
- form.value.prodclassname = data[data.length-1].prodclassname
|
|
|
- form.value.w_prodclassid = data[data.length-1].w_prodclassid
|
|
|
-}
|
|
|
+ form.value.prodclassname = data[data.length - 1].prodclassname;
|
|
|
+ form.value.w_prodclassid = data[data.length - 1].w_prodclassid;
|
|
|
+};
|
|
|
|
|
|
let handleList = (res) => {
|
|
|
console.log(res);
|
|
|
- res.data = createDeep(res.data)
|
|
|
-}
|
|
|
+ res.data = createDeep(res.data);
|
|
|
+};
|
|
|
let createDeep = (array) => {
|
|
|
- let arr = []
|
|
|
- function deepFun (node) {
|
|
|
- console.log(node,'触发');
|
|
|
+ let arr = [];
|
|
|
+ function deepFun(node) {
|
|
|
+ console.log(node, "触发");
|
|
|
let elNode = {
|
|
|
- changeby:node['changeby'],
|
|
|
- changeuserid:node['changeuserid'],
|
|
|
- createby:node['createby'],
|
|
|
- createuserid:node['createuserid'],
|
|
|
- parentid:node['parentid'],
|
|
|
- prodclassname:node['prodclassname'],
|
|
|
- prodclassnum:node['prodclassnum'],
|
|
|
- remarks:node['remarks'],
|
|
|
- sequence:node['sequence'],
|
|
|
- w_prodclassid:node['w_prodclassid'],
|
|
|
- children:[]
|
|
|
- }
|
|
|
+ changeby: node["changeby"],
|
|
|
+ changeuserid: node["changeuserid"],
|
|
|
+ createby: node["createby"],
|
|
|
+ createuserid: node["createuserid"],
|
|
|
+ parentid: node["parentid"],
|
|
|
+ prodclassname: node["prodclassname"],
|
|
|
+ prodclassnum: node["prodclassnum"],
|
|
|
+ remarks: node["remarks"],
|
|
|
+ sequence: node["sequence"],
|
|
|
+ w_prodclassid: node["w_prodclassid"],
|
|
|
+ children: [],
|
|
|
+ };
|
|
|
if (node.sub && node.sub.length > 0) {
|
|
|
// 如果存在子节点
|
|
|
for (var index = 0; index < node.sub.length; index++) {
|
|
|
- // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
|
|
|
- elNode.children.push(deepFun(node.sub[index]));
|
|
|
+ // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
|
|
|
+ elNode.children.push(deepFun(node.sub[index]));
|
|
|
}
|
|
|
}
|
|
|
- if (!elNode.children.length) delete elNode.children
|
|
|
- return elNode
|
|
|
+ if (!elNode.children.length) delete elNode.children;
|
|
|
+ return elNode;
|
|
|
}
|
|
|
- array.forEach(item => {
|
|
|
+ array.forEach((item) => {
|
|
|
console.log(item);
|
|
|
- arr.push(deepFun(item))
|
|
|
- })
|
|
|
- return arr
|
|
|
-}
|
|
|
+ arr.push(deepFun(item));
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-
|
|
|
</style>
|