|
|
@@ -0,0 +1,285 @@
|
|
|
+<template>
|
|
|
+ <a-drawer
|
|
|
+ v-model:visible="modeVisible"
|
|
|
+ class="custom-class"
|
|
|
+ title="自产品库添加"
|
|
|
+ placement="right"
|
|
|
+ width="1200px"
|
|
|
+ :closable="false"
|
|
|
+ @close="modeVisible = false"
|
|
|
+ >
|
|
|
+ <div style="margin-bottom:16px;display:flex">
|
|
|
+ <a-button type="primary" @click="handleAdd" style="margin-right:25px" :disabled="handleBtnDisabled">批量添加</a-button>
|
|
|
+
|
|
|
+ <selectAllData
|
|
|
+ style="margin-right: 25px"
|
|
|
+ :total="total"
|
|
|
+ @handlePullApi="handlePullApi"
|
|
|
+ @handleUploadApi="handleUploadApi"
|
|
|
+ @onSuccess="emit('onSuccess')"
|
|
|
+ @emitCallBack="emitCallBack"
|
|
|
+ :isEmit="true"
|
|
|
+ ></selectAllData>
|
|
|
+
|
|
|
+ <div style="margin-right: 25px;">
|
|
|
+ <span>搜索:</span>
|
|
|
+ <a-input v-model:value="param.content.where.condition" placeholder="产品编码/名称" style="width:200px"></a-input>
|
|
|
+ </div>
|
|
|
+ <div style="margin-right: 25px;">
|
|
|
+ <span>设备类型:</span>
|
|
|
+ <a-select
|
|
|
+ v-model:value="param.content.where.prodtype"
|
|
|
+ style="width:200px"
|
|
|
+ placeholder="请选择设备类型"
|
|
|
+ @change="$refs.list.listData()"
|
|
|
+ allowClear
|
|
|
+ >
|
|
|
+ <a-select-option :value="item.value" v-for="(item,index) in typeList" :key="index">{{ item.value }}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <span>厂商:</span>
|
|
|
+ <a-select
|
|
|
+ style="width:200px"
|
|
|
+ v-model:value="param.content.where.enterprisename"
|
|
|
+ @change="$refs.list.listData()"
|
|
|
+ allowClear
|
|
|
+ >
|
|
|
+ <a-select-option v-for="item in enterpriseList" :key="item.sys_enterpriseid" :value="item.sys_enterpriseid">{{ item.enterprisename }}</a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <normalTable rowKey="w_productid" ref="list" size="small" :param="param" :columns="utils.TBLayout('productListTable')" @onSelect="onSelect" @handleList="handleProduct">
|
|
|
+ <template #tb_cell="{data}">
|
|
|
+ <template v-if="data.column.dataIndex === 'operation'">
|
|
|
+ <a-button type="link" size="small" @click="addProduct(data.record)">添加</a-button>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ {{ data.record[data.column.dataIndex] }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </normalTable>
|
|
|
+ <template #extra>
|
|
|
+ <a-space>
|
|
|
+ <a-button @click="visible=false">关闭</a-button>
|
|
|
+ </a-space>
|
|
|
+ </template>
|
|
|
+ </a-drawer>
|
|
|
+ <SelectModel
|
|
|
+ ref="Class"
|
|
|
+ @selectRowData="selectClass"
|
|
|
+ rowKey="w_prodclassid"
|
|
|
+ :param="classParam"
|
|
|
+ :filterMultiple="true"
|
|
|
+ :columns="utils.TBLayout('categoryTable')" title="选择产品分类"
|
|
|
+ @handleList="handleList"
|
|
|
+ @close="classClose"
|
|
|
+ >
|
|
|
+ </SelectModel>
|
|
|
+ <a-button type="primary" @click="modeVisible=true">自产品库添加</a-button>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import normalTable from '@/template/normalTable/index.vue'
|
|
|
+import selectAllData from './selectAllData.vue'
|
|
|
+import SelectModel from '@/components/selectModel/index.vue'
|
|
|
+import { useBaseStore } from '@/stores/modules/base'
|
|
|
+import {ref, defineProps, defineEmits, onMounted, computed} from 'vue'
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
+import Api from '@/api/api'
|
|
|
+import utils from '@/utils/utils'
|
|
|
+
|
|
|
+import {message} from 'ant-design-vue'
|
|
|
+
|
|
|
+let router = useRouter()
|
|
|
+let base = useBaseStore()
|
|
|
+let emit = defineEmits(['selectRowData','onSuccess'])
|
|
|
+let props = defineProps({
|
|
|
+})
|
|
|
+let param = ref({
|
|
|
+ "id": 20230612101702,
|
|
|
+ "content": {
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 20,
|
|
|
+ "where": {
|
|
|
+ "condition": "",
|
|
|
+ "prodtype": "",
|
|
|
+ "enterprisename": ""
|
|
|
+ }
|
|
|
+ },
|
|
|
+})
|
|
|
+let classParam = ref({
|
|
|
+ "id": 20230609105302,
|
|
|
+ "content": {},
|
|
|
+})
|
|
|
+let Class = ref()
|
|
|
+let typeList = ref([])
|
|
|
+let enterpriseList = ref([])
|
|
|
+let list = ref()
|
|
|
+let selectRowData = ref([])
|
|
|
+let selectOneData = ref({})
|
|
|
+let modeVisible = ref(false)
|
|
|
+let cacheFun = ref('')
|
|
|
+let selectClassArr = ref([])
|
|
|
+let total = ref(0)
|
|
|
+
|
|
|
+let addProduct = (data) => {
|
|
|
+ actionClassSelect(data)
|
|
|
+}
|
|
|
+
|
|
|
+let handleAdd = async () => {
|
|
|
+ Class.value.modeVisible = true
|
|
|
+}
|
|
|
+
|
|
|
+let onSelect = (data) => {
|
|
|
+ selectRowData.value = data
|
|
|
+}
|
|
|
+
|
|
|
+let handleBtnDisabled = computed(() => {
|
|
|
+ return selectRowData.value.length > 0 ? false : true
|
|
|
+})
|
|
|
+
|
|
|
+let emitCallBack = (fun) => {
|
|
|
+ cacheFun.value = fun
|
|
|
+ Class.value.modeVisible = true
|
|
|
+}
|
|
|
+
|
|
|
+/* 选中产品分类 */
|
|
|
+let selectClass = async (data) => {
|
|
|
+ let res
|
|
|
+ selectClassArr.value = data
|
|
|
+ if (cacheFun.value) {
|
|
|
+ cacheFun.value()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (Object.keys(selectOneData.value).length) {
|
|
|
+ res = await Api.requested({
|
|
|
+ "id": 20230612112302,
|
|
|
+ "content": {
|
|
|
+ "items": [
|
|
|
+ {
|
|
|
+ "w_productid": selectOneData.value.w_productid,
|
|
|
+ "w_prodclassid": data[data.length - 1].w_prodclassid
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let items = selectRowData.value.map(item => {
|
|
|
+ return {
|
|
|
+ "w_productid":item.w_productid,
|
|
|
+ "w_prodclassid":data[data.length - 1].w_prodclassid
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ res = await Api.requested({
|
|
|
+ "id": 20230612112302,
|
|
|
+ "content": {
|
|
|
+ "items": items
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ utils.message(res,'添加成功',() => {
|
|
|
+ emit('onSuccess')
|
|
|
+ selectOneData.value = []
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+let classClose = () => {
|
|
|
+ selectOneData.value = []
|
|
|
+}
|
|
|
+
|
|
|
+/* 激活分类选择窗口 */
|
|
|
+let actionClassSelect = (data) => {
|
|
|
+ Class.value.modeVisible = true
|
|
|
+ selectOneData.value = data
|
|
|
+}
|
|
|
+
|
|
|
+let getEnterpriseList = async () => {
|
|
|
+ let res = await Api.requested({
|
|
|
+ "id": 20230612091102,
|
|
|
+ "content": {
|
|
|
+ "pageNumber": 1,
|
|
|
+ "pageSize": 9999999,
|
|
|
+ "where": {
|
|
|
+ "condition": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ enterpriseList.value = res.data
|
|
|
+ console.log(enterpriseList.value)
|
|
|
+}
|
|
|
+
|
|
|
+/*改变产品分类列表数据结构 sub:[] => children:[] */
|
|
|
+let handleList = (res) => {
|
|
|
+ res.data = createDeep(res.data)
|
|
|
+}
|
|
|
+let handleProduct = (res) => {
|
|
|
+ total.value =res.total
|
|
|
+}
|
|
|
+let createDeep = (array) => {
|
|
|
+ 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:[]
|
|
|
+ }
|
|
|
+ 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]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!elNode.children.length) delete elNode.children
|
|
|
+ return elNode
|
|
|
+ }
|
|
|
+ array.forEach(item => {
|
|
|
+ console.log(item);
|
|
|
+ arr.push(deepFun(item))
|
|
|
+ })
|
|
|
+ return arr
|
|
|
+}
|
|
|
+
|
|
|
+/*拉取数据*/
|
|
|
+let handlePullApi = (pullApi) => {
|
|
|
+ pullApi.content = JSON.parse(JSON.stringify(param.value.content))
|
|
|
+ pullApi.id = param.value.id
|
|
|
+ /*pullApi.content.sa_projectid = this.$route.query.id*/
|
|
|
+}
|
|
|
+/*上传数据*/
|
|
|
+let handleUploadApi = (uploadApi,data) => {
|
|
|
+ uploadApi.id = 20230612112302
|
|
|
+ uploadApi.content = {
|
|
|
+ "items": data.map(e=>{
|
|
|
+ return {
|
|
|
+ "w_productid":e.w_productid,
|
|
|
+ "w_prodclassid":selectClassArr.value[selectClassArr.value.length - 1].w_prodclassid,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ getEnterpriseList()
|
|
|
+ let res = await base.optiontypeselect('prodtype')
|
|
|
+ typeList.value = res.data
|
|
|
+})
|
|
|
+
|
|
|
+defineExpose({
|
|
|
+ modeVisible
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|