• 小程序 打开方式 页面效果 表单页面 点击跳到详情页 图标 获取后台数据 进行页面渲染


     请求地址:geecg-uniapp 同源策略 数据请求 获取后台数据 ui库安装 冲突解决(3)-CSDN博客

    一.uniapp转小程序  

    (1)  运行微信开发工具

    (2) 配置id  然后运行

     打开小程序  路径  E:\通\uniapp-jeecg\unpackage\dist\dev\mp-weixin

    (5)运行

    二.表单页面

    1. <template>
    2. <view>
    3. <cu-custom bgColor="bg-gradual-blue" :isBack="true">
    4. <block slot="content">额外加工</block>
    5. </cu-custom>
    6. <uni-section title=" ">
    7. <view style="margin: 0 20px;">
    8. <uni-forms ref="customForm" :rules="customRules" :modelValue="customFormData">
    9. <uni-forms-item label="类型" required name="seType">
    10. <uni-data-select v-model="customFormData.seType" :localdata="range" style="width: 215px; "
    11. @change="select"></uni-data-select>
    12. </uni-forms-item>
    13. <uni-forms-item label="石材编号" required name="seRknum">
    14. <uni-data-select style="width: 215px; " v-model="customFormData.seRknum" :localdata="candidates"></uni-data-select>
    15. </uni-forms-item>
    16. <uni-forms-item label="日期时间" required name="seDate">
    17. <uni-datetime-picker style="width: 215px; " type="datetime" return-type="timestamp" v-model="customFormData.seDate" />
    18. </uni-forms-item>
    19. <uni-forms-item label="长" required name="seLong">
    20. <!-- <input v-model="customFormData.seLong" placeholder="请输入长" type="number" /> -->
    21. <input class="uni-input " name="input" v-model="customFormData.seLong" placeholder="请输入长"
    22. @input="fpNumInput" />
    23. </uni-forms-item>
    24. <uni-forms-item label="宽" required name="seWeight">
    25. <input class="uni-input " name="input" v-model="customFormData.seWeight" placeholder="请输入宽"
    26. type="number" @input="fpNumInputseWeight" />
    27. </uni-forms-item>
    28. <uni-forms-item label="高" required name="seHeight">
    29. <input class="uni-input " name="input" v-model="customFormData.seHeight" placeholder="请输入高"
    30. type="number" @input="fpNumInputseHeight" />
    31. </uni-forms-item>
    32. <uni-forms-item label="数量" required name="seNum">
    33. <input class="uni-input " name="input" v-model="customFormData.seNum" placeholder="请输入数量"
    34. type="number" @input="fpNumInputseNum" />
    35. </uni-forms-item>
    36. <uni-forms-item label="面积" required name="seMj">
    37. <input class="uni-input " name="input" v-model="customFormData.seMj" placeholder="请输入面积"
    38. type="number" @input="fpNumInputseMj" />
    39. </uni-forms-item>
    40. <uni-forms-item label="体积" required name="seTj">
    41. <input class="uni-input " name="input" v-model="customFormData.seTj" placeholder="请输入体积"
    42. type="number" @input="fpNumInputseTj" />
    43. </uni-forms-item>
    44. <uni-forms-item label="额外加工" required name="sePromed">
    45. <uni-data-select style="width: 215px; " v-model="customFormData.sePromed" :localdata="sePromed"></uni-data-select>
    46. </uni-forms-item>
    47. <uni-forms-item label="机组" required name="seSet">
    48. <uni-data-select style="width: 215px; " v-model="customFormData.seSet" :localdata="seSets"></uni-data-select>
    49. </uni-forms-item>
    50. <uni-forms-item label="单价" required name="sePrice">
    51. <input class="uni-input " name="input" v-model="customFormData.sePrice" placeholder="请输入单价"
    52. type="number" @input="fpNumInputsePrice" />
    53. </uni-forms-item>
    54. <uni-forms-item label="总价">
    55. <input class="uni-input " name="input" v-model="customFormData.seZprice" placeholder="请输入总价"
    56. type="number" @input="fpNumInputseZprice" />
    57. </uni-forms-item>
    58. <uni-forms-item label="人员" required name="sePerson">
    59. <uni-data-select style="width: 215px; " v-model="customFormData.sePerson" :localdata="sePerson"></uni-data-select>
    60. </uni-forms-item>
    61. <uni-forms-item label="操作人">
    62. <uni-easyinput v-model="customFormData.seOpuser" placeholder="请输入操作人" disabled style="width: 215px; "/>
    63. <!-- <input class="uni-input " v-model="customFormData.seOpuser" placeholder="请输入操作人" disabled /> -->
    64. </uni-forms-item>
    65. <uni-forms-item label="图片" required name="sePic">
    66. <uni-file-picker v-model="imageValue" fileMediatype="image" mode="grid" @select="upload"
    67. @delete="delIMG" title="最多选择3张图片" :auto-upload='false' limit="3"></uni-file-picker>
    68. </uni-forms-item>
    69. <uni-forms-item label="备注">
    70. <uni-easyinput style="width: 215px; " type="textarea" v-model="customFormData.seRemake" placeholder="请输入备注" />
    71. </uni-forms-item>
    72. </uni-forms>
    73. <button type="primary" @click="submit('customForm')" style='background-color: blue;'>提交</button>
    74. </view>
    75. </uni-section>
    76. </view>
    77. </template>
    78. <script>
    79. export default {
    80. data() {
    81. return {
    82. imgURL: '',
    83. imageValue: [],
    84. imageUrls: [],
    85. tableDatafinish: [],
    86. // 定义初始数据 绑定类型 :localdata="range"
    87. range: [{
    88. value: 1,
    89. text: "荒料"
    90. },
    91. {
    92. value: 2,
    93. text: "板材成品"
    94. },
    95. {
    96. value: 3,
    97. text: "板材半成品"
    98. },
    99. {
    100. value: 4,
    101. text: "路边石成品"
    102. },
    103. {
    104. value: 5,
    105. text: "路边石半成品"
    106. },
    107. {
    108. value: 6,
    109. text: "界石成品"
    110. },
    111. {
    112. value: 7,
    113. text: "界石半成品"
    114. }
    115. ],
    116. // 定义初始数据 绑定石材编号 :localdata="candidates"
    117. candidates: [],
    118. // 定义初始数据 绑定机组 :localdata="seSet"
    119. seSets: [],
    120. // 定义初始数据 绑定机组 :localdata="seSet"
    121. sePerson: [],
    122. sePromed: [],
    123. // 定义初始数据 绑定输入框 获取输入数据 v-model="customFormData.xxx" aa
    124. customFormData: {
    125. seType: '',
    126. seRknum: '',
    127. seDate: new Date(),
    128. seLong: '',
    129. seWeight: '',
    130. seHeight: '',
    131. seNum: '',
    132. seMj: '',
    133. seTj: '',
    134. sePromed: '',
    135. seSet: '',
    136. sePrice: '',
    137. seZprice: '',
    138. sePerson: '',
    139. seOpuser: '',
    140. seRemake: '',
    141. sePic: ''
    142. },
    143. customRules: {
    144. seType: {
    145. rules: [{
    146. required: true,
    147. errorMessage: '石材编号不能为空'
    148. }]
    149. },
    150. seRknum: {
    151. rules: [{
    152. required: true,
    153. errorMessage: '石材编号不能为空'
    154. }]
    155. },
    156. seDate: {
    157. rules: [{
    158. required: true,
    159. errorMessage: '时间不能为空'
    160. }]
    161. },
    162. seLong: {
    163. rules: [{
    164. required: true,
    165. errorMessage: '长度不能为空'
    166. }]
    167. },
    168. // seLong: [
    169. // { required: true, message: '请再次输入密码', trigger: 'blur' },
    170. // { pattern: /^\S{6,15}$/, message: '请输入 6 ~ 15 位的非空字符', trigger: 'blur' },
    171. // ],
    172. seWeight: {
    173. rules: [{
    174. required: true,
    175. errorMessage: '宽度不能为空'
    176. }]
    177. },
    178. seHeight: {
    179. rules: [{
    180. required: true,
    181. errorMessage: '高度不能为空'
    182. }]
    183. },
    184. seNum: {
    185. rules: [{
    186. required: true,
    187. errorMessage: '数量不能为空'
    188. }]
    189. },
    190. seMj: {
    191. rules: [{
    192. required: true,
    193. errorMessage: '面积不能为空'
    194. }]
    195. },
    196. seTj: {
    197. rules: [{
    198. required: true,
    199. errorMessage: '体积不能为空'
    200. }]
    201. },
    202. sePromed: {
    203. rules: [{
    204. required: true,
    205. errorMessage: '额外加工不能为空'
    206. }]
    207. },
    208. seSet: {
    209. rules: [{
    210. required: true,
    211. errorMessage: '机组不能为空'
    212. }]
    213. },
    214. sePrice: {
    215. rules: [{
    216. required: true,
    217. errorMessage: '单价不能为空'
    218. }]
    219. },
    220. sePerson: {
    221. rules: [{
    222. required: true,
    223. errorMessage: '人员不能为空'
    224. }]
    225. },
    226. },
    227. }
    228. },
    229. mounted() {
    230. // 机组
    231. let url33 = '/ewjg/smsEwjg/gztj';
    232. this.$http.get(url33).then(res => {
    233. console.log(res.data.result)
    234. res.data.result.records.forEach(value => { //循环 添加到 candidates
    235. this.seSets.push({
    236. value: value.seSet,
    237. text: value.seSet_dictText
    238. })
    239. })
    240. res.data.result.records.forEach(value => { //循环 添加到 candidates
    241. this.sePerson.push({
    242. value: value.sePerson,
    243. text: value.sePerson_dictText
    244. })
    245. })
    246. res.data.result.records.forEach(value => { //循环 添加到 candidates
    247. this.sePromed.push({
    248. value: value.sePromed,
    249. text: value.sePromed_dictText
    250. })
    251. })
    252. })
    253. },
    254. methods: {
    255. fpNumInput(e) {
    256. const o = e.target;
    257. const inputRule = /[^\d]/g
    258. this.$nextTick(function() {
    259. this.customFormData.seLong = o.value.replace(inputRule, '');
    260. })
    261. },
    262. fpNumInputseWeight(e) {
    263. const o = e.target;
    264. const inputRule = /[^\d]/g
    265. this.$nextTick(function() {
    266. this.customFormData.seWeight = o.value.replace(inputRule, '');
    267. })
    268. },
    269. fpNumInputseHeight(e) {
    270. const o = e.target;
    271. const inputRule = /[^\d]/g
    272. this.$nextTick(function() {
    273. this.customFormData.seHeight = o.value.replace(inputRule, '');
    274. })
    275. },
    276. fpNumInputseNum(e) {
    277. const o = e.target;
    278. const inputRule = /[^\d]/g
    279. this.$nextTick(function() {
    280. this.customFormData.seNum = o.value.replace(inputRule, '');
    281. })
    282. },
    283. fpNumInputseMj(e) {
    284. const o = e.target;
    285. const inputRule = /[^\d]/g
    286. this.$nextTick(function() {
    287. this.customFormData.seMj = o.value.replace(inputRule, '');
    288. })
    289. },
    290. fpNumInputseTj(e) {
    291. const o = e.target;
    292. const inputRule = /[^\d]/g
    293. this.$nextTick(function() {
    294. this.customFormData.seTj = o.value.replace(inputRule, '');
    295. })
    296. },
    297. fpNumInputsePrice(e) {
    298. const o = e.target;
    299. const inputRule = /[^\d]/g
    300. this.$nextTick(function() {
    301. this.customFormData.sePrice = o.value.replace(inputRule, '');
    302. })
    303. },
    304. fpNumInputseZprice(e) {
    305. const o = e.target;
    306. const inputRule = /[^\d]/g
    307. this.$nextTick(function() {
    308. this.customFormData.seZprice = o.value.replace(inputRule, '');
    309. })
    310. },
    311. // 获取上传状态
    312. upload(e) {
    313. this.imageValue.push(e.tempFiles[0])
    314. },
    315. delIMG(e) {
    316. const index = this.imageValue.findIndex(v => v.url === e.tempFilePath);
    317. if (index !== -1) {
    318. this.imageValue.splice(index, 1);
    319. }
    320. },
    321. submitImage() {
    322. if (this.imageValue.length != 0) {
    323. const uploadPromises = this.imageValue.map(val => {
    324. const formData = {
    325. biz: 'temp',
    326. };
    327. return new Promise((resolve, reject) => {
    328. uni.uploadFile({
    329. url: 'http://43.138.31.228:1888/jeecg-boot/sys/common/upload',
    330. formData: formData,
    331. filePath: val.path,
    332. name: 'file',
    333. fileType: 'image',
    334. fileName: val.name,
    335. success: (uploadFileRes) => {
    336. var jsonObject = JSON.parse(uploadFileRes.data);
    337. const imageUrl = jsonObject.message;
    338. this.imageUrls.push(imageUrl); // 将每次上传的图片链接添加到数组中
    339. if (this.imageUrls.length > 1) {
    340. this.customFormData.sePic = this.imageUrls.join(',');
    341. } else {
    342. this.customFormData.sePic = imageUrl
    343. }
    344. resolve();
    345. },
    346. fail: (err) => {
    347. reject(err);
    348. }
    349. });
    350. });
    351. });
    352. this.imageUrls = []
    353. return Promise.all(uploadPromises)
    354. } else {
    355. this.customFormData.sePic = '';
    356. return Promise.resolve(); // 如果没有上传图片,直接返回一个已解决的Promise对象
    357. }
    358. },
    359. select() {
    360. let url3 = '/cwkhfk/cwKhfk/scxxList';
    361. let params = {
    362. type: this.value //定义 this.value 赋值给type 最后parmas
    363. }
    364. this.$http.get(url3, {
    365. params: params //定义赋值 params = parmas
    366. }).then(res => {
    367. // this.candidates = res.data.result
    368. res.data.result.forEach(value => { //循环 添加到 candidates
    369. this.candidates.push({
    370. value: value.number,
    371. text: value.number
    372. })
    373. })
    374. })
    375. },
    376. async submit(ref) {
    377. console.log('tijiao')
    378. // await this.submitImage();
    379. // console.log(this.customFormData.sePic)
    380. // //添加上传
    381. // let customFormData = this.customFormData
    382. // // 获取数据进行添加
    383. // let url = '/ewjg/smsEwjg/add';
    384. // var params = customFormData //定义赋值 params = customFormData 后端带着parmas去后端
    385. // this.$http.post(url, params).then(res => {
    386. // this.customFormData = res.data.result
    387. // })
    388. // this.customFormData = ''
    389. // this.$refs[ref].validate().then(res => {
    390. // console.log('success', res);
    391. // uni.showToast({
    392. // title: `校验通过`
    393. // })
    394. // }).catch(err => {
    395. // console.log('err', err);
    396. // })
    397. },
    398. }
    399. }
    400. </script>
    401. <style>
    402. .uni-input {
    403. width: 215px;
    404. font-size: 12px;
    405. height: 35px;
    406. border: 1px solid #dedede;
    407. padding: 0 5px;
    408. border-radius: 5px;
    409. }
    410. </style>

    二. 点击跳到详情页

     父页面

    1. <template>
    2. <view class="order-list">
    3. <cu-custom bgColor="bg-gradual-blue" :isBack="true">
    4. <block slot="content">荒料管理</block>
    5. </cu-custom>
    6. <view class="" >
    7. <!-- 订单展示 -->
    8. <mescroll-uni ref="mescrollRef" @init="mescrollInit" top="60rpx" @down="downCallback" @up="upCallback">
    9. <!-- 数据列表 -->
    10. <view class="data-list" style=" margin-top: 2rem;">
    11. <!-- 空内容展示-->
    12. <u-empty :text="textNoMore" v-if="dataList.length==0" mode="list"></u-empty>
    13. <!-- 空内容展示End-->
    14. <view class="order margin-top-sm" v-for="(item, aindex) in dataList" :key="item.id"
    15. @click="jumpToOrder(item)">
    16. <view class='bg-white padding-sm flex padding-right-zero flex-between'>
    17. <view class='flex-sub radius text-left text-xs margin-top-xs'>
    18. <image src="../../static/common/huang.png"
    19. style="width: 100rpx;height: 80rpx;margin-top: -10px;"></image>
    20. </view>
    21. <view class='flex-sub radius text-left text-xs margin-top-xs'
    22. style="margin-left: -200px;font-size: 12px;">
    23. 编号:{{ item.sbwWarehousingNumber}}</view>
    24. </view>
    25. <view class="bg-white padding-sm solid-top" >
    26. <view class='padding-top-sm text-sm flex'>
    27. <view class="left-title" style="font-size: 12px;">日期:</view><view class="right-content" style="font-size: 12px;">{{ item.sbwWarehousingDate}}</view>
    28. </view>
    29. <view class='padding-top-sm text-sm flex'></view>
    30. </view>
    31. </view>
    32. <!-- 返回顶部 -->
    33. <u-back-top :scroll-top="scrollTop" top="600">
    34. </u-back-top>
    35. <!-- 返回顶部End -->
    36. </view>
    37. </mescroll-uni>
    38. </view>
    39. <!-- 订单展示完毕End -->
    40. </view>
    41. </template>
    42. <script>
    43. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
    44. import configService from '@/common/service/config.service.js';
    45. export default {
    46. mixins: [MescrollMixin],
    47. data() {
    48. return {
    49. pageable: {
    50. pageIndex: 0,
    51. pageSize: 10
    52. },
    53. list: [{
    54. complainantStatus: '0',
    55. name: '待解决'
    56. }, {
    57. complainantStatus: '10',
    58. name: '已解决'
    59. }],
    60. textNoMore :'-- 没有更多数据了 --',
    61. tabCurrent: 0,
    62. scrollTop: 0,
    63. dataList: [],
    64. }
    65. },
    66. methods: {
    67. //下拉刷新
    68. downCallback() {
    69. this.mescroll.scrollTo(0, 0)
    70. this.mescroll.resetUpScroll();
    71. },
    72. //上拉加载
    73. async upCallback(pages) {
    74. let pageIndex = pages.num // 页码, 默认从1开始
    75. let pageSize = pages.size // 页长, 默认每页10
    76. this.pageable.pageIndex = pageIndex
    77. this.pageable.pageSize = pageSize
    78. let data = await this.getOrder(this.pageable)
    79. console.log("data" + data)
    80. const curPageData = data.records || []
    81. if (data && curPageData.length > 0) {
    82. const curPageLen = curPageData.length // 当前数据长度
    83. const totalPage = data.total // 获取接口总共有多少页
    84. this.mescroll.endByPage(curPageLen, totalPage);
    85. } else {
    86. this.mescroll.endErr()
    87. }
    88. },
    89. //订单列表
    90. async getOrder(pageable) {
    91. let that = this
    92. let params = {
    93. openid: uni.getStorageSync("openId"),
    94. complainantStatus: this.list[this.tabCurrent].complainantStatus,
    95. pageNo: pageable.pageIndex,
    96. pageSize: pageable.pageSize
    97. }
    98. // console.log(params)
    99. let preData = {
    100. records: []
    101. }
    102. // 获取列表数据
    103. await that.$http.get('/block/smsBlockWarehousing/list', {
    104. params: params
    105. }).then(res => {
    106. console.log(res)
    107. if (res.data.success !== true) {
    108. that.$tip.alert(res.data.message)
    109. } else {
    110. if (pageable.pageIndex < 2)
    111. that.dataList = [] // 如果是第一页需手动置空列表
    112. that.dataList.push(...res.data.result.records) //数据添加到dataList
    113. console.log(res.data.result)
    114. preData = res.data.result;
    115. }
    116. }).catch(err => {
    117. // that.$tip.alert("网络波动,请重试!")
    118. console.log("err")
    119. })
    120. console.log(preData)
    121. return preData
    122. },
    123. // 点击跳转到huangliao页面 携带当前点击的id 过去
    124. jumpToOrder(item) {
    125. // console.log(item, 'adad')
    126. uni.navigateTo({
    127. url: '/pages/common/huangliao?id=' + item.id
    128. })
    129. },
    130. }
    131. }
    132. </script>

    子页面

    1. <template>
    2. <view style="background-color: #ffffff;">
    3. <cu-custom bgColor="bg-gradual-blue" :isBack="true">
    4. <block slot="content">荒料详情</block>
    5. </cu-custom>
    6. <u-form :model="form" ref="uForm">
    7. <view class="container">
    8. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ; display: flex;">入库编号 :<span
    9. style="color:#666;">{{form.sbwWarehousingNumber}}</span></view>
    10. <view style="border: #e5e5e5 1px solid; margin: 10px;"></view>
    11. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">入库日期 :<span
    12. style="color:#666;">{{form.sbwWarehousingDate}}</span></view>
    13. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    14. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">荒料种类 :<span
    15. style="color:#666;">{{form.sbwName_dictText}}</span></view>
    16. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    17. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">长 :<span
    18. style="color:#666;">{{form.sbwLong}}</span></view>
    19. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    20. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">宽 :<span
    21. style="color:#666;">{{form.sbwWidth}}</span></view>
    22. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    23. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">高 :<span
    24. style="color:#666;">{{form.sbwTall}}</span></view>
    25. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    26. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">体积 :<span
    27. style="color:#666;">{{form.sbwSbwVolume}}</span></view>
    28. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    29. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">颜色 :<span
    30. style="color:#666;">{{form.sbwColor_dictText}}</span></view>
    31. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    32. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">价格 :<span
    33. style="color:#666;">{{form.sbwPrice}}</span></view>
    34. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    35. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">数量 :<span
    36. style="color:#666;">{{form.sbwNum}}</span></view>
    37. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    38. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">运单单价 :<span
    39. style="color:#666;">{{form.sbwFreightPrice}}</span></view>
    40. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    41. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">运费 :<span
    42. style="color:#666;">{{form.sbwFreight}}</span></view>
    43. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    44. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">运输人 :<span
    45. style="color:#666;">{{form.sbwTransporter_dictText}}</span></view>
    46. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    47. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">总价 :<span
    48. style="color:#666;">{{form.sbwNum}}</span></view>
    49. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    50. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">料场 :<span
    51. style="color:#666;">{{form.sbwFreight}}</span></view>
    52. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    53. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">操作员 :<span
    54. style="color:#666;">{{form.sbwTransporter_dictText}}</span></view>
    55. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    56. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">图片 :<!-- <span
    57. style="color:#666;">{{form.sbwPic}}</span> -->
    58. <image src="form.sbwPic" mode=""></image>
    59. </view>
    60. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    61. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">文件 :<span
    62. style="color:#666;">{{form.sbwFile}}</span></view>
    63. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    64. <view style="margin-top: 5px; font-size: 13px;padding:10px 15px ;">备注 :<span
    65. style="color:#666;">{{form.sbwRemake}}</span></view>
    66. <view style="border: #e5e5e5 1px solid; margin: 10px;;"></view>
    67. </view>
    68. </u-form>
    69. </view>
    70. </template>
    71. <script>
    72. export default {
    73. data() {
    74. return {
    75. form: {
    76. sbwWarehousingDate: '',
    77. sbwWarehousingNumber: '',
    78. sbwName_dictText: '',
    79. sbwLong: '',
    80. sbwWidth: '',
    81. sbwTall: '',
    82. sbwSbwVolume: '',
    83. sbwColor_dictText: '',
    84. sbwPrice: '',
    85. sbwNum: '',
    86. sbwFreightPrice: '',
    87. sbwFreight: '',
    88. sbwTransporter_dictText: '',
    89. sbwTotalPrice: '',
    90. sbwStockyard_dictText: '',
    91. sbwPic: '',
    92. sbwFile: '',
    93. sbwRemake: ''
    94. },
    95. }
    96. },
    97. onLoad: function(options) {
    98. this.getOrderDetail()
    99. },
    100. methods: {
    101. // 接受数据
    102. async getOrderDetail() {
    103. let that = this
    104. let params = {
    105. id: this.id
    106. }
    107. console.log(params)
    108. //return
    109. await this.$http.get('/block/smsBlockWarehousing/list', {
    110. params: params
    111. }).then(res => {
    112. console.log("get RES")
    113. console.log(res.data.result.records[0], '马甲的喇嘛是的')
    114. if (res.data.success !== true) {
    115. that.form = res.data.result.records[0]
    116. that.$tip.alert(res.data.message)
    117. } else {
    118. that.form = res.data.result.records[0]
    119. if (that.form.complaintFileString) {
    120. that.fileList = that.form.complaintFileString.split(",")
    121. }
    122. console.log(that.fileList)
    123. }
    124. }).catch(err => {
    125. // that.$tip.alert("网络波动,请重试!")
    126. console.log(err)
    127. })
    128. },
    129. }
    130. }
    131. </script>

    三.图标

    1. <template>
    2. <view>
    3. <cu-custom bgColor="bg-gradual-blue" :isBack="true">
    4. <block slot="content">出库统计图</block>
    5. </cu-custom>
    6. <view>
    7. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button" activeColor="#3a82f8"></uni-segmented-control>
    8. </view>
    9. <view class="charts-box">
    10. <qiun-data-charts
    11. type="pie"
    12. :opts="opts"
    13. :chartData="chartData"
    14. />
    15. <qiun-data-charts
    16. type="mount"
    17. :opts="opt"
    18. :chartData="chartData"
    19. />
    20. </view>
    21. </view>
    22. </template>
    23. <script>
    24. import { forEach } from '../../common/luch-request/utils';
    25. export default {
    26. data() {
    27. return {
    28. items: ['日', '月', '年'],
    29. current: 0,
    30. chartData: {},
    31. //您可以通过修改 config-ucharts.js 文件中下标为 ['pie'] 的节点来配置全局默认参数,如都是默认参数,此处可以不传 opts 。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式,达到页面简洁的需求。
    32. // 饼图
    33. opts: {
    34. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
    35. // padding: [15,5,5,5],
    36. // enableScroll: false,
    37. // legend: {
    38. // show:true,
    39. // lineHeight:20
    40. // },
    41. // extra: {
    42. // pie: {
    43. // activeOpacity: 0.5,
    44. // activeRadius: 10,
    45. // offsetAngle: 0,
    46. // labelWidth: 15,
    47. // border: true,
    48. // borderWidth: 3,
    49. // borderColor: "#FFFFFF"
    50. // }
    51. // }
    52. },
    53. // 条形图
    54. opt: {
    55. color: ["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],
    56. // padding: [15,10,0,5],
    57. // enableScroll: false,
    58. // legend: {
    59. // show:false,
    60. // },
    61. // xAxis: {
    62. // disableGrid: true,
    63. // rotateLabel:true,
    64. // rotateAngle:"45",
    65. // },
    66. // yAxis: {
    67. // data: [
    68. // {
    69. // min: 0
    70. // }
    71. // ]
    72. // },
    73. // extra: {
    74. // mount: {
    75. // type: "bar",
    76. // widthRatio: 0.3,
    77. // borderWidth: 0,
    78. // barBorderRadius: [
    79. // 50,
    80. // 50,
    81. // 50,
    82. // 50
    83. // ],
    84. // linearType: "custom"
    85. // }
    86. // }
    87. }
    88. };
    89. },
    90. mounted() {
    91. var today = new Date(); //
    92. var yesterday = new Date(today.getTime()); //
    93. this.getServerData(yesterday.getFullYear() + "-" + (yesterday.getMonth() + 1) + "-" + yesterday.getDate(),'0') //
    94. },
    95. methods: {
    96. // 定义方法 和值 (item,type)
    97. async getServerData(item,type) {
    98. let that = this
    99. let params = {
    100. item: item, //自己定义的值 和后端的值要对应 问后端
    101. type: type
    102. }
    103. // 请求数据 携带 params
    104. await that.$http.get('/totalView/totalView/PieChuKu',{params: params}).then(res => {
    105. // 计算总值 reduce 累加
    106. // 在括号内的箭头函数(acc, item) => acc + item.value是reduce方法所接受的函数。这个箭头函数接收两个参数,acc表示累加器(accumulator),item表示当前正在处理的数组元素。箭头函数的功能是将累加器acc和当前元素的value属性相加,并返回相加的结果。
    107. //最后的, 0表示reduce方法的初始值为0。这意味着在开始累加之前,累加器acc的初始值为0
    108. const totalValue = res.data.result.reduce((acc, item) => acc + item.value, 0);
    109. // console.log(totalValue,'asasasasa')
    110. // 计算占比并更新数组
    111. // console.log(res.data.result,'dadsada')
    112. // 判断数据 要是是0 要么是有数值
    113. // 如果totalValue值 等于0 就循环遍历渲染
    114. if(totalValue==0){
    115. res.data.result.forEach(item => {
    116. item.labelText = '0%'; //强制数值变成0% 不写的话 就平均分成6份 因为有6
    117. });
    118. }
    119. else{
    120. // 如果不是 就截取后两位 拼接上%
    121. res.data.result.forEach(item => {
    122. const percentage = (item.value / totalValue) * 100; //获取的数值× 100
    123. item.labelText = percentage.toFixed(2)+"%"; //然后 拼接上%
    124. });
    125. }
    126. // ress是一个包含series属性的对象。
    127. // series是一个包含一个对象的数组。
    128. // 这个对象包含一个名为data的属性,其值为res.data.result,假设res是一个包含data属性的对象,而data属性包含一个名为result的数组。
    129. let ress = {
    130. series: [
    131. {
    132. data:res.data.result
    133. }
    134. ]
    135. };
    136. this.chartData = JSON.parse(JSON.stringify(ress));
    137. }).catch(err => {
    138. console.log(err,"err")
    139. })
    140. },
    141. onClickItem(e) {
    142. if (this.current != e.currentIndex) {
    143. this.current = e.currentIndex;
    144. if(this.current=="0"){
    145. // var today = new Date(); 创建了一个Date对象,表示当前的日期和时间。它会将当前的日期和时间信息存储在today变量中。
    146. // console.log(today,'sasasasa') 打印出了today的值,以及额外的字符串sasasasa到控制台。这里主要是用来调试和查看today的值。
    147. // var yesterday = new Date(today.getTime()); 创建了另一个Date对象,其时间戳(以毫秒为单位的时间值)与today相同。这意味着yesterday代表的是和today相同的日期和时间。
    148. // this.getServerData(yesterday.getFullYear() + "-" + (yesterday.getMonth() + 1) + "-" + yesterday.getDate(),'2'); 这行代码调用了一个名为getServerData的方法,并传递了两个参数。第一个参数是一个表示日期的字符串,格式为"年-月-日",通过yesterday.getFullYear() + "-" + (yesterday.getMonth() + 1) + "-" + yesterday.getDate()获取。第二个参数是字符串'2'
    149. var today = new Date();
    150. var yesterday = new Date(today.getTime());
    151. this.getServerData(yesterday.getFullYear() + "-" + (yesterday.getMonth() + 1) + "-" + yesterday.getDate(),'0')
    152. }
    153. if(this.current=="1"){
    154. var today = new Date();
    155. var yesterday = new Date(today.getTime());
    156. this.getServerData(yesterday.getFullYear() + "-" + (yesterday.getMonth() + 1) + "-" + yesterday.getDate(),'1');
    157. }
    158. if(this.current=="2"){
    159. var today = new Date(); //显示
    160. console.log(today,'sasasasa')
    161. var yesterday = new Date(today.getTime());
    162. this.getServerData(yesterday.getFullYear() + "-" + (yesterday.getMonth() + 1) + "-" + yesterday.getDate(),'2');
    163. }
    164. }
    165. }
    166. }
    167. };
    168. </script>
    169. <style scoped>
    170. /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
    171. .charts-box {
    172. width: 100%;
    173. height: 230px;
    174. }
    175. </style>

    地址:演示 - uCharts跨平台图表库 

     五,获取后台数据 进行页面渲染

    案例一

    (1)代码展示
    1. <template>
    2. <view>
    3. <cu-custom bgColor="bg-gradual-pink" :isBack="true">
    4. <block slot="content">荒料管理</block>
    5. </cu-custom>
    6. <view class="uni-container">
    7. <uni-table border stripe emptyText="暂无更多数据">
    8. <uni-tr style="background-color:#ebebeb;">
    9. <uni-th width="150" align="center">序号</uni-th>
    10. <uni-th width="150" align="center">入库编号</uni-th>
    11. <uni-th align="center">日期</uni-th>
    12. <uni-th align="center">荒料种类</uni-th>
    13. <uni-th align="center"></uni-th>
    14. <uni-th align="center"></uni-th>
    15. <uni-th align="center"></uni-th>
    16. <uni-th align="center">体积</uni-th>
    17. <uni-th align="center">颜色</uni-th>
    18. <uni-th align="center">价格</uni-th>
    19. <uni-th align="center">数量</uni-th>
    20. <uni-th align="center">运单单价</uni-th>
    21. <uni-th align="center">运费</uni-th>
    22. <uni-th width="204" align="center">运输人</uni-th>
    23. <uni-th width="204" align="center">总价</uni-th>
    24. <uni-th width="204" align="center">料场</uni-th>
    25. <uni-th align="center">操作员</uni-th>
    26. <uni-th align="center">图片</uni-th>
    27. <uni-th align="center">文件</uni-th>
    28. <uni-th align="center">备注</uni-th>
    29. </uni-tr>
    30. <uni-tr v-for="(item, index) in tableData" :key="index">
    31. <uni-td>{{index+1}}</uni-td>
    32. <uni-td>
    33. <view class="name">{{ item.sbwWarehousingNumber}}</view>
    34. </uni-td>
    35. <uni-td align="center">{{ item.sbwWarehousingDate}}</uni-td>
    36. <uni-td align="center">{{ item.sbwName_dictText }}</uni-td>
    37. <uni-td align="center">{{ item.sbwLong }}</uni-td>
    38. <uni-td align="center">{{ item.sbwWidth }}</uni-td>
    39. <uni-td align="center">{{ item.sbwTall }}</uni-td>
    40. <uni-td align="center">{{ item.sbwSbwVolume }}</uni-td>
    41. <uni-td align="center">{{ item.sbwColor_dictText }}</uni-td>
    42. <uni-td align="center">{{ item.sbwPrice }}</uni-td>
    43. <uni-td align="center">{{ item.sbwNum }}</uni-td>
    44. <uni-td align="center">{{ item.sbwFreightPrice }}</uni-td>
    45. <uni-td align="center">{{ item.sbwFreight }}</uni-td>
    46. <uni-td align="center">{{ item.sbwTransporter_dictText }}</uni-td>
    47. <uni-td align="center">{{ item.sbwTotalPrice }}</uni-td>
    48. <uni-td align="center">{{ item.sbwStockyard_dictText }}</uni-td>
    49. <uni-td align="center">{{ item.sbwTransporter_dictText }}</uni-td>
    50. <uni-td align="center">{{ item.sbwPic }}</uni-td>
    51. <uni-td align="center">{{ item.sbwFile }}</uni-td>
    52. <uni-td align="center">{{ item.sbwRemake }}</uni-td>
    53. </uni-tr>
    54. </uni-table>
    55. <p>总数据量{{this.total}}</p>
    56. <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent"
    57. :total="total" @change="change" /></view>
    58. </view>
    59. </view>
    60. </template>
    61. <script>
    62. export default {
    63. data() {
    64. return {
    65. searchVal: '',
    66. tableData: [],
    67. // 每页数据量
    68. pageSize: 10,
    69. // 当前页
    70. pageCurrent: 1,
    71. // 数据总量
    72. total: 0,
    73. }
    74. },
    75. onLoad() {
    76. this.selectedIndexs = []
    77. this.getData(1) //初始化默认第一页
    78. },
    79. methods: {
    80. // 分页触发
    81. change(e) {
    82. // this.selectedIndexs.length = 0
    83. this.getData(e.current) //点击出发 :current="pageCurrent" 当前页
    84. },
    85. // 获取数据
    86. getData(pageCurrent) {
    87. // 定义请求数据 然后通过路径带到后端返回需要的数据
    88. this.pageCurrent = pageCurrent
    89. let pageNo=this.pageCurrent //当前页
    90. let pageSize=this.pageSize //每页数据量
    91. // 路径拼接数据 发送到后端 获取翻页的数据和效果
    92. let url = '/block/smsBlockWarehousing/list?pageNo='+pageNo+"&pageSize="+pageSize;
    93. this.$http.get(url).then(res => {
    94. this.tableData = res.data.result.records
    95. this.total=res.data.result.total; //总数据量
    96. // console.log('结果', res.data.result.records)
    97. })
    98. },
    99. }
    100. }
    101. </script>
    (2)页面展示

    案例二

    (1)代码展示
    1. <template>
    2. <view>
    3. <cu-custom bgColor="bg-gradual-pink" :isBack="true">
    4. <block slot="content">路边石管理</block>
    5. </cu-custom>
    6. <uni-section title="">
    7. <view>
    8. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" />
    9. </view>
    10. <view class="content">
    11. <view v-if="current === 0">
    12. <uni-table border stripe emptyText="暂无更多数据">
    13. <uni-tr style="background-color:#ebebeb;">
    14. <uni-th width="100" align="center">序号</uni-th>
    15. <uni-th width="204" align="center">入库编号</uni-th>
    16. <uni-th align="center" width="204">库存日期</uni-th>
    17. <uni-th width="150" align="center">长(m)</uni-th>
    18. <uni-th width="150" align="center">宽(m)</uni-th>
    19. <uni-th width="150" align="center">高(m)</uni-th>
    20. <uni-th width="150" align="center">数量</uni-th>
    21. <uni-th width="150" align="center">单价</uni-th>
    22. <uni-th width="150" align="center">体积(㎡)</uni-th>
    23. <uni-th width="204" align="center">加工费</uni-th>
    24. <uni-th width="150" align="center">颜色</uni-th>
    25. <uni-th width="150" align="center">机组</uni-th>
    26. <uni-th width="150" align="center">人员</uni-th>
    27. <uni-th width="204" align="center">操作员</uni-th>
    28. <uni-th width="204" align="center">图片</uni-th>
    29. <uni-th width="150" align="center">文件</uni-th>
    30. <uni-th width="204" align="center">备注</uni-th>
    31. </uni-tr>
    32. <uni-tr v-for="(item, index) in tableData" :key="index">
    33. <uni-td>{{index+1}}</uni-td>
    34. <uni-td align="center">{{ item.sskwRkid }}</uni-td>
    35. <uni-td align="center">{{ item.sskwDate }}</uni-td>
    36. <uni-td align="center">{{ item.sskwLong }}</uni-td>
    37. <uni-td align="center">{{ item.sskwWight }}</uni-td>
    38. <uni-td align="center">{{ item.sskwHight }}</uni-td>
    39. <uni-td align="center">{{ item.sskwNum }}</uni-td>
    40. <uni-td align="center">{{ item.sskwPrice }}</uni-td>
    41. <uni-td align="center">{{ item.sskwVolume }}</uni-td>
    42. <uni-td align="center">{{ item.sskwWages }}</uni-td>
    43. <uni-td align="center">{{item.sskwColor_dictText}}</uni-td>
    44. <uni-td align="center">{{item.sskwSet_dictText}}</uni-td>
    45. <uni-td align="center">{{ item.sskwPromed_dictText }}</uni-td>
    46. <uni-td align="center">{{ item.sskwOpuser }}</uni-td>
    47. <uni-td align="center"><img :src="item.sabwPic" /></uni-td>
    48. <uni-td align="center">{{ item.sskwFile }}</uni-td>
    49. <uni-td align="center">{{ item.sskwRemake }}</uni-td>
    50. </uni-tr>
    51. </uni-table>
    52. <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize"
    53. :current="pageCurrent" :total="total" @change="change" /></view>
    54. </view>
    55. <view v-if="current === 1">
    56. <uni-table border stripe emptyText="暂无更多数据">
    57. <uni-tr style="background-color:#ebebeb;">
    58. <uni-th width="100" align="center">序号</uni-th>
    59. <uni-th width="204" align="center">入库编号</uni-th>
    60. <uni-th align="center" width="204">库存日期</uni-th>
    61. <uni-th width="150" align="center">长(m)</uni-th>
    62. <uni-th width="150" align="center">宽(m)</uni-th>
    63. <uni-th width="150" align="center">高(m)</uni-th>
    64. <uni-th width="150" align="center">数量</uni-th>
    65. <uni-th width="150" align="center">单价</uni-th>
    66. <uni-th width="150" align="center">体积(㎡)</uni-th>
    67. <uni-th width="204" align="center">加工费</uni-th>
    68. <uni-th width="150" align="center">颜色</uni-th>
    69. <uni-th width="150" align="center">机组</uni-th>
    70. <uni-th width="150" align="center">人员</uni-th>
    71. <uni-th width="204" align="center">操作员</uni-th>
    72. <uni-th width="150" align="center">加工方式</uni-th>
    73. <uni-th width="204" align="center">图片</uni-th>
    74. <uni-th width="150" align="center">文件</uni-th>
    75. <uni-th width="204" align="center">备注</uni-th>
    76. </uni-tr>
    77. <uni-tr v-for="(item, index) in tableData2" :key="index">
    78. <uni-td>{{index+1}}</uni-td>
    79. <uni-td>
    80. <view class="name">{{ item.skwRkid }}</view>
    81. </uni-td>
    82. <uni-td align="center">{{ item.skwDate }}</uni-td>
    83. <uni-td align="center">{{ item.skwLong }}</uni-td>
    84. <uni-td align="center">{{ item.skwWight}}</uni-td>
    85. <uni-td align="center">{{ item.skwHight }}</uni-td>
    86. <uni-td align="center">{{ item.skwNum }}</uni-td>
    87. <uni-td align="center">{{ item.skwPrice}}</uni-td>
    88. <uni-td align="center">{{ item.skwVolume }}</uni-td>
    89. <uni-td align="center">{{ item.skwWages }}</uni-td>
    90. <uni-td align="center">{{item.skwColor_dictText}}</uni-td>
    91. <uni-td align="center">{{item.skwSet_dictText}}</uni-td>
    92. <uni-td align="center">{{ item.skwPerson_dictText }}</uni-td>
    93. <uni-td align="center">{{ item.skwOpuser }}</uni-td>
    94. <uni-td align="center">{{ item.skwPromed_dictText}}</uni-td>
    95. <uni-td align="center"><img :src="item.skwPic" /></uni-td>
    96. <uni-td align="center">{{ item.skwFile }}</uni-td>
    97. <uni-td align="center">{{ item.skwRemake }}</uni-td>
    98. </uni-tr>
    99. </uni-table>
    100. <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize2"
    101. :current="pageCurrent2" :total="total2" @change="changeChengpin" /></view>
    102. </view>
    103. </view>
    104. </uni-section>
    105. </view>
    106. </template>
    107. <script>
    108. export default {
    109. data() {
    110. return {
    111. tableData: [], //半成品获取数据
    112. tableData2: [], //成品获取数据
    113. // 每页数据量
    114. pageSize: 7,
    115. pageSize2: 7,
    116. // 当前页
    117. pageCurrent: 1,
    118. pageCurrent2: 1,
    119. // 数据总量
    120. total: 0,
    121. total2:0,
    122. loading: false,
    123. current: 0,
    124. current2: 0,
    125. items: ['半成品展示', '成品展示'],
    126. }
    127. },
    128. // 初始值
    129. onLoad() {
    130. // this.getRemote()
    131. this.selectedIndexs = []
    132. this.getData(1)
    133. this.getData2(1)
    134. },
    135. // 方法
    136. methods: {
    137. // 点击切换展示页面
    138. onClickItem(e) {
    139. if (this.current !== e.currentIndex) {
    140. this.current = e.currentIndex
    141. }
    142. },
    143. // 分页触发
    144. change(e) {
    145. // this.$refs.table.clearSelection()
    146. this.selectedIndexs.length = 0
    147. this.getData(e.current) //半成品
    148. },
    149. changeChengpin(e) {
    150. // this.$refs.table.clearSelection()
    151. this.selectedIndexs.length = 0
    152. this.getData2(e.current) //成品
    153. },
    154. // 半成品获取数据
    155. getData(pageCurrent) {
    156. this.loading = true
    157. this.pageCurrent = pageCurrent
    158. let pageNo = this.pageCurrent
    159. let pageSize = this.pageSize
    160. let url = '/sakerb/smsSaKerbWarehousing/list?pageNo=' + pageNo + "&pageSize=" + pageSize;
    161. this.$http.get(url).then(res => {
    162. this.tableData = res.data.result.records
    163. this.total = res.data.result.total;
    164. // console.log('结果', res.data.result.records)
    165. });
    166. },
    167. // 成品获取数据
    168. getData2(pageCurrent2) {
    169. this.loading = true
    170. this.pageCurrent2 = pageCurrent2
    171. let pageNo = this.pageCurrent2
    172. let pageSize = this.pageSize2
    173. let url2 = '/kerb/smsKerbWarehousing/list?pageNo=' + pageNo + "&pageSize=" + pageSize;
    174. this.$http.get(url2).then(res => {
    175. this.tableData2 = res.data.result.records
    176. this.total2 = res.data.result.total;
    177. // console.log('结果', res.data.result.records)
    178. })
    179. }
    180. // 成品伪request请求
    181. }
    182. }
    183. </script>
    (2)页面展示

  • 相关阅读:
    作为一个十年卷王,告诫你们年轻人应该如何才能认清自己的价值
    如何利用快解析实现个人私有云
    算法课作业1
    入局AI手机 苹果公布Apple Intelligence
    compile Python missing or unusable error while cross compiling GDB
    Vue——状态管理库Pinia
    bootstrap-fileinput拦截文件上传处理失败,根据后台返回数据处理
    redis未授权访问漏洞
    如何使用API接口获取商品数据,从申请API接口、使用API接口到实际应用,一一讲解
    全世界 LoRA 训练脚本,联合起来!
  • 原文地址:https://blog.csdn.net/weixin_68266812/article/details/134293000