|
@@ -0,0 +1,347 @@
|
|
|
+<template>
|
|
|
+ <view class="list">
|
|
|
+ <view class="search">
|
|
|
+ <wd-search
|
|
|
+ ref="search"
|
|
|
+ v-model="value"
|
|
|
+ cancel-txt="搜索"
|
|
|
+ @cancel="onSearch"
|
|
|
+ :disabled="searchType === '项目名称'"
|
|
|
+ >
|
|
|
+ <template #prefix>
|
|
|
+ <wd-popover v-model="show" mode="menu" :content="menu" @menuclick="changeSearchType">
|
|
|
+ <view class="search-type">
|
|
|
+ <text>{{ searchType }}</text>
|
|
|
+ <wd-icon custom-class="icon-arrow" name="fill-arrow-down"></wd-icon>
|
|
|
+ </view>
|
|
|
+ </wd-popover>
|
|
|
+ </template>
|
|
|
+ </wd-search>
|
|
|
+ </view>
|
|
|
+ <view style="height: 70px"></view>
|
|
|
+ <view v-if="listData.length > 0">
|
|
|
+ <wd-card v-for="(item, index) in oldData" :key="index">
|
|
|
+ <view v-for="(child, childIndex) in item" :key="childIndex">
|
|
|
+ <view class="flex">
|
|
|
+ <view class="left">{{ child.text }}:</view>
|
|
|
+ <view class="right">{{ child.value }}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <!-- <view class="flex">
|
|
|
+ <view>采购数量:</view>
|
|
|
+ <view>
|
|
|
+ {{ item['采购数量(吨)'] ? item['采购数量(吨)'] : item['采购数量(升)'] }}
|
|
|
+ {{ item['单位吨或者升'] }}
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="flex">
|
|
|
+ <view>采购金额(元):</view>
|
|
|
+ <view>{{ item['采购金额(元)'] }}</view>
|
|
|
+ </view>
|
|
|
+ <view class="flex">
|
|
|
+ <view>采购单号:</view>
|
|
|
+ <view>{{ item['采购单号'] }}</view>
|
|
|
+ </view>
|
|
|
+ <view class="flex">
|
|
|
+ <view>项目名称:</view>
|
|
|
+ <view>{{ item['项目名称'] }}</view>
|
|
|
+ </view>
|
|
|
+ <view class="flex">
|
|
|
+ <view>价差:</view>
|
|
|
+ <view>{{ item['价差'] }}</view>
|
|
|
+ </view>
|
|
|
+ <view class="flex">
|
|
|
+ <view>销售价格:</view>
|
|
|
+ <view>{{ item['销售价格'] }}</view>
|
|
|
+ </view> -->
|
|
|
+ <template #footer>
|
|
|
+ <wd-button size="small" plain @click="editClick(item)">编辑</wd-button>
|
|
|
+ </template>
|
|
|
+ </wd-card>
|
|
|
+ <wd-loadmore custom-class="loadmore" :state="loadState" />
|
|
|
+ </view>
|
|
|
+ <view v-else>
|
|
|
+ <wd-loadmore custom-class="loadmore" state="finished" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <wd-action-sheet
|
|
|
+ v-model="sheetShow"
|
|
|
+ :actions="columns"
|
|
|
+ title="项目名称"
|
|
|
+ @close="close"
|
|
|
+ @select="onSelect"
|
|
|
+ cancel-text="取消"
|
|
|
+ ></wd-action-sheet>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { onLoad, onReachBottom } from '@dcloudio/uni-app';
|
|
|
+import dataService from '@/api/procure';
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
+const value = ref('');
|
|
|
+const searchType = ref('采购单号');
|
|
|
+const loadState = ref('loading');
|
|
|
+const columns = ref([]);
|
|
|
+const show = ref(false);
|
|
|
+const sheetShow = ref(false);
|
|
|
+const menu = ref([
|
|
|
+ {
|
|
|
+ content: '采购单号',
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ content: '采购单名称',
|
|
|
+ value: 2,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ content: '项目名称',
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+]);
|
|
|
+const listData = ref([]);
|
|
|
+const dbLinkId = ref('');
|
|
|
+const tableColumns = ref([]);
|
|
|
+const isMore = ref(true);
|
|
|
+const idKey = ref('');
|
|
|
+const form = ref({
|
|
|
+ pageQuery: {
|
|
|
+ current: 1,
|
|
|
+ size: 20,
|
|
|
+ },
|
|
|
+ paramList: [
|
|
|
+ {
|
|
|
+ cubeColumnId: 875,
|
|
|
+ function: 'like',
|
|
|
+ values: [],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+});
|
|
|
+const oldData = ref([]);
|
|
|
+const formData = ref([]);
|
|
|
+
|
|
|
+onLoad((options) => {
|
|
|
+ projectList();
|
|
|
+ getFormConfig();
|
|
|
+});
|
|
|
+
|
|
|
+onReachBottom(() => {
|
|
|
+ if (isMore.value) {
|
|
|
+ form.value.pageQuery.current++;
|
|
|
+ getFormList();
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+// 获取采购管理-项目列表
|
|
|
+function projectList() {
|
|
|
+ dataService.getProjectList().then((res) => {
|
|
|
+ if (res.data.code === 200) {
|
|
|
+ columns.value = res.data.data.map((item) => {
|
|
|
+ return {
|
|
|
+ name: item['项目名称'],
|
|
|
+ };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ columns.value = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 获取表单配置信息
|
|
|
+function getFormConfig() {
|
|
|
+ dataService.getConfig('f7436dcb6bbd469b1d154511ab74dd0f').then((res) => {
|
|
|
+ const { code, data } = res.data;
|
|
|
+ if (code === 200) {
|
|
|
+ idKey.value = String(data.idKey);
|
|
|
+ formData.value = JSON.parse(data.formData);
|
|
|
+ dbLinkId.value = data.dbLinkId;
|
|
|
+ tableColumns.value = JSON.parse(data.tables);
|
|
|
+ getFormList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function editClick(item) {
|
|
|
+ uni.navigateTo({
|
|
|
+ url:
|
|
|
+ '/pages/procure/edit?item=' +
|
|
|
+ JSON.stringify(item) +
|
|
|
+ '&formId=f7436dcb6bbd469b1d154511ab74dd0f',
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 搜索
|
|
|
+function onSearch() {
|
|
|
+ oldData.value = [];
|
|
|
+ form.value.pageQuery.current = 1;
|
|
|
+ isMore.value = true;
|
|
|
+ getFormList();
|
|
|
+}
|
|
|
+
|
|
|
+// 获取列表信息
|
|
|
+function getFormList() {
|
|
|
+ if (searchType.value !== '项目名称') {
|
|
|
+ form.value.paramList[0].values = [value.value];
|
|
|
+ }
|
|
|
+ const params = {
|
|
|
+ dbLinkId: dbLinkId.value,
|
|
|
+ form: form.value,
|
|
|
+ };
|
|
|
+ dataService.getFormList(params).then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const { columnDict, pageData } = res.data;
|
|
|
+ if (pageData.records.length < 20 || pageData.records.length == 0) {
|
|
|
+ loadState.value = 'finished';
|
|
|
+ isMore.value = false;
|
|
|
+ } else {
|
|
|
+ isMore.value = true;
|
|
|
+ loadState.value = 'loading';
|
|
|
+ }
|
|
|
+ const arr = tableColumns.value.map((val) => {
|
|
|
+ for (const key in columnDict) {
|
|
|
+ if (val.fieldId == key) {
|
|
|
+ val.filedCode = columnDict[key];
|
|
|
+ } else {
|
|
|
+ const obj = {
|
|
|
+ filedCode: columnDict[key],
|
|
|
+ fieldName: 'idKey',
|
|
|
+ };
|
|
|
+ }
|
|
|
+ val.valueKey = key;
|
|
|
+ }
|
|
|
+ return val;
|
|
|
+ });
|
|
|
+ arr.push({
|
|
|
+ filedCode: columnDict[idKey.value],
|
|
|
+ fieldName: 'idKey',
|
|
|
+ valueKey: idKey.value,
|
|
|
+ fieldId: idKey.value,
|
|
|
+ });
|
|
|
+ listData.value = pageData.records.map((val) => {
|
|
|
+ const newObj = [];
|
|
|
+ for (const k in val) {
|
|
|
+ arr.forEach((v) => {
|
|
|
+ const obj = {};
|
|
|
+ if (v.filedCode == k) {
|
|
|
+ newObj.push({
|
|
|
+ text: v.fieldName,
|
|
|
+ value: val[k],
|
|
|
+ valueKey: v.fieldId,
|
|
|
+ });
|
|
|
+ // newObj[v.fieldName] = val[k];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return newObj;
|
|
|
+ });
|
|
|
+ if (form.value.pageQuery.current > 1) {
|
|
|
+ listData.value.forEach((item) => {
|
|
|
+ oldData.value.push(item);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ oldData.value = listData.value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function changeSearchType(e) {
|
|
|
+ // oldData.value = [];
|
|
|
+ searchType.value = e.item.content;
|
|
|
+ form.value.pageQuery.current = 1;
|
|
|
+ isMore.value = true;
|
|
|
+ if (e.item.value === 3) {
|
|
|
+ sheetShow.value = true;
|
|
|
+ } else if (e.item.value === 1) {
|
|
|
+ form.value.paramList = [
|
|
|
+ {
|
|
|
+ cubeColumnId: 875,
|
|
|
+ function: 'like',
|
|
|
+ values: [],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ form.value.paramList = [
|
|
|
+ {
|
|
|
+ cubeColumnId: 572,
|
|
|
+ function: 'like',
|
|
|
+ values: [],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function onSelect({ item, rowIndex, colIndex }) {
|
|
|
+ form.value.paramList = [
|
|
|
+ {
|
|
|
+ cubeColumnId: 572,
|
|
|
+ function: 'in',
|
|
|
+ values: [item.name],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ getFormList();
|
|
|
+}
|
|
|
+// 关闭项目选项
|
|
|
+function close() {
|
|
|
+ searchType.value = '采购单号';
|
|
|
+ sheetShow.value = false;
|
|
|
+ value.value = '';
|
|
|
+ oldData.value = [];
|
|
|
+ form.value.pageQuery.current = 1;
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.list {
|
|
|
+ min-height: calc(100vh - var(--window-top) - var(--window-bottom));
|
|
|
+ width: 100vw;
|
|
|
+ box-sizing: border-box;
|
|
|
+ background: #f1f1f1;
|
|
|
+ position: relative;
|
|
|
+ // padding: 0 15px;
|
|
|
+ // box-sizing: border-box;
|
|
|
+ // background-image: url('https://pic.imgdb.cn/item/65796604c458853aef1aec2a.jpg');
|
|
|
+ // background-size: 100% 100%;
|
|
|
+ .search {
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100%;
|
|
|
+ .search-type {
|
|
|
+ position: relative;
|
|
|
+ height: 30px;
|
|
|
+ line-height: 30px;
|
|
|
+ padding: 0 8px 0 16px;
|
|
|
+ }
|
|
|
+ .search-type::after {
|
|
|
+ position: absolute;
|
|
|
+ content: '';
|
|
|
+ width: 1px;
|
|
|
+ right: 0;
|
|
|
+ top: 5px;
|
|
|
+ bottom: 5px;
|
|
|
+ background: rgba(0, 0, 0, 0.25);
|
|
|
+ }
|
|
|
+ .search-type {
|
|
|
+ :deep(.icon-arrow) {
|
|
|
+ display: inline-block;
|
|
|
+ font-size: 20px;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .flex {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .left {
|
|
|
+ width: 30%;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ .right {
|
|
|
+ flex: 1;
|
|
|
+ text-align: right;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|