|
@@ -1,17 +1,5 @@
|
|
<template>
|
|
<template>
|
|
<view>
|
|
<view>
|
|
- <view>
|
|
|
|
- <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="120">
|
|
|
|
- <uni-grid :column="5" @change="change" showBorder="false" square="false">
|
|
|
|
- <uni-grid-item v-for="item in categories" :index="item.id">
|
|
|
|
- <view class="grid-item-box">
|
|
|
|
- <image class="image" :src="loadImgSrcLocalhost(item.icon)" mode="aspectFit"></image>
|
|
|
|
- <text class="text">{{ item.productName }}</text>
|
|
|
|
- </view>
|
|
|
|
- </uni-grid-item>
|
|
|
|
- </uni-grid>
|
|
|
|
- </scroll-view>
|
|
|
|
- </view>
|
|
|
|
<view class="uni-container">
|
|
<view class="uni-container">
|
|
<uni-table>
|
|
<uni-table>
|
|
<uni-tr>
|
|
<uni-tr>
|
|
@@ -37,7 +25,7 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import {listConfig,QuotationsList, listQuotations} from "@/api/quotations/quotations";
|
|
|
|
|
|
+import {listConfig, QuotationsList, listQuotations} from "@/api/quotations/quotations";
|
|
import upload from '../../components/upload/index.vue'
|
|
import upload from '../../components/upload/index.vue'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -67,11 +55,13 @@ export default {
|
|
pageSize: 15,
|
|
pageSize: 15,
|
|
id: null,
|
|
id: null,
|
|
type: null,
|
|
type: null,
|
|
|
|
+ types: [],
|
|
},
|
|
},
|
|
//表单数据
|
|
//表单数据
|
|
form: {},
|
|
form: {},
|
|
|
|
+
|
|
//分类树列表
|
|
//分类树列表
|
|
- forms:{},
|
|
|
|
|
|
+ forms: {},
|
|
imageList: []
|
|
imageList: []
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -93,47 +83,73 @@ export default {
|
|
this.getList();
|
|
this.getList();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- getList(row) {
|
|
|
|
- // 这里是获取列表的方法
|
|
|
|
- this.queryParams.type = this.FatherType
|
|
|
|
- listQuotations(this.queryParams).then(response => {
|
|
|
|
- if (this.queryParams.pageNum === 1) {
|
|
|
|
- this.quotationsList = this.dataFormat(response.rows)
|
|
|
|
- } else {
|
|
|
|
- this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
|
|
|
|
- }
|
|
|
|
- // 判断是否还有更多数据
|
|
|
|
- if (response.rows.length < this.queryParams.pageSize) {
|
|
|
|
- this.status = 'noMore'; // 没有更多数据
|
|
|
|
- } else {
|
|
|
|
- this.status = 'more'; // 还有更多数据
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- this.forms.parentId = this.FatherType
|
|
|
|
|
|
+ getList() {
|
|
//获取分类树的方法
|
|
//获取分类树的方法
|
|
- QuotationsList(this.forms).then(response => {
|
|
|
|
- //取出response.rows中所有homeDisplay为1的数据
|
|
|
|
- this.categories = response.rows
|
|
|
|
- });
|
|
|
|
|
|
+ listConfig().then(response => {
|
|
|
|
+ this.categories = this.findNodes(response.data.quotations, this.FatherType)
|
|
|
|
+ //categories是一个数组,把他数组中的每一个id属性都取出来并添加到this.queryParams.types中
|
|
|
|
+ this.queryParams.types = this.categories.map(item => item.id);
|
|
|
|
+ listQuotations(this.queryParams).then(response => {
|
|
|
|
+ if (this.queryParams.pageNum === 1) {
|
|
|
|
+ this.quotationsList = this.dataFormat(response.rows)
|
|
|
|
+ } else {
|
|
|
|
+ this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
|
|
|
|
+ }
|
|
|
|
+ // 判断是否还有更多数据
|
|
|
|
+ if (response.rows.length < this.queryParams.pageSize) {
|
|
|
|
+ this.status = 'noMore'; // 没有更多数据
|
|
|
|
+ } else {
|
|
|
|
+ this.status = 'more'; // 还有更多数据
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ // 这里是获取列表的方法
|
|
|
|
+
|
|
uni.stopPullDownRefresh();
|
|
uni.stopPullDownRefresh();
|
|
},
|
|
},
|
|
|
|
+ findNodes(tree, id) {
|
|
|
|
+ let result = [];
|
|
|
|
+ for (let v in tree) {
|
|
|
|
+ let node = tree[v];
|
|
|
|
+ if (node.id == id || node.parentId == id) {
|
|
|
|
+ result.push(node)
|
|
|
|
+ };
|
|
|
|
+ if (node.children) {
|
|
|
|
+ result = result.concat(this.findNodes(node.children, id));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ },
|
|
//格式化时间
|
|
//格式化时间
|
|
dataFormat(rows) {
|
|
dataFormat(rows) {
|
|
|
|
+ // 创建一个映射对象,键是id,值是productName
|
|
|
|
+ const idToProductName = this.categories.reduce((acc, cur) => {
|
|
|
|
+ acc[cur.id] = cur.productName;
|
|
|
|
+ return acc;
|
|
|
|
+ }, {});
|
|
return rows.map(item => {
|
|
return rows.map(item => {
|
|
let date = new Date(item.createTime);
|
|
let date = new Date(item.createTime);
|
|
item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
|
|
item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
|
|
|
|
+ // 使用映射对象将type的值从id转换为productName
|
|
|
|
+ item.type = idToProductName[item.type] || item.type;
|
|
return item;
|
|
return item;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
//根据分类id查询列表
|
|
//根据分类id查询列表
|
|
change(e) {
|
|
change(e) {
|
|
- this.queryParams.type = e.detail.index;
|
|
|
|
listQuotations(this.queryParams).then(response => {
|
|
listQuotations(this.queryParams).then(response => {
|
|
- this.quotationsList = response.rows.map(item => {
|
|
|
|
- let date = new Date(item.createTime);
|
|
|
|
- item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
|
|
|
|
- return item;
|
|
|
|
- });
|
|
|
|
|
|
+ if (this.queryParams.pageNum === 1) {
|
|
|
|
+ this.quotationsList = this.dataFormat(response.rows)
|
|
|
|
+ } else {
|
|
|
|
+ this.quotationsList = this.quotationsList.concat(this.dataFormat(response.rows));
|
|
|
|
+ }
|
|
|
|
+ // 判断是否还有更多数据
|
|
|
|
+ if (response.rows.length < this.queryParams.pageSize) {
|
|
|
|
+ this.status = 'noMore'; // 没有更多数据
|
|
|
|
+ } else {
|
|
|
|
+ this.status = 'more'; // 还有更多数据
|
|
|
|
+ }
|
|
});
|
|
});
|
|
},
|
|
},
|
|
updateImg(imgList) {
|
|
updateImg(imgList) {
|