quotations.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view>
  3. <view>
  4. <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll" scroll-left="120">
  5. <uni-grid :column="5" @change="change" showBorder="false" square="false">
  6. <uni-grid-item v-for="item in categories" :index="item.id">
  7. <view class="grid-item-box">
  8. <image class="image" :src="loadImgSrc(item.icon)" mode="aspectFit"></image>
  9. <text class="text">{{ item.productName }}</text>
  10. </view>
  11. </uni-grid-item>
  12. </uni-grid>
  13. </scroll-view>
  14. </view>
  15. <view class="uni-container">
  16. <uni-table>
  17. <uni-tr>
  18. <uni-th width="80" align="center">名称</uni-th>
  19. <uni-th width="80" align="center">类型</uni-th>
  20. <uni-th width="80" align="center">价格</uni-th>
  21. <uni-th width="100" align="center">时间</uni-th>
  22. </uni-tr>
  23. <uni-tr v-for="(item, index) in quotationsList" :key="index">
  24. <uni-td align="center">{{ item.productName }}
  25. </uni-td>
  26. <uni-td align="center">
  27. <view class="name">{{ item.type }}</view>
  28. </uni-td>
  29. <uni-td align="center">{{ item.price }}
  30. </uni-td>
  31. <uni-td align="center">{{ item.createTime }}
  32. </uni-td>
  33. </uni-tr>
  34. </uni-table>
  35. <uni-fab ref="fab" :horizontal="right" :vertical="bottom"
  36. @fabClick="fabClick('bottom')"/>
  37. </view>
  38. <uni-popup ref="popup" background-color="#fff" @change="popup">
  39. <view class="example">
  40. <!-- 基础用法,不包含校验规则 -->
  41. <uni-forms ref="baseForm" :modelValue="form" >
  42. <uni-forms-item label="产品名称" required>
  43. <uni-easyinput v-model="form.productName" placeholder="请输入产品名称" />
  44. </uni-forms-item>
  45. <uni-forms-item label="地区" required>
  46. <uni-easyinput v-model="form.area" placeholder="请输入地区" />
  47. </uni-forms-item>
  48. <uni-forms-item label="价格" required>
  49. <uni-easyinput v-model="form.price" placeholder="请输入价格" />
  50. </uni-forms-item>
  51. <uni-forms-item label="地址" required>
  52. <uni-easyinput v-model="form.address" placeholder="请输入地址" />
  53. </uni-forms-item>
  54. <uni-forms-item label="手机号" required>
  55. <uni-easyinput v-model="form.phone" placeholder="请输入手机号" />
  56. </uni-forms-item>
  57. <uni-forms-item label="图片" required>
  58. <upload :imgArr="imageList" :fileSize="1" :limit="3" @updateImg="updateImg"></upload>
  59. </uni-forms-item>
  60. </uni-forms>
  61. </view>
  62. </uni-popup>
  63. </view>
  64. </template>
  65. <script>
  66. import {listConfig, listQuotations} from "@/api/quotations/quotations";
  67. export default {
  68. data() {
  69. return {
  70. //是否显示弹出层
  71. open: false,
  72. //悬浮按钮右对齐
  73. right:'right',
  74. //悬浮按钮下对齐
  75. bottom:'bottom',
  76. //分类列表
  77. categories: [
  78. // 这里是一级分类的数据
  79. ],
  80. // 行情列表
  81. quotationsList: [
  82. // 这里是列表的数据
  83. ],
  84. //查询参数
  85. queryParams: {
  86. // pageNum: 1,
  87. // pageSize: 10,
  88. id: null,
  89. },
  90. //表单数据
  91. form:{},
  92. imageList:[]
  93. }
  94. },
  95. created() {
  96. this.getList();
  97. },
  98. methods: {
  99. getList(row) {
  100. // 这里是获取列表的方法
  101. listQuotations().then(response => {
  102. this.quotationsList = response.rows.map(item => {
  103. let date = new Date(item.createTime);
  104. item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
  105. return item;
  106. });
  107. });
  108. //获取分类树的方法
  109. listConfig().then(response => {
  110. this.categories = response.data.quotations;
  111. });
  112. },
  113. //根据分类id查询列表
  114. change(e) {
  115. this.queryParams.type = e.detail.index;
  116. listQuotations(this.queryParams).then(response => {
  117. this.quotationsList = response.rows.map(item => {
  118. let date = new Date(item.createTime);
  119. item.createTime = date.toLocaleDateString('zh-CN', {dateStyle: 'short'});
  120. return item;
  121. });
  122. });
  123. },
  124. //悬浮按钮点击事件
  125. fabClick(type){
  126. this.type = type
  127. // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
  128. this.$refs.popup.open(type)
  129. },
  130. popup(){
  131. }
  132. }
  133. }
  134. </script>
  135. <style>
  136. .grid-item-box {
  137. flex: 1;
  138. // position: relative;
  139. /* #ifndef APP-NVUE */
  140. display: flex;
  141. /* #endif */
  142. flex-direction: column;
  143. align-items: center;
  144. justify-content: center;
  145. padding: 0px 0;
  146. }
  147. .image {
  148. height: 100%;
  149. width: 100%;
  150. }
  151. </style>