wechat
ihzero 2023-10-29 18:20:33 +08:00
parent ba46652f9b
commit a442c2ca59
32 changed files with 12650 additions and 14801 deletions

View File

@ -77,6 +77,8 @@
"node-sass": "^6.0.1", "node-sass": "^6.0.1",
"sass-loader": "^13.3.2", "sass-loader": "^13.3.2",
"uview-ui": "^1.8.8", "uview-ui": "^1.8.8",
"video.js": "^8.6.1",
"videojs-contrib-hls": "^5.15.0",
"vue": "^2.6.11", "vue": "^2.6.11",
"vuex": "^3.2.0", "vuex": "^3.2.0",
"vuex-persistedstate": "^4.1.0" "vuex-persistedstate": "^4.1.0"

View File

@ -4,12 +4,13 @@ export default {
onLaunch: function () { onLaunch: function () {
console.log('App Launch') console.log('App Launch')
if (!(store.state.user_access_token && store.state.userInfo['id'])) { if (!store.state.user_access_token) {
// //
uni.redirectTo({ uni.redirectTo({
url: '/pages/login/login', url: '/pages/login/login',
}) })
} else { } else {
this.$store.dispatch('getUserInfo')
// console.log(store.state.user_access_token) // console.log(store.state.user_access_token)
} }
}, },
@ -28,7 +29,8 @@ export default {
<style lang="scss"> <style lang="scss">
@import 'uview-ui/index.scss'; @import 'uview-ui/index.scss';
/*每个页面公共css */ /*每个页面公共css */
body, uni-page-body { body,
uni-page-body {
background-color: #f8f8f8; background-color: #f8f8f8;
} }
@ -647,8 +649,8 @@ body, uni-page-body {
} }
} }
.dropdownClose{ .dropdownClose {
.u-dropdown__content{ .u-dropdown__content {
pointer-events: none; pointer-events: none;
} }
} }

View File

@ -32,6 +32,7 @@
</u-popup> </u-popup>
</template> </template>
<script> <script>
import checkPermission from '@/utils/permission.js'
export default { export default {
props: { props: {
value: { value: {
@ -46,6 +47,14 @@ export default {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
editAuth: {
type: Array,
default: () => [],
},
delAuth: {
type: Array,
default: () => [],
},
}, },
computed: { computed: {
show: { show: {
@ -57,10 +66,10 @@ export default {
}, },
}, },
isEdit() { isEdit() {
return !!this.$listeners.onEdit return !!this.$listeners.onEdit && checkPermission(this.editAuth)
}, },
isDel() { isDel() {
return !!this.$listeners.onDel return !!this.$listeners.onDel && checkPermission(this.delAuth)
}, },
columsList() { columsList() {
const arr = [] const arr = []

View File

@ -0,0 +1,103 @@
<template>
<div class="video-js" ref="videos" style="width: 100%; height: 100%"></div>
</template>
<script>
import videojs from 'video.js'
import 'videojs-contrib-hls'
import 'video.js/dist/video-js.css'
export default {
props: {
url: {
type: String,
default: '',
},
id: {
type: String,
default: 'videoRefI',
},
},
data() {
return {
player: null,
}
},
mounted() {
this.initVideo()
},
beforeDestroy() {
this.player?.dispose()
},
methods: {
initVideo() {
let video = document.createElement('video')
video.id = this.id
video.style = 'width: 100%; height: 100%;'
video.controls = true
video.preload = 'auto'
video.setAttribute('playsinline', true) //IOS
video.setAttribute('webkit-playsinline', true) //baiios 10duzhivideo
video.setAttribute('x5-video-player-type', 'h5') // H5 video西
let source = document.createElement('source')
source.src = this.url
video.appendChild(source)
// return
this.$refs.videos.appendChild(video)
let that = this
let player = videojs(
this.id,
{
playbackRates: [0.7, 1.0, 1.5, 2.0], //
autoDisable: true,
preload: 'none', //auto - meta - none -
language: 'zh-CN',
fluid: true, //
muted: true, //
aspectRatio: '16:9', // 使 - "16:9""4:3"
controls: false, // true,false ,api
autoplay: true, //true, autoplay: "muted", // //,muted:
loop: true, //
screenshot: true,
controlBar: {
volumePanel: {
//
inline: false, // 使
},
timeDivider: true, // 线
durationDisplay: true, //
progressControl: true, //
remainingTimeDisplay: true, //
fullscreenToggle: true, //
pictureInPictureToggle: true, //
},
},
function () {
this.on('error', function (err) {
//
console.log('请求数据时遇到错误', err)
})
this.on('stalled', function (stalled) {
//
console.log('网速失速', stalled)
})
}
)
},
},
}
</script>
<style lang="scss">
// .vjs-loading-spinner {
// .vjs-control-text {
// display: none !important;
// }
// }
.myvideo {
@apply w-full h-full;
video {
@apply w-full h-full;
}
}
</style>

View File

@ -0,0 +1,14 @@
import permission from './permission'
const install = function(Vue) {
Vue.directive('permission', permission)
}
if (window.Vue) {
window['permission'] = permission
Vue.use(install); // eslint-disable-line
}
permission.install = install
export default permission

View File

@ -0,0 +1,30 @@
import store from '@/store'
function checkPermission(el, binding) {
const { value } = binding
const roles = store.getters && (store.getters.userInfo?.permissions_slug ?? [])
if (value && value instanceof Array) {
if (value.length > 0) {
const permissionRoles = value
const hasPermission = roles.some(role => {
return permissionRoles.includes(role)
})
if (!hasPermission) {
el.parentNode && el.parentNode.removeChild(el)
}
}
} else {
throw new Error(`need roles! Like v-permission="['admin','editor']"`)
}
}
export default {
inserted(el, binding) {
checkPermission(el, binding)
},
update(el, binding) {
checkPermission(el, binding)
}
}

View File

@ -13,6 +13,9 @@ Vue.component('ynSelectInputList', ynSelectInputList)
Vue.prototype.$http = http Vue.prototype.$http = http
Vue.prototype.$getFullUrl = getFullUrl Vue.prototype.$getFullUrl = getFullUrl
App.mpType = 'app' App.mpType = 'app'
import permission from '@/directive/permission/index.js'
Vue.directive('auth', permission)

View File

@ -2,7 +2,12 @@
<view> <view>
<Appbar title="基地数据"> <Appbar title="基地数据">
<template #right> <template #right>
<view class="text-white mr-20px" @click="handleCreate"></view> <view
v-auth="['endpoint.agricultural_basic.create']"
class="text-white mr-20px"
@click="handleCreate"
>新增</view
>
</template> </template>
</Appbar> </Appbar>
<u-sticky> <u-sticky>
@ -61,6 +66,8 @@
:data="currentData" :data="currentData"
@onEdit="handleEdit" @onEdit="handleEdit"
@onDel="handleDel" @onDel="handleDel"
:editAuth="['endpoint.agricultural_basic.edit']"
:delAuth="['endpoint.agricultural_basic.destroy']"
></BaseTablePopup> ></BaseTablePopup>
<!-- 编辑 --> <!-- 编辑 -->
<cuPopup v-model="formShow" :title="currentData ? '编辑基地' : '新增基地'"> <cuPopup v-model="formShow" :title="currentData ? '编辑基地' : '新增基地'">
@ -80,6 +87,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue' import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue' import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue' import BasicsEdit from './components/basics-edit.vue'
import checkPermission from '@/utils/permission.js'
const baseTableColums = [ const baseTableColums = [
{ {
title: '基地名称', title: '基地名称',
@ -164,22 +172,7 @@ export default {
}, },
}, },
dataList: [], dataList: [],
options: [
{
text: '编辑',
opt: 'edit',
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
style: {
backgroundColor: '#dd524d',
},
},
],
formShow: false, formShow: false,
baseShow: false, baseShow: false,
searchFormSchema: [ searchFormSchema: [
@ -211,6 +204,30 @@ export default {
], ],
} }
}, },
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.agricultural_basic.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.agricultural_basic.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) =>
checkPermission(e.permission)
)
},
},
methods: { methods: {
handleSubmit(e) { handleSubmit(e) {
this.filterParmas = e this.filterParmas = e

View File

@ -3,9 +3,9 @@
<view class="bg-white p-30rpx"> <view class="bg-white p-30rpx">
<view class="flex justify-between items-center"> <view class="flex justify-between items-center">
<view class="text-32rpx">全市数据统计</view> <view class="text-32rpx">全市数据统计</view>
<u-button size="mini" @click="cityEditShow = true">编辑</u-button> <u-button size="mini" v-auth="['endpoint.town_street.base_statistics_edit']" @click="cityEditShow = true"></u-button>
</view> </view>
<view class="grid grid-cols-2 mt-20rpx"> <view class="grid grid-cols-2 mt-20rpx" v-auth="['endpoint.town_street.base_statistics']">
<CountItem <CountItem
v-for="(item, i) in showCityList" v-for="(item, i) in showCityList"
:key="i" :key="i"

View File

@ -2,7 +2,7 @@
<view> <view>
<Appbar title="基地农作物"> <Appbar title="基地农作物">
<template #right> <template #right>
<view class="text-white mr-20px" @click="handleCreate"></view> <view v-auth="['endpoint.crops.create']" class="text-white mr-20px" @click="handleCreate"></view>
</template> </template>
</Appbar> </Appbar>
<u-sticky> <u-sticky>
@ -52,17 +52,9 @@
:data="currentData" :data="currentData"
@onEdit="handleEdit" @onEdit="handleEdit"
@onDel="handleDel" @onDel="handleDel"
:editAuth="['endpoint.crops.edit']"
:delAuth="['endpoint.crops.destroy']"
> >
<!-- <template #extends="{ data }">
<view
class="flex justify-between w-full px-30rpx py-20rpx"
v-for="(item, i) in data.value"
:key="i"
>
<view> 名称{{ item.name }}</view>
<view> 单位{{ item.unit }}</view>
</view>
</template> -->
</BaseTablePopup> </BaseTablePopup>
<!-- 编辑 --> <!-- 编辑 -->
<cuPopup v-model="formShow" :title="currentData ? '编辑农作物' : '新增农作物'"> <cuPopup v-model="formShow" :title="currentData ? '编辑农作物' : '新增农作物'">
@ -83,6 +75,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue' import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue' import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue' import BasicsEdit from './components/basics-edit.vue'
import checkPermission from '@/utils/permission.js'
const baseTableColums = [ const baseTableColums = [
{ {
title: '名称', title: '名称',
@ -128,22 +121,6 @@ export default {
}, },
}, },
dataList: [], dataList: [],
options: [
{
text: '编辑',
opt: 'edit',
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
style: {
backgroundColor: '#dd524d',
},
},
],
formShow: false, formShow: false,
baseShow: false, baseShow: false,
searchFormSchema: [ searchFormSchema: [
@ -158,6 +135,28 @@ export default {
], ],
} }
}, },
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.crops.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.crops.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
},
methods: { methods: {
handleSubmit(e) { handleSubmit(e) {
this.filterParmas = e this.filterParmas = e

View File

@ -2,7 +2,12 @@
<view> <view>
<Appbar title="城镇农作物"> <Appbar title="城镇农作物">
<template #right> <template #right>
<view class="text-white mr-20px" @click="handleCreate"></view> <view
v-auth="['endpoint.town_crops.create']"
class="text-white mr-20px"
@click="handleCreate"
>新增</view
>
</template> </template>
</Appbar> </Appbar>
<u-sticky> <u-sticky>
@ -52,20 +57,15 @@
:data="currentData" :data="currentData"
@onEdit="handleEdit" @onEdit="handleEdit"
@onDel="handleDel" @onDel="handleDel"
:editAuth="['endpoint.town_crops.edit']"
:delAuth="['endpoint.town_crops.destroy']"
> >
<!-- <template #extends="{ data }">
<view
class="flex justify-between w-full px-30rpx py-20rpx"
v-for="(item, i) in data.value"
:key="i"
>
<view> 名称{{ item.name }}</view>
<view> 单位{{ item.unit }}</view>
</view>
</template> -->
</BaseTablePopup> </BaseTablePopup>
<!-- 编辑 --> <!-- 编辑 -->
<cuPopup v-model="formShow" :title="currentData ? '编辑农作物' : '新增农作物'"> <cuPopup
v-model="formShow"
:title="currentData ? '编辑农作物' : '新增农作物'"
>
<BasicsEdit <BasicsEdit
@cancel="formShow = false" @cancel="formShow = false"
@confirm="handleEditConfirm" @confirm="handleEditConfirm"
@ -82,6 +82,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue' import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue' import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue' import BasicsEdit from './components/basics-edit.vue'
import checkPermission from '@/utils/permission.js'
const baseTableColums = [ const baseTableColums = [
{ {
title: '名称', title: '名称',
@ -127,22 +128,6 @@ export default {
}, },
}, },
dataList: [], dataList: [],
options: [
{
text: '编辑',
opt: 'edit',
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
style: {
backgroundColor: '#dd524d',
},
},
],
formShow: false, formShow: false,
baseShow: false, baseShow: false,
searchFormSchema: [ searchFormSchema: [
@ -157,6 +142,28 @@ export default {
], ],
} }
}, },
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.town_crops.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.town_crops.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
},
methods: { methods: {
handleSubmit(e) { handleSubmit(e) {
this.filterParmas = e this.filterParmas = e

View File

@ -3,7 +3,7 @@
<u-navbar title="设备管理" :background="background" :custom-back="goback" <u-navbar title="设备管理" :background="background" :custom-back="goback"
:title-color="titleColor" :back-icon-color="titleColor"> :title-color="titleColor" :back-icon-color="titleColor">
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view v-auth="['endpoint.device.create']" class="custom_btn add_btn" @click="addBtn()"></view>
</view> </view>
</u-navbar> </u-navbar>
<view class="secreen-section"> <view class="secreen-section">
@ -172,8 +172,8 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view class="btn_del" v-auth="['endpoint.device.destroy']" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> <view class="btn_edit" v-auth="['endpoint.device.edit']" @click="editInfoId(formInfo.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
@ -288,6 +288,7 @@
<script> <script>
import {navigateBack} from '@/com/utils.js' import {navigateBack} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default { export default {
data() { data() {
return { return {
@ -299,20 +300,6 @@
page:1, page:1,
list:[], list:[],
loading:'loadmore', loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false, popupShow:false,
cindex:-1,// cindex:-1,//
editShow:false, editShow:false,
@ -433,7 +420,28 @@
} }
}; };
}, },
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.device.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.device.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
},
onLoad() { onLoad() {
this.queryDataList(); this.queryDataList();
this.getDeviceTypes(); this.getDeviceTypes();

View File

@ -1,9 +1,19 @@
<template> <template>
<view class="bg-page"> <view class="bg-page">
<u-navbar title="稻虾流向" :background="background" :custom-back="goback" <u-navbar
:title-color="titleColor" :back-icon-color="titleColor"> title="稻虾流向"
:background="background"
:custom-back="goback"
:title-color="titleColor"
:back-icon-color="titleColor"
>
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view
v-auth="['endpoint.rice_shrimp_flows.create']"
class="custom_btn add_btn"
@click="addBtn()"
>新增</view
>
</view> </view>
</u-navbar> </u-navbar>
<view class="secreen-section"> <view class="secreen-section">
@ -14,98 +24,120 @@
</view> </view>
</view> </view>
<view class="content-box u-padding-25"> <view class="content-box u-padding-25">
<u-swipe-action class="tb_swipe_list" <u-swipe-action
class="tb_swipe_list"
v-for="(item, index) in list" v-for="(item, index) in list"
:show="item.show" :index="index" :key="item.id" :show="item.show"
:index="index"
:key="item.id"
@click="click" @click="click"
@open="open" @open="open"
:options="options" :options="options"
> >
<view class="tb_body" @click="showInfo(index)"> <view class="tb_body" @click="showInfo(index)">
<view class="row_box"> <view class="row_box">
<view class="text">年份{{ item.year }}</view> <view class="text">年份{{ item.year }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">季度{{item.quarter|quartername}}</view> <view class="text">季度{{ item.quarter | quartername }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">地区{{ item.area }}</view> <view class="text">地区{{ item.area }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">销量{{ item.sales }}{{item.unit}}</view> <view class="text">销量{{ item.sales }}{{ item.unit }}</view>
</view> </view>
<!-- <view class="row_box"> <!-- <view class="row_box">
<view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view> <view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view>
</view> --> </view> -->
</view> </view>
</u-swipe-action> </u-swipe-action>
<u-loadmore :status="loading" margin-top="60"/> <u-loadmore :status="loading" margin-top="60" />
</view> </view>
<!-- 编辑 --> <!-- 编辑 -->
<u-popup v-model="editShow" border-radius="28" width="92%" height="60%" <u-popup
mode="center" :closeable="true" :mask-close-able="false" z-index="910"> v-model="editShow"
border-radius="28"
width="92%"
height="60%"
mode="center"
:closeable="true"
:mask-close-able="false"
z-index="910"
>
<view class="popup-form-ubox"> <view class="popup-form-ubox">
<view class="top_box"> <view class="top_box">
<view class="title" v-if="setInfo.id"></view> <view class="title" v-if="setInfo.id"></view>
<view class="title" v-else></view> <view class="title" v-else></view>
</view> </view>
<scroll-view class="scroll-y" scroll-y="true"> <scroll-view class="scroll-y" scroll-y="true">
<view class="form_edit" style="padding-left: 50rpx;"> <view class="form_edit" style="padding-left: 50rpx">
<u-form> <u-form>
<u-form-item label="ID" label-width="140" v-if="setInfo.id"> <u-form-item label="ID" label-width="140" v-if="setInfo.id">
<view class="input_box bg_colorf8 pdlr12"> <view class="input_box bg_colorf8 pdlr12">
<u-input v-model="setInfo.id" :disabled="true" /> <u-input v-model="setInfo.id" :disabled="true" />
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="年份" label-width="140" :required='true'> <u-form-item label="年份" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<view class="u-select-list" @click="selectFn1()"> <view class="u-select-list" @click="selectFn1()">
<view class="value u-line-2" <view class="value u-line-2" v-if="setInfo.year">{{
v-if="setInfo.year">{{setInfo.year}}</view> setInfo.year
}}</view>
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
<view class="right"> <view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon
name="arrow-right"
color="#999"
size="28"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="季度" label-width="140" :required='true'> <u-form-item label="季度" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<view class="u-select-list" @click="selectFn2()"> <view class="u-select-list" @click="selectFn2()">
<view class="value u-line-2" <view class="value u-line-2" v-if="setInfo.quarter_name">{{
v-if="setInfo.quarter_name">{{setInfo.quarter_name}}</view> setInfo.quarter_name
}}</view>
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
<view class="right"> <view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon
name="arrow-right"
color="#999"
size="28"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="地区" label-width="140" :required='true'> <u-form-item label="地区" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<u-input v-model="setInfo.area" /> <u-input v-model="setInfo.area" />
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="销量" label-width="140" :required='true'> <u-form-item label="销量" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<u-input v-model="setInfo.sales" type="number"/> <u-input v-model="setInfo.sales" type="number" />
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="单位" label-width="140" :required='true'> <u-form-item label="单位" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<u-input v-model="setInfo.unit" /> <u-input v-model="setInfo.unit" />
</view> </view>
</u-form-item> </u-form-item>
</u-form> </u-form>
</view> </view>
</scroll-view> </scroll-view>
<view class="buttom_section"> <view class="buttom_section">
<u-button class="btn" type="default" @click="editShow = false">取消</u-button> <u-button class="btn" type="default" @click="editShow = false"
<u-button class="btn" @click="editInfoBtn()" type="primary">确定</u-button> >取消</u-button
>
<u-button class="btn" @click="editInfoBtn()" type="primary"
>确定</u-button
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
@ -113,36 +145,47 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> v-auth="['endpoint.rice_shrimp_flows.destroy']"
class="btn_del"
@click="deleteInfoId(formInfo.id)"
>删除</view
>
<view
v-auth="['endpoint.rice_shrimp_flows.edit']"
class="btn_edit"
@click="editInfoId(formInfo.id)"
>编辑</view
>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">年份</view> <view class="label_t">年份</view>
<view class="flex-1">{{formInfo.year}}</view> <view class="flex-1">{{ formInfo.year }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">季度</view> <view class="label_t">季度</view>
<view class="flex-1">{{formInfo.quarter|quartername}}</view> <view class="flex-1">{{ formInfo.quarter | quartername }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">地区</view> <view class="label_t">地区</view>
<view class="flex-1">{{formInfo.area}}</view> <view class="flex-1">{{ formInfo.area }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">销量</view> <view class="label_t">销量</view>
<view class="flex-1">{{ formInfo.sales }}{{formInfo.unit}}</view> <view class="flex-1">{{ formInfo.sales }}{{ formInfo.unit }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">创建人</view> <view class="label_t">创建人</view>
<view class="flex-1">{{ formInfo.created_by?formInfo.created_by.name:'-' }}</view> <view class="flex-1">{{
formInfo.created_by ? formInfo.created_by.name : '-'
}}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">更新时间</view> <view class="label_t">更新时间</view>
<view class="flex-1">{{ formInfo.updated_at|timeFormat}}</view> <view class="flex-1">{{ formInfo.updated_at | timeFormat }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -155,303 +198,341 @@
<view class="row_ul u-padding-right-20 u-padding-top-40"> <view class="row_ul u-padding-right-20 u-padding-top-40">
<view class="row_list u-flex"> <view class="row_list u-flex">
<view class="label_tit small">年份</view> <view class="label_tit small">年份</view>
<yn-select-input-list :value="queryCond.year" <yn-select-input-list
rightIcon="calendar" placeholder="请选择年份" :value="queryCond.year"
@click="selectFn1('q')"></yn-select-input-list> rightIcon="calendar"
placeholder="请选择年份"
@click="selectFn1('q')"
></yn-select-input-list>
</view> </view>
<view class="row_list u-flex"> <view class="row_list u-flex">
<view class="label_tit small">季度</view> <view class="label_tit small">季度</view>
<yn-select-input-list :value="queryCond.quarter_name" placeholder="请选择季度" <yn-select-input-list
@click="selectFn2('q')"></yn-select-input-list> :value="queryCond.quarter_name"
placeholder="请选择季度"
@click="selectFn2('q')"
></yn-select-input-list>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view class="buttom_section u-padding-top-40"> <view class="buttom_section u-padding-top-40">
<u-button class="btn small_btn" type="default" @click="resetQuery()"></u-button> <u-button class="btn small_btn" type="default" @click="resetQuery()"
<u-button class="btn small_btn" @click="queryBtn()" type="primary">查询</u-button> >重置</u-button
>
<u-button class="btn small_btn" @click="queryBtn()" type="primary"
>查询</u-button
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
<u-picker mode="time" v-model="selectShow1" <u-picker
:params="timeParams" :default-time="selectValue1" mode="time"
@confirm="uselectConfirm1"></u-picker> v-model="selectShow1"
<u-select v-model="selectShow2" :list="quarterlist" :params="timeParams"
:default-value="selectValue2" mode="single-column" :default-time="selectValue1"
@confirm="uselectConfirm2"></u-select> @confirm="uselectConfirm1"
></u-picker>
<u-select
v-model="selectShow2"
:list="quarterlist"
:default-value="selectValue2"
mode="single-column"
@confirm="uselectConfirm2"
></u-select>
</view> </view>
</template> </template>
<script> <script>
import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js' import {
export default { formatDate,
showLoading,
hideLoading,
navigateBack,
} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default {
data() { data() {
return { return {
background: { background: {
backgroundColor:'#2a7dc9', backgroundColor: '#2a7dc9',
}, },
titleColor:"#ffffff", titleColor: '#ffffff',
per_page:15, per_page: 15,
page:1, page: 1,
list:[], list: [],
loading:'loadmore', loading: 'loadmore',
options: [
{ popupShow: false,
text: '编辑', cindex: -1, //
style: { editShow: false,
backgroundColor: '#007aff' formInfo: {},
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false,
cindex:-1,//
editShow:false,
formInfo:{},
timeParams: { timeParams: {
year: true, year: true,
month: false, month: false,
day: false, day: false,
hour: false, hour: false,
minute: false, minute: false,
second: false second: false,
}, },
screenShow:false, screenShow: false,
isqueryselect:false, isqueryselect: false,
setInfo:{ setInfo: {
id:'', id: '',
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
area:'', area: '',
sales:'', sales: '',
unit:'' unit: '',
}, },
editShow:false, editShow: false,
queryCond:{ queryCond: {
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
}, },
selectShow1:false, selectShow1: false,
selectShow2:false, selectShow2: false,
selectValue1:'', selectValue1: '',
selectValue2:[0], selectValue2: [0],
quarterlist:[ quarterlist: [
{ {
label:'第一季度', label: '第一季度',
value:1, value: 1,
}, },
{ {
label:'第二季度', label: '第二季度',
value:2, value: 2,
}, },
{ {
label:'第三季度', label: '第三季度',
value:3, value: 3,
}, },
{ {
label:'第四季度', label: '第四季度',
value:4, value: 4,
},
],
} }
]
};
}, },
filters:{ computed: {
quartername(val){ options() {
let keys = {1:'第一季度',2:'第二季度',3:'第三季度',4:'第四季度'} return [
let name = keys[val]?keys[val]:val {
return name; text: '编辑',
}, opt: 'edit',
timeFormat(val){ permission: ['endpoint.rice_shrimp_flows.edit'],
return formatDate(val*1000, 'yyyy-MM-dd hh:mm'); style: {
backgroundColor: '#007aff',
}, },
}, },
onLoad(){ {
this.queryDataList(); text: '删除',
opt: 'delete',
permission: ['endpoint.rice_shrimp_flows.destroy'],
style: {
backgroundColor: '#dd524d',
}, },
methods:{
addBtn(){
this.setInfoKeys('add');
this.editShow = true;
}, },
selectFn1(type){ ].filter((e) => checkPermission(e.permission))
this.isqueryselect = false; },
let year = this.setInfo.year; },
if(type=='q'){ filters: {
this.isqueryselect = true; quartername(val) {
this.selectShow1 = true; let keys = { 1: '第一季度', 2: '第二季度', 3: '第三季度', 4: '第四季度' }
year = this.queryCond.year; let name = keys[val] ? keys[val] : val
return name
},
timeFormat(val) {
return formatDate(val * 1000, 'yyyy-MM-dd hh:mm')
},
},
onLoad() {
this.queryDataList()
},
methods: {
addBtn() {
this.setInfoKeys('add')
this.editShow = true
},
selectFn1(type) {
this.isqueryselect = false
let year = this.setInfo.year
if (type == 'q') {
this.isqueryselect = true
this.selectShow1 = true
year = this.queryCond.year
} }
if(year){ if (year) {
this.selectValue1 = `${year}-01-01 00:00:01`; this.selectValue1 = `${year}-01-01 00:00:01`
} }
console.log(this.selectValue1) console.log(this.selectValue1)
this.selectShow1 = true; this.selectShow1 = true
}, },
selectFn2(type){ selectFn2(type) {
this.isqueryselect = false; this.isqueryselect = false
let quarter = this.setInfo.quarter; let quarter = this.setInfo.quarter
if(type=='q'){ if (type == 'q') {
this.isqueryselect = true; this.isqueryselect = true
quarter = this.queryCond.quarter; quarter = this.queryCond.quarter
} }
for(let [index,item] of this.quarterlist.entries()){ for (let [index, item] of this.quarterlist.entries()) {
if(quarter==item.value){ if (quarter == item.value) {
this.selectValue2 = [index]; this.selectValue2 = [index]
break; break
} }
} }
this.selectShow2 = true; this.selectShow2 = true
}, },
resetQuery(){ resetQuery() {
this.queryCond = { this.queryCond = {
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
} }
}, },
queryBtn(){ queryBtn() {
this.list = []; this.list = []
this.queryDataList(true); this.queryDataList(true)
this.screenShow = false; this.screenShow = false
}, },
uselectConfirm1(e){ uselectConfirm1(e) {
if(this.isqueryselect){ if (this.isqueryselect) {
console.log(e); console.log(e)
this.queryCond.year = e.year; this.queryCond.year = e.year
}else{ } else {
this.setInfo.year = e.year; this.setInfo.year = e.year
} }
}, },
uselectConfirm2(e){ uselectConfirm2(e) {
if(this.isqueryselect){ if (this.isqueryselect) {
console.log(e); console.log(e)
this.queryCond.quarter = e[0].value; this.queryCond.quarter = e[0].value
this.queryCond.quarter_name = e[0].label; this.queryCond.quarter_name = e[0].label
}else{ } else {
this.setInfo.quarter = e[0].value; this.setInfo.quarter = e[0].value
this.setInfo.quarter_name = e[0].label; this.setInfo.quarter_name = e[0].label
} }
}, },
screenShowFn(){ screenShowFn() {
this.screenShow = true; this.screenShow = true
}, },
showInfo(index){ showInfo(index) {
this.cindex = index; this.cindex = index
let _id = this.list[index].id; let _id = this.list[index].id
this.queryInfo(_id); this.queryInfo(_id)
this.formInfo = this.list[index]; this.formInfo = this.list[index]
this.popupShow = true; this.popupShow = true
}, },
open(index){ open(index) {
this.list[index].show = true; this.list[index].show = true
}, },
click(index, index1) { click(index, index1) {
console.log(index,index1,this.list[index]) console.log(index, index1, this.list[index])
if(index1 == 1) { if (index1 == 1) {
this.cindex = index; this.cindex = index
let _id = this.list[index].id; let _id = this.list[index].id
this.deleteInfoId(_id); this.deleteInfoId(_id)
} else {// } else {
let _id = this.list[index].id; //
this.formInfo = this.list[index]; let _id = this.list[index].id
this.queryInfo(_id); this.formInfo = this.list[index]
this.setInfoKeys(); this.queryInfo(_id)
this.editShow = true; this.setInfoKeys()
this.list[index].show = false; this.editShow = true
this.list[index].show = false
} }
}, },
queryDataList(refresh){ queryDataList(refresh) {
if(refresh){ if (refresh) {
this.loading = 'loadmore'; this.loading = 'loadmore'
this.page = 1; this.page = 1
} }
if(this.loading=='nomore'){// if (this.loading == 'nomore') {
return false; //
return false
} }
let params = { let params = {
per_page:this.per_page, per_page: this.per_page,
page: this.page ++, page: this.page++,
_t: new Date().getTime() _t: new Date().getTime(),
} }
for(let k in this.queryCond){ for (let k in this.queryCond) {
if(this.queryCond[k]||this.queryCond[k]=='0'){ if (this.queryCond[k] || this.queryCond[k] == '0') {
params[k] = this.queryCond[k]; params[k] = this.queryCond[k]
} }
} }
this.loading = 'loading'; this.loading = 'loading'
this.$http.get('/api/rice-shrimp-flows',{params:params}).then(({data})=>{ this.$http
.get('/api/rice-shrimp-flows', { params: params })
.then(({ data }) => {
console.log(data) console.log(data)
this.screenShow = false; this.screenShow = false
if(refresh){ if (refresh) {
this.list = []; this.list = []
} }
this.loading = 'loadmore'; this.loading = 'loadmore'
if(data.code==200){ if (data.code == 200) {
let _list = data.data|| []; let _list = data.data || []
for(let item of _list){ for (let item of _list) {
item.show = false; item.show = false
} }
this.list = this.list.concat(_list); this.list = this.list.concat(_list)
console.log(this.list); console.log(this.list)
if(this.list.length>= data.meta.total){ if (this.list.length >= data.meta.total) {
this.loading ='nomore'; this.loading = 'nomore'
} }
} }
}).catch(()=>{ })
this.loading = 'loadmore'; .catch(() => {
this.screenShow = false; this.loading = 'loadmore'
this.screenShow = false
}) })
}, },
// //
editInfoBtn(){ editInfoBtn() {
if(!this.valiFormRule()){ if (!this.valiFormRule()) {
return false; return false
} }
let params = {} let params = {}
params = this.setInfo; params = this.setInfo
showLoading('请稍等...'); showLoading('请稍等...')
if(params['id']){ if (params['id']) {
this.$http.put(`/api/rice-shrimp-flows/${params['id']}`,params).then(({data})=>{ this.$http
hideLoading(); .put(`/api/rice-shrimp-flows/${params['id']}`, params)
if(data.code==200){ .then(({ data }) => {
hideLoading()
this.editShow = false; if (data.code == 200) {
this.queryDataList(true); this.editShow = false
this.queryDataList(true)
} }
uni.showToast({ title: data.message, icon: 'none' }); uni.showToast({ title: data.message, icon: 'none' })
}).catch(()=>{
hideLoading();
}) })
}else{ .catch(() => {
delete params['id']; hideLoading()
this.$http.post(`/api/rice-shrimp-flows`,params).then(({data})=>{ })
hideLoading(); } else {
if(data.code==200){ delete params['id']
this.queryDataList(true); this.$http
this.editShow = false; .post(`/api/rice-shrimp-flows`, params)
uni.showToast({ title: data.message, icon: 'none' }); .then(({ data }) => {
}else{ hideLoading()
uni.showToast({ title: data.message, icon: 'none' }); if (data.code == 200) {
this.queryDataList(true)
this.editShow = false
uni.showToast({ title: data.message, icon: 'none' })
} else {
uni.showToast({ title: data.message, icon: 'none' })
} }
}).catch(()=>{ })
hideLoading(); .catch(() => {
hideLoading()
}) })
} }
}, },
queryInfo(id){ queryInfo(id) {
// this.$http.get(`/api/rice-shrimp-flows/${id}`).then(({data})=>{ // this.$http.get(`/api/rice-shrimp-flows/${id}`).then(({data})=>{
// console.log(data,'queryInfo===') // console.log(data,'queryInfo===')
// if(data.code==200){ // if(data.code==200){
@ -459,114 +540,112 @@
// this.setInfoKeys(); // this.setInfoKeys();
// } // }
// }).catch((err)=>{ // }).catch((err)=>{
// }) // })
}, },
editInfoId(id){ editInfoId(id) {
// this.queryInfo(id); // this.queryInfo(id);
this.setInfoKeys(); this.setInfoKeys()
this.editShow = true; this.editShow = true
this.popupShow = false; this.popupShow = false
}, },
//deleteInfoId //deleteInfoId
deleteInfoId(id){ deleteInfoId(id) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '是否确定删除?', content: '是否确定删除?',
success: (res)=> { success: (res) => {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定'); console.log('用户点击确定')
showLoading('请稍等...'); showLoading('请稍等...')
this.$http.delete(`/api/rice-shrimp-flows/${id}`).then(({data})=>{ this.$http
hideLoading(); .delete(`/api/rice-shrimp-flows/${id}`)
if(data.code==200){ .then(({ data }) => {
this.formInfo = {};// hideLoading()
this.popupShow = false; if (data.code == 200) {
this.list.splice(this.cindex,1); this.formInfo = {} //
this.popupShow = false
this.list.splice(this.cindex, 1)
// this.queryDataList(true); // this.queryDataList(true);
} }
uni.showToast({ title: data.message, icon: 'none' }); uni.showToast({ title: data.message, icon: 'none' })
}).catch(()=>{ })
hideLoading(); .catch(() => {
hideLoading()
}) })
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消'); console.log('用户点击取消')
} }
}
});
}, },
setInfoKeys(type){ })
},
setInfoKeys(type) {
let info = { let info = {
id:'', id: '',
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
area:'', area: '',
sales:'', sales: '',
unit:'' unit: '',
} }
if(type=='add'){ if (type == 'add') {
this.setInfo = info; this.setInfo = info
}else{ } else {
let {id,year,quarter,area,sales,unit} = this.formInfo; let { id, year, quarter, area, sales, unit } = this.formInfo
try{ try {
for(let k in info){ for (let k in info) {
info[k] = this.formInfo[k]; info[k] = this.formInfo[k]
} }
for(let item of this.quarterlist){ for (let item of this.quarterlist) {
if(quarter == item.value){ if (quarter == item.value) {
info.quarter_name = item.label; info.quarter_name = item.label
break; break
} }
} }
this.setInfo = info; this.setInfo = info
} catch (e) {
}catch(e){
//TODO handle the exception //TODO handle the exception
uni.showToast({ title: '数据错误', icon: 'none' }) uni.showToast({ title: '数据错误', icon: 'none' })
} }
} }
}, },
valiFormRule(){ valiFormRule() {
let {id,year,quarter,area,sales,unit} = this.setInfo; let { id, year, quarter, area, sales, unit } = this.setInfo
if(year==''){ if (year == '') {
uni.showToast({ title: '年份不能为空', icon: 'none' }); uni.showToast({ title: '年份不能为空', icon: 'none' })
return false; return false
} }
if(quarter==''){ if (quarter == '') {
uni.showToast({ title: '季度不能为空', icon: 'none' }); uni.showToast({ title: '季度不能为空', icon: 'none' })
return false; return false
} }
if(area==''){ if (area == '') {
uni.showToast({ title: '地区不能为空', icon: 'none' }); uni.showToast({ title: '地区不能为空', icon: 'none' })
return false; return false
} }
if(sales==''){ if (sales == '') {
uni.showToast({ title: '销量不能为空', icon: 'none' }); uni.showToast({ title: '销量不能为空', icon: 'none' })
return false; return false
} }
if(unit==''){ if (unit == '') {
uni.showToast({ title: '单位不能为空', icon: 'none' }); uni.showToast({ title: '单位不能为空', icon: 'none' })
return false; return false
} }
return true; return true
}, },
goback(){ goback() {
navigateBack() navigateBack()
} },
}, },
// //
onReachBottom() { onReachBottom() {
if(this.loading=='loadmore'){ if (this.loading == 'loadmore') {
this.queryDataList(); this.queryDataList()
} }
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss"></style>
</style>

View File

@ -3,7 +3,7 @@
<u-navbar title="稻虾产业" :background="background" :custom-back="goback" <u-navbar title="稻虾产业" :background="background" :custom-back="goback"
:title-color="titleColor" :back-icon-color="titleColor"> :title-color="titleColor" :back-icon-color="titleColor">
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view v-auth="['endpoint.rice_shrimp_industries.create']" class="custom_btn add_btn" @click="addBtn()"></view>
</view> </view>
</u-navbar> </u-navbar>
<view class="secreen-section"> <view class="secreen-section">
@ -125,8 +125,8 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view v-auth="['endpoint.rice_shrimp_industries.destroy']" class="btn_del" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> <view v-auth="['endpoint.rice_shrimp_industries.edit']" class="btn_edit" @click="editInfoId(formInfo.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
@ -195,6 +195,7 @@
<script> <script>
import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js' import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default { export default {
data() { data() {
return { return {
@ -206,20 +207,7 @@
page:1, page:1,
list:[], list:[],
loading:'loadmore', loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false, popupShow:false,
cindex:-1,// cindex:-1,//
editShow:false, editShow:false,
@ -275,6 +263,28 @@
} }
] ]
}; };
},
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.rice_shrimp_industries.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.rice_shrimp_industries.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
}, },
filters:{ filters:{
quartername(val){ quartername(val){

View File

@ -3,7 +3,7 @@
<u-navbar title="大宗物资" :background="background" :custom-back="goback" <u-navbar title="大宗物资" :background="background" :custom-back="goback"
:title-color="titleColor" :back-icon-color="titleColor"> :title-color="titleColor" :back-icon-color="titleColor">
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view v-auth="['endpoint.materiels.create']" class="custom_btn add_btn" @click="addBtn()"></view>
</view> </view>
</u-navbar> </u-navbar>
<view class="secreen-section"> <view class="secreen-section">
@ -134,8 +134,8 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view class="btn_del" v-auth="['endpoint.materiels.destroy']" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> <view class="btn_edit" v-auth="['endpoint.materiels.edit']" @click="editInfoId(formInfo.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
@ -225,6 +225,7 @@
<script> <script>
import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js' import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default { export default {
data() { data() {
return { return {
@ -236,20 +237,6 @@
page:1, page:1,
list:[], list:[],
loading:'loadmore', loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false, popupShow:false,
cindex:-1,// cindex:-1,//
editShow:false, editShow:false,
@ -318,6 +305,28 @@
} }
] ]
}; };
},
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.materiels.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.materiels.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
}, },
filters:{ filters:{
quartername(val){ quartername(val){

View File

@ -1,9 +1,19 @@
<template> <template>
<view class="bg-page"> <view class="bg-page">
<u-navbar title="稻虾价格" :background="background" :custom-back="goback" <u-navbar
:title-color="titleColor" :back-icon-color="titleColor"> title="稻虾价格"
:background="background"
:custom-back="goback"
:title-color="titleColor"
:back-icon-color="titleColor"
>
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view
v-auth="['endpoint.rice_shrimp_prices.create']"
class="custom_btn add_btn"
@click="addBtn()"
>新增</view
>
</view> </view>
</u-navbar> </u-navbar>
<view class="secreen-section"> <view class="secreen-section">
@ -14,21 +24,23 @@
</view> </view>
</view> </view>
<view class="content-box u-padding-25"> <view class="content-box u-padding-25">
<u-swipe-action class="tb_swipe_list" <u-swipe-action
class="tb_swipe_list"
v-for="(item, index) in list" v-for="(item, index) in list"
:show="item.show" :index="index" :key="item.id" :show="item.show"
:index="index"
:key="item.id"
@click="click" @click="click"
@open="open" @open="open"
:options="options" :options="options"
> >
<view class="tb_body" @click="showInfo(index)"> <view class="tb_body" @click="showInfo(index)">
<view class="row_box"> <view class="row_box">
<view class="text">年份{{ item.year }}</view> <view class="text">年份{{ item.year }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">季度{{item.quarter|quartername}}</view> <view class="text">季度{{ item.quarter | quartername }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">价格{{ item.price }}</view> <view class="text">价格{{ item.price }}</view>
@ -36,63 +48,83 @@
<!-- <view class="row_box"> <!-- <view class="row_box">
<view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view> <view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view>
</view> --> </view> -->
</view> </view>
</u-swipe-action> </u-swipe-action>
<u-loadmore :status="loading" margin-top="60"/> <u-loadmore :status="loading" margin-top="60" />
</view> </view>
<!-- 编辑 --> <!-- 编辑 -->
<u-popup v-model="editShow" border-radius="28" width="92%" height="700rpx" <u-popup
mode="center" :closeable="true" :mask-close-able="false" z-index="910"> v-model="editShow"
border-radius="28"
width="92%"
height="700rpx"
mode="center"
:closeable="true"
:mask-close-able="false"
z-index="910"
>
<view class="popup-form-ubox"> <view class="popup-form-ubox">
<view class="top_box"> <view class="top_box">
<view class="title" v-if="setInfo.id"></view> <view class="title" v-if="setInfo.id"></view>
<view class="title" v-else></view> <view class="title" v-else></view>
</view> </view>
<scroll-view class="scroll-y" scroll-y="true"> <scroll-view class="scroll-y" scroll-y="true">
<view class="form_edit" style="padding-left: 50rpx;"> <view class="form_edit" style="padding-left: 50rpx">
<u-form> <u-form>
<u-form-item label="ID" label-width="140" v-if="setInfo.id"> <u-form-item label="ID" label-width="140" v-if="setInfo.id">
<view class="input_box bg_colorf8 pdlr12"> <view class="input_box bg_colorf8 pdlr12">
<u-input v-model="setInfo.id" :disabled="true" /> <u-input v-model="setInfo.id" :disabled="true" />
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="年份" label-width="140" :required='true'> <u-form-item label="年份" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<view class="u-select-list" @click="selectFn1()"> <view class="u-select-list" @click="selectFn1()">
<view class="value u-line-2" <view class="value u-line-2" v-if="setInfo.year">{{
v-if="setInfo.year">{{setInfo.year}}</view> setInfo.year
}}</view>
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
<view class="right"> <view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon
name="arrow-right"
color="#999"
size="28"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="季度" label-width="140" :required='true'> <u-form-item label="季度" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<view class="u-select-list" @click="selectFn2()"> <view class="u-select-list" @click="selectFn2()">
<view class="value u-line-2" <view class="value u-line-2" v-if="setInfo.quarter_name">{{
v-if="setInfo.quarter_name">{{setInfo.quarter_name}}</view> setInfo.quarter_name
}}</view>
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
<view class="right"> <view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon
name="arrow-right"
color="#999"
size="28"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="价格" label-width="140" :required='true'> <u-form-item label="价格" label-width="140" :required="true">
<view class="input_box"> <view class="input_box">
<u-input v-model="setInfo.price" type="number" /> <u-input v-model="setInfo.price" type="number" />
</view> </view>
</u-form-item> </u-form-item>
</u-form> </u-form>
</view> </view>
</scroll-view> </scroll-view>
<view class="buttom_section"> <view class="buttom_section">
<u-button class="btn" type="default" @click="editShow = false">取消</u-button> <u-button class="btn" type="default" @click="editShow = false"
<u-button class="btn" @click="editInfoBtn()" type="primary">确定</u-button> >取消</u-button
>
<u-button class="btn" @click="editInfoBtn()" type="primary"
>确定</u-button
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
@ -100,29 +132,39 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> v-auth="['endpoint.rice_shrimp_prices.destroy']"
class="btn_del"
@click="deleteInfoId(formInfo.id)"
>删除</view
>
<view
v-auth="['endpoint.rice_shrimp_prices.edit']"
class="btn_edit"
@click="editInfoId(formInfo.id)"
>编辑</view
>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">年份</view> <view class="label_t">年份</view>
<view class="flex-1">{{formInfo.year}}</view> <view class="flex-1">{{ formInfo.year }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">季度</view> <view class="label_t">季度</view>
<view class="flex-1">{{formInfo.quarter|quartername}}</view> <view class="flex-1">{{ formInfo.quarter | quartername }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">价格</view> <view class="label_t">价格</view>
<view class="flex-1">{{formInfo.price}}</view> <view class="flex-1">{{ formInfo.price }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">创建人</view> <view class="label_t">创建人</view>
<view class="flex-1">{{ formInfo.created_by?formInfo.created_by.name:'-' }}</view> <view class="flex-1">{{
formInfo.created_by ? formInfo.created_by.name : '-'
}}</view>
</view> </view>
</view> </view>
</view> </view>
</u-popup> </u-popup>
@ -134,299 +176,335 @@
<view class="row_ul u-padding-right-20 u-padding-top-40"> <view class="row_ul u-padding-right-20 u-padding-top-40">
<view class="row_list u-flex"> <view class="row_list u-flex">
<view class="label_tit small">年份</view> <view class="label_tit small">年份</view>
<yn-select-input-list :value="queryCond.year" <yn-select-input-list
rightIcon="calendar" placeholder="请选择年份" :value="queryCond.year"
@click="selectFn1('q')"></yn-select-input-list> rightIcon="calendar"
placeholder="请选择年份"
@click="selectFn1('q')"
></yn-select-input-list>
</view> </view>
<view class="row_list u-flex"> <view class="row_list u-flex">
<view class="label_tit small">季度</view> <view class="label_tit small">季度</view>
<yn-select-input-list :value="queryCond.quarter_name" placeholder="请选择季度" <yn-select-input-list
@click="selectFn2('q')"></yn-select-input-list> :value="queryCond.quarter_name"
placeholder="请选择季度"
@click="selectFn2('q')"
></yn-select-input-list>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view class="buttom_section u-padding-top-40"> <view class="buttom_section u-padding-top-40">
<u-button class="btn small_btn" type="default" @click="resetQuery()"></u-button> <u-button class="btn small_btn" type="default" @click="resetQuery()"
<u-button class="btn small_btn" @click="queryBtn()" type="primary">查询</u-button> >重置</u-button
>
<u-button class="btn small_btn" @click="queryBtn()" type="primary"
>查询</u-button
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
<u-picker mode="time" v-model="selectShow1" <u-picker
:params="timeParams" :default-time="selectValue1" mode="time"
@confirm="uselectConfirm1"></u-picker> v-model="selectShow1"
<u-select v-model="selectShow2" :list="quarterlist" :params="timeParams"
:default-value="selectValue2" mode="single-column" :default-time="selectValue1"
@confirm="uselectConfirm2"></u-select> @confirm="uselectConfirm1"
></u-picker>
<u-select
v-model="selectShow2"
:list="quarterlist"
:default-value="selectValue2"
mode="single-column"
@confirm="uselectConfirm2"
></u-select>
</view> </view>
</template> </template>
<script> <script>
import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js' import {
export default { formatDate,
showLoading,
hideLoading,
navigateBack,
} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default {
data() { data() {
return { return {
background: { background: {
backgroundColor:'#2a7dc9', backgroundColor: '#2a7dc9',
}, },
titleColor:"#ffffff", titleColor: '#ffffff',
per_page:15, per_page: 15,
page:1, page: 1,
list:[], list: [],
loading:'loadmore', loading: 'loadmore',
options: [ popupShow: false,
{ cindex: -1, //
text: '编辑', editShow: false,
style: { formInfo: {},
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false,
cindex:-1,//
editShow:false,
formInfo:{},
timeParams: { timeParams: {
year: true, year: true,
month: false, month: false,
day: false, day: false,
hour: false, hour: false,
minute: false, minute: false,
second: false second: false,
}, },
screenShow:false, screenShow: false,
isqueryselect:false, isqueryselect: false,
setInfo:{ setInfo: {
id:'', id: '',
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
price:'' price: '',
}, },
editShow:false, editShow: false,
queryCond:{ queryCond: {
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
}, },
selectShow1:false, selectShow1: false,
selectShow2:false, selectShow2: false,
selectValue1:'', selectValue1: '',
selectValue2:[0], selectValue2: [0],
quarterlist:[ quarterlist: [
{ {
label:'第一季度', label: '第一季度',
value:1, value: 1,
}, },
{ {
label:'第二季度', label: '第二季度',
value:2, value: 2,
}, },
{ {
label:'第三季度', label: '第三季度',
value:3, value: 3,
}, },
{ {
label:'第四季度', label: '第四季度',
value:4, value: 4,
},
],
} }
]
};
}, },
filters:{ filters: {
quartername(val){ quartername(val) {
let keys = {1:'第一季度',2:'第二季度',3:'第三季度',4:'第四季度'} let keys = { 1: '第一季度', 2: '第二季度', 3: '第三季度', 4: '第四季度' }
let name = keys[val]?keys[val]:val let name = keys[val] ? keys[val] : val
return name; return name
}, },
}, },
onLoad(){ computed: {
this.queryDataList(); options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.rice_shrimp_prices.edit'],
style: {
backgroundColor: '#007aff',
}, },
methods:{
addBtn(){
this.setInfoKeys('add');
this.editShow = true;
}, },
selectFn1(type){ {
this.isqueryselect = false; text: '删除',
let year = this.setInfo.year; opt: 'delete',
if(type=='q'){ permission: ['endpoint.rice_shrimp_prices.destroy'],
this.isqueryselect = true; style: {
this.selectShow1 = true; backgroundColor: '#dd524d',
year = this.queryCond.year; },
},
].filter((e) => checkPermission(e.permission))
},
},
onLoad() {
this.queryDataList()
},
methods: {
addBtn() {
this.setInfoKeys('add')
this.editShow = true
},
selectFn1(type) {
this.isqueryselect = false
let year = this.setInfo.year
if (type == 'q') {
this.isqueryselect = true
this.selectShow1 = true
year = this.queryCond.year
} }
if(year){ if (year) {
this.selectValue1 = `${year}-01-01 00:00:01`; this.selectValue1 = `${year}-01-01 00:00:01`
} }
console.log(this.selectValue1) console.log(this.selectValue1)
this.selectShow1 = true; this.selectShow1 = true
}, },
selectFn2(type){ selectFn2(type) {
this.isqueryselect = false; this.isqueryselect = false
let quarter = this.setInfo.quarter; let quarter = this.setInfo.quarter
if(type=='q'){ if (type == 'q') {
this.isqueryselect = true; this.isqueryselect = true
quarter = this.queryCond.quarter; quarter = this.queryCond.quarter
} }
for(let [index,item] of this.quarterlist.entries()){ for (let [index, item] of this.quarterlist.entries()) {
if(quarter==item.value){ if (quarter == item.value) {
this.selectValue2 = [index]; this.selectValue2 = [index]
break; break
} }
} }
this.selectShow2 = true; this.selectShow2 = true
}, },
resetQuery(){ resetQuery() {
this.queryCond = { this.queryCond = {
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
} }
}, },
queryBtn(){ queryBtn() {
this.list = []; this.list = []
this.queryDataList(true); this.queryDataList(true)
this.screenShow = false; this.screenShow = false
}, },
uselectConfirm1(e){ uselectConfirm1(e) {
if(this.isqueryselect){ if (this.isqueryselect) {
console.log(e); console.log(e)
this.queryCond.year = e.year; this.queryCond.year = e.year
}else{ } else {
this.setInfo.year = e.year; this.setInfo.year = e.year
} }
}, },
uselectConfirm2(e){ uselectConfirm2(e) {
if(this.isqueryselect){ if (this.isqueryselect) {
console.log(e); console.log(e)
this.queryCond.quarter = e[0].value; this.queryCond.quarter = e[0].value
this.queryCond.quarter_name = e[0].label; this.queryCond.quarter_name = e[0].label
}else{ } else {
this.setInfo.quarter = e[0].value; this.setInfo.quarter = e[0].value
this.setInfo.quarter_name = e[0].label; this.setInfo.quarter_name = e[0].label
} }
}, },
screenShowFn(){ screenShowFn() {
this.screenShow = true; this.screenShow = true
}, },
showInfo(index){ showInfo(index) {
this.cindex = index; this.cindex = index
let _id = this.list[index].id; let _id = this.list[index].id
this.queryInfo(_id); this.queryInfo(_id)
this.formInfo = this.list[index]; this.formInfo = this.list[index]
this.popupShow = true; this.popupShow = true
}, },
open(index){ open(index) {
this.list[index].show = true; this.list[index].show = true
}, },
click(index, index1) { click(index, index1) {
console.log(index,index1,this.list[index]) console.log(index, index1, this.list[index])
if(index1 == 1) { if (index1 == 1) {
this.cindex = index; this.cindex = index
let _id = this.list[index].id; let _id = this.list[index].id
this.deleteInfoId(_id); this.deleteInfoId(_id)
} else {// } else {
let _id = this.list[index].id; //
this.formInfo = this.list[index]; let _id = this.list[index].id
this.queryInfo(_id); this.formInfo = this.list[index]
this.setInfoKeys(); this.queryInfo(_id)
this.editShow = true; this.setInfoKeys()
this.list[index].show = false; this.editShow = true
this.list[index].show = false
} }
}, },
queryDataList(refresh){ queryDataList(refresh) {
if(refresh){ if (refresh) {
this.loading = 'loadmore'; this.loading = 'loadmore'
this.page = 1; this.page = 1
} }
if(this.loading=='nomore'){// if (this.loading == 'nomore') {
return false; //
return false
} }
let params = { let params = {
per_page:this.per_page, per_page: this.per_page,
page: this.page ++, page: this.page++,
_t: new Date().getTime() _t: new Date().getTime(),
} }
for(let k in this.queryCond){ for (let k in this.queryCond) {
if(this.queryCond[k]||this.queryCond[k]=='0'){ if (this.queryCond[k] || this.queryCond[k] == '0') {
params[k] = this.queryCond[k]; params[k] = this.queryCond[k]
} }
} }
this.loading = 'loading'; this.loading = 'loading'
this.$http.get('/api/rice-shrimp-prices',{params:params}).then(({data})=>{ this.$http
.get('/api/rice-shrimp-prices', { params: params })
.then(({ data }) => {
console.log(data) console.log(data)
this.screenShow = false; this.screenShow = false
if(refresh){ if (refresh) {
this.list = []; this.list = []
} }
this.loading = 'loadmore'; this.loading = 'loadmore'
if(data.code==200){ if (data.code == 200) {
let _list = data.data|| []; let _list = data.data || []
for(let item of _list){ for (let item of _list) {
item.show = false; item.show = false
} }
this.list = this.list.concat(_list); this.list = this.list.concat(_list)
console.log(this.list); console.log(this.list)
if(this.list.length>= data.meta.total){ if (this.list.length >= data.meta.total) {
this.loading ='nomore'; this.loading = 'nomore'
} }
} }
}).catch(()=>{ })
this.loading = 'loadmore'; .catch(() => {
this.screenShow = false; this.loading = 'loadmore'
this.screenShow = false
}) })
}, },
// //
editInfoBtn(){ editInfoBtn() {
if(!this.valiFormRule()){ if (!this.valiFormRule()) {
return false; return false
} }
let params = {} let params = {}
params = this.setInfo; params = this.setInfo
showLoading('请稍等'); showLoading('请稍等')
if(params['id']){ if (params['id']) {
this.$http.put(`/api/rice-shrimp-prices/${params['id']}`,params).then(({data})=>{ this.$http
hideLoading(); .put(`/api/rice-shrimp-prices/${params['id']}`, params)
if(data.code==200){ .then(({ data }) => {
hideLoading()
this.editShow = false; if (data.code == 200) {
this.queryDataList(true); this.editShow = false
this.queryDataList(true)
} }
uni.showToast({ title: data.message, icon: 'none' }); uni.showToast({ title: data.message, icon: 'none' })
}).catch(()=>{
hideLoading();
}) })
}else{ .catch(() => {
delete params['id']; hideLoading()
this.$http.post(`/api/rice-shrimp-prices`,params).then(({data})=>{ })
hideLoading(); } else {
if(data.code==200){ delete params['id']
this.queryDataList(true); this.$http
this.editShow = false; .post(`/api/rice-shrimp-prices`, params)
uni.showToast({ title: data.message, icon: 'none' }); .then(({ data }) => {
}else{ hideLoading()
uni.showToast({ title: data.message, icon: 'none' }); if (data.code == 200) {
this.queryDataList(true)
this.editShow = false
uni.showToast({ title: data.message, icon: 'none' })
} else {
uni.showToast({ title: data.message, icon: 'none' })
} }
}).catch(()=>{ })
hideLoading(); .catch(() => {
hideLoading()
}) })
} }
}, },
queryInfo(id){ queryInfo(id) {
// this.$http.get(`/api/rice-shrimp-prices/${id}`).then(({data})=>{ // this.$http.get(`/api/rice-shrimp-prices/${id}`).then(({data})=>{
// console.log(data,'queryInfo===') // console.log(data,'queryInfo===')
// if(data.code==200){ // if(data.code==200){
@ -434,104 +512,102 @@
// this.setInfoKeys(); // this.setInfoKeys();
// } // }
// }).catch((err)=>{ // }).catch((err)=>{
// }) // })
}, },
editInfoId(id){ editInfoId(id) {
// this.queryInfo(id); // this.queryInfo(id);
this.setInfoKeys(); this.setInfoKeys()
this.editShow = true; this.editShow = true
this.popupShow = false; this.popupShow = false
}, },
//deleteInfoId //deleteInfoId
deleteInfoId(id){ deleteInfoId(id) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '是否确定删除?', content: '是否确定删除?',
success: (res)=> { success: (res) => {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定'); console.log('用户点击确定')
showLoading('请稍等'); showLoading('请稍等')
this.$http.delete(`/api/rice-shrimp-prices/${id}`).then(({data})=>{ this.$http
hideLoading(); .delete(`/api/rice-shrimp-prices/${id}`)
if(data.code==200){ .then(({ data }) => {
this.formInfo = {};// hideLoading()
this.popupShow = false; if (data.code == 200) {
this.list.splice(this.cindex,1); this.formInfo = {} //
this.popupShow = false
this.list.splice(this.cindex, 1)
// this.queryDataList(true); // this.queryDataList(true);
} }
uni.showToast({ title: data.message, icon: 'none' }); uni.showToast({ title: data.message, icon: 'none' })
}).catch(()=>{ })
hideLoading(); .catch(() => {
hideLoading()
}) })
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消'); console.log('用户点击取消')
} }
}
});
}, },
setInfoKeys(type){ })
},
setInfoKeys(type) {
let info = { let info = {
id:'', id: '',
year:'', year: '',
quarter:'', quarter: '',
quarter_name:'', quarter_name: '',
price:'' price: '',
} }
if(type=='add'){ if (type == 'add') {
this.setInfo = info; this.setInfo = info
}else{ } else {
let {id,year,quarter,price} = this.formInfo; let { id, year, quarter, price } = this.formInfo
try{ try {
for(let item of this.quarterlist){ for (let item of this.quarterlist) {
if(quarter == item.value){ if (quarter == item.value) {
info.quarter_name = item.label; info.quarter_name = item.label
break; break
} }
} }
info['id'] = id; info['id'] = id
info['year'] = year; info['year'] = year
info['quarter'] = quarter; info['quarter'] = quarter
info['price'] = price; info['price'] = price
this.setInfo = info; this.setInfo = info
} catch (e) {
}catch(e){
//TODO handle the exception //TODO handle the exception
uni.showToast({ title: '数据错误', icon: 'none' }) uni.showToast({ title: '数据错误', icon: 'none' })
} }
} }
}, },
valiFormRule(){ valiFormRule() {
let {id,year,quarter,price} = this.setInfo; let { id, year, quarter, price } = this.setInfo
if(year==''){ if (year == '') {
uni.showToast({ title: '年份不能为空', icon: 'none' }); uni.showToast({ title: '年份不能为空', icon: 'none' })
return false; return false
} }
if(quarter==''){ if (quarter == '') {
uni.showToast({ title: '季度不能为空', icon: 'none' }); uni.showToast({ title: '季度不能为空', icon: 'none' })
return false; return false
} }
if(price==''){ if (price == '') {
uni.showToast({ title: '价格不能为空', icon: 'none' }); uni.showToast({ title: '价格不能为空', icon: 'none' })
return false; return false
} }
return true; return true
}, },
goback(){ goback() {
navigateBack() navigateBack()
} },
}, },
// //
onReachBottom() { onReachBottom() {
if(this.loading=='loadmore'){ if (this.loading == 'loadmore') {
this.queryDataList(); this.queryDataList()
} }
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss"></style>
</style>

View File

@ -1,9 +1,14 @@
<template> <template>
<view class="bg-page"> <view class="bg-page">
<u-navbar title="稻虾每周价格" :background="background" :custom-back="goback" <u-navbar
:title-color="titleColor" :back-icon-color="titleColor"> title="稻虾每周价格"
:background="background"
:custom-back="goback"
:title-color="titleColor"
:back-icon-color="titleColor"
>
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view v-auth="['endpoint.rice_shrimp_weekly_prices.create']" class="custom_btn add_btn" @click="addBtn()"></view>
</view> </view>
</u-navbar> </u-navbar>
<view class="secreen-section"> <view class="secreen-section">
@ -14,21 +19,23 @@
</view> </view>
</view> </view>
<view class="content-box u-padding-25"> <view class="content-box u-padding-25">
<u-swipe-action class="tb_swipe_list" <u-swipe-action
class="tb_swipe_list"
v-for="(item, index) in list" v-for="(item, index) in list"
:show="item.show" :index="index" :key="item.id" :show="item.show"
:index="index"
:key="item.id"
@click="click" @click="click"
@open="open" @open="open"
:options="options" :options="options"
> >
<view class="tb_body" @click="showInfo(index)"> <view class="tb_body" @click="showInfo(index)">
<view class="row_box"> <view class="row_box">
<view class="text">年份{{ item.year }}</view> <view class="text">年份{{ item.year }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">{{item.week_label}}</view> <view class="text">{{ item.week_label }}</view>
</view> </view>
<view class="row_box"> <view class="row_box">
<view class="text">价格{{ item.price }}</view> <view class="text">价格{{ item.price }}</view>
@ -36,66 +43,98 @@
<!-- <view class="row_box"> <!-- <view class="row_box">
<view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view> <view class="text">创建人{{ item.created_by?item.created_by.name:'-' }}</view>
</view> --> </view> -->
</view> </view>
</u-swipe-action> </u-swipe-action>
<u-loadmore :status="loading" margin-top="60"/> <u-loadmore :status="loading" margin-top="60" />
</view> </view>
<!-- 编辑 --> <!-- 编辑 -->
<u-popup v-model="editShow" border-radius="28" width="92%" height="700rpx" <u-popup
mode="center" :closeable="true" :mask-close-able="false" z-index="910"> v-model="editShow"
border-radius="28"
width="92%"
height="700rpx"
mode="center"
:closeable="true"
:mask-close-able="false"
z-index="910"
>
<view class="popup-form-ubox"> <view class="popup-form-ubox">
<view class="top_box"> <view class="top_box">
<view class="title" v-if="setInfo.id"></view> <view class="title" v-if="setInfo.id"></view>
<view class="title" v-else></view> <view class="title" v-else></view>
</view> </view>
<scroll-view class="scroll-y" scroll-y="true"> <scroll-view class="scroll-y" scroll-y="true">
<view class="form_edit" style="padding-left: 50rpx;"> <view class="form_edit" style="padding-left: 50rpx">
<u-form > <u-form>
<u-form-item label="ID" label-width="140" v-if="setInfo.id"> <u-form-item label="ID" label-width="140" v-if="setInfo.id">
<view class="input_box bg_colorf8 pdlr12"> <view class="input_box bg_colorf8 pdlr12">
<u-input v-model="setInfo.id" :disabled="true" /> <u-input v-model="setInfo.id" :disabled="true" />
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="年份" label-width="140" <u-form-item
prop="year" :required='true'> label="年份"
label-width="140"
prop="year"
:required="true"
>
<view class="input_box"> <view class="input_box">
<view class="u-select-list" @click="selectFn1()"> <view class="u-select-list" @click="selectFn1()">
<view class="value u-line-2" <view class="value u-line-2" v-if="setInfo.year">{{
v-if="setInfo.year">{{setInfo.year}}</view> setInfo.year
}}</view>
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
<view class="right"> <view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon
name="arrow-right"
color="#999"
size="28"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="周" label-width="140" <u-form-item
prop="week" :required='true'> label="周"
label-width="140"
prop="week"
:required="true"
>
<view class="input_box"> <view class="input_box">
<view class="u-select-list" @click="selectFn2()"> <view class="u-select-list" @click="selectFn2()">
<view class="value u-line-2" <view class="value u-line-2" v-if="setInfo.week_name">{{
v-if="setInfo.week_name">{{setInfo.week_name}}</view> setInfo.week_name
}}</view>
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
<view class="right"> <view class="right">
<u-icon name="arrow-right" color="#999" size="28"></u-icon> <u-icon
name="arrow-right"
color="#999"
size="28"
></u-icon>
</view> </view>
</view> </view>
</view> </view>
</u-form-item> </u-form-item>
<u-form-item label="价格" label-width="140" <u-form-item
prop="week" :required='true'> label="价格"
label-width="140"
prop="week"
:required="true"
>
<view class="input_box"> <view class="input_box">
<u-input v-model="setInfo.price" type="number"/> <u-input v-model="setInfo.price" type="number" />
</view> </view>
</u-form-item> </u-form-item>
</u-form> </u-form>
</view> </view>
</scroll-view> </scroll-view>
<view class="buttom_section"> <view class="buttom_section">
<u-button class="btn" type="default" @click="editShow = false">取消</u-button> <u-button class="btn" type="default" @click="editShow = false"
<u-button class="btn" @click="editInfoBtn()" type="primary">确定</u-button> >取消</u-button
>
<u-button class="btn" @click="editInfoBtn()" type="primary"
>确定</u-button
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
@ -103,29 +142,29 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view v-auth="['endpoint.rice_shrimp_weekly_prices.destroy']" class="btn_del" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> <view v-auth="['endpoint.rice_shrimp_weekly_prices.edit']" class="btn_edit" @click="editInfoId(formInfo.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">年份</view> <view class="label_t">年份</view>
<view class="flex-1">{{formInfo.year}}</view> <view class="flex-1">{{ formInfo.year }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t"></view> <view class="label_t"></view>
<view class="flex-1">{{formInfo.week_label}}</view> <view class="flex-1">{{ formInfo.week_label }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">价格</view> <view class="label_t">价格</view>
<view class="flex-1">{{formInfo.price}}</view> <view class="flex-1">{{ formInfo.price }}</view>
</view> </view>
<view class="plist u-border-bottom"> <view class="plist u-border-bottom">
<view class="label_t">创建人</view> <view class="label_t">创建人</view>
<view class="flex-1">{{ formInfo.created_by?formInfo.created_by.name:'-' }}</view> <view class="flex-1">{{
formInfo.created_by ? formInfo.created_by.name : '-'
}}</view>
</view> </view>
</view> </view>
</view> </view>
</u-popup> </u-popup>
@ -137,276 +176,312 @@
<view class="row_ul u-padding-right-20 u-padding-top-40"> <view class="row_ul u-padding-right-20 u-padding-top-40">
<view class="row_list u-flex"> <view class="row_list u-flex">
<view class="label_tit small">年份</view> <view class="label_tit small">年份</view>
<yn-select-input-list :value="queryCond.year" <yn-select-input-list
rightIcon="calendar" placeholder="请选择年份" :value="queryCond.year"
@click="selectFn1('q')"></yn-select-input-list> rightIcon="calendar"
placeholder="请选择年份"
@click="selectFn1('q')"
></yn-select-input-list>
</view> </view>
<view class="row_list u-flex"> <view class="row_list u-flex">
<view class="label_tit small"></view> <view class="label_tit small"></view>
<yn-select-input-list :value="queryCond.week_name" placeholder="请选择季度" <yn-select-input-list
@click="selectFn2('q')"></yn-select-input-list> :value="queryCond.week_name"
placeholder="请选择季度"
@click="selectFn2('q')"
></yn-select-input-list>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view class="buttom_section u-padding-top-40"> <view class="buttom_section u-padding-top-40">
<u-button class="btn small_btn" type="default" @click="resetQuery()"></u-button> <u-button class="btn small_btn" type="default" @click="resetQuery()"
<u-button class="btn small_btn" @click="queryBtn()" type="primary">查询</u-button> >重置</u-button
>
<u-button class="btn small_btn" @click="queryBtn()" type="primary"
>查询</u-button
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
<u-picker mode="time" v-model="selectShow1" <u-picker
:params="timeParams" :default-time="selectValue1" mode="time"
@confirm="uselectConfirm1"></u-picker> v-model="selectShow1"
<u-select v-model="selectShow2" :list="weeksperyearlist" :params="timeParams"
:default-value="selectValue2" mode="single-column" :default-time="selectValue1"
@confirm="uselectConfirm2"></u-select> @confirm="uselectConfirm1"
></u-picker>
<u-select
v-model="selectShow2"
:list="weeksperyearlist"
:default-value="selectValue2"
mode="single-column"
@confirm="uselectConfirm2"
></u-select>
</view> </view>
</template> </template>
<script> <script>
import {formatDate,showLoading,hideLoading,navigateBack} from '@/com/utils.js' import {
export default { formatDate,
showLoading,
hideLoading,
navigateBack,
} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default {
data() { data() {
return { return {
background: { background: {
backgroundColor:'#2a7dc9', backgroundColor: '#2a7dc9',
}, },
titleColor:"#ffffff", titleColor: '#ffffff',
per_page:15, per_page: 15,
page:1, page: 1,
list:[], list: [],
loading:'loadmore', loading: 'loadmore',
options: [ popupShow: false,
{ cindex: -1, //
text: '编辑', editShow: false,
style: { formInfo: {},
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false,
cindex:-1,//
editShow:false,
formInfo:{},
timeParams: { timeParams: {
year: true, year: true,
month: false, month: false,
day: false, day: false,
hour: false, hour: false,
minute: false, minute: false,
second: false second: false,
}, },
screenShow:false, screenShow: false,
isqueryselect:false, isqueryselect: false,
setInfo:{ setInfo: {
id:'', id: '',
year:'', year: '',
week:'', week: '',
week_name:'', week_name: '',
price:'' price: '',
}, },
editShow:false, editShow: false,
queryCond:{ queryCond: {
year:'', year: '',
week:'', week: '',
week_name:'', week_name: '',
}, },
selectShow1:false, selectShow1: false,
selectShow2:false, selectShow2: false,
selectValue1:'', selectValue1: '',
selectValue2:[0], selectValue2: [0],
weeksperyearlist:[], weeksperyearlist: [],
};
},
onLoad(){
this.queryDataList();
this.getweeksperyear();
},
methods:{
addBtn(){
this.setInfoKeys('add');
this.editShow = true;
},
selectFn1(type){
this.isqueryselect = false;
let year = this.setInfo.year;
if(type=='q'){
this.isqueryselect = true;
this.selectShow1 = true;
year = this.queryCond.year;
} }
if(year){ },
this.selectValue1 = `${year}-01-01 00:00:01`; computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.rice_shrimp_weekly_prices.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.rice_shrimp_weekly_prices.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
},
onLoad() {
this.queryDataList()
this.getweeksperyear()
},
methods: {
addBtn() {
this.setInfoKeys('add')
this.editShow = true
},
selectFn1(type) {
this.isqueryselect = false
let year = this.setInfo.year
if (type == 'q') {
this.isqueryselect = true
this.selectShow1 = true
year = this.queryCond.year
}
if (year) {
this.selectValue1 = `${year}-01-01 00:00:01`
} }
console.log(this.selectValue1) console.log(this.selectValue1)
this.selectShow1 = true; this.selectShow1 = true
}, },
selectFn2(type){ selectFn2(type) {
this.isqueryselect = false; this.isqueryselect = false
let week = this.setInfo.week; let week = this.setInfo.week
if(type=='q'){ if (type == 'q') {
this.isqueryselect = true; this.isqueryselect = true
week = this.queryCond.week; week = this.queryCond.week
} }
for(let [index,item] of this.weeksperyearlist.entries()){ for (let [index, item] of this.weeksperyearlist.entries()) {
if(week==item.value){ if (week == item.value) {
this.selectValue2 = [index]; this.selectValue2 = [index]
break; break
} }
} }
this.selectShow2 = true; this.selectShow2 = true
}, },
resetQuery(){ resetQuery() {
this.queryCond = { this.queryCond = {
year:'', year: '',
week:'', week: '',
week_name:'', week_name: '',
} }
}, },
queryBtn(){ queryBtn() {
this.list = []; this.list = []
this.queryDataList(true); this.queryDataList(true)
this.screenShow = false; this.screenShow = false
}, },
uselectConfirm1(e){ uselectConfirm1(e) {
if(this.isqueryselect){ if (this.isqueryselect) {
console.log(e); console.log(e)
this.queryCond.year = e.year; this.queryCond.year = e.year
}else{ } else {
this.setInfo.year = e.year; this.setInfo.year = e.year
} }
}, },
uselectConfirm2(e){ uselectConfirm2(e) {
if(this.isqueryselect){ if (this.isqueryselect) {
console.log(e); console.log(e)
this.queryCond.week = e[0].value; this.queryCond.week = e[0].value
this.queryCond.week_name = e[0].label; this.queryCond.week_name = e[0].label
}else{ } else {
this.setInfo.week = e[0].value; this.setInfo.week = e[0].value
this.setInfo.week_name = e[0].label; this.setInfo.week_name = e[0].label
} }
}, },
screenShowFn(){ screenShowFn() {
this.screenShow = true; this.screenShow = true
}, },
showInfo(index){ showInfo(index) {
this.cindex = index; this.cindex = index
let _id = this.list[index].id; let _id = this.list[index].id
this.queryInfo(_id); this.queryInfo(_id)
this.formInfo = this.list[index]; this.formInfo = this.list[index]
this.popupShow = true; this.popupShow = true
}, },
open(index){ open(index) {
this.list[index].show = true; this.list[index].show = true
}, },
click(index, index1) { click(index, index1) {
console.log(index,index1,this.list[index]) console.log(index, index1, this.list[index])
if(index1 == 1) { if (index1 == 1) {
this.cindex = index; this.cindex = index
let _id = this.list[index].id; let _id = this.list[index].id
this.deleteInfoId(_id); this.deleteInfoId(_id)
} else {// } else {
let _id = this.list[index].id; //
this.formInfo = this.list[index]; let _id = this.list[index].id
this.queryInfo(_id); this.formInfo = this.list[index]
this.setInfoKeys(); this.queryInfo(_id)
this.editShow = true; this.setInfoKeys()
this.list[index].show = false; this.editShow = true
this.list[index].show = false
} }
}, },
queryDataList(refresh){ queryDataList(refresh) {
if(refresh){ if (refresh) {
this.loading = 'loadmore'; this.loading = 'loadmore'
this.page = 1; this.page = 1
} }
if(this.loading=='nomore'){// if (this.loading == 'nomore') {
return false; //
return false
} }
let params = { let params = {
per_page:this.per_page, per_page: this.per_page,
page: this.page ++, page: this.page++,
_t: new Date().getTime() _t: new Date().getTime(),
} }
for(let k in this.queryCond){ for (let k in this.queryCond) {
if(this.queryCond[k]||this.queryCond[k]=='0'){ if (this.queryCond[k] || this.queryCond[k] == '0') {
params[k] = this.queryCond[k]; params[k] = this.queryCond[k]
} }
} }
this.loading = 'loading'; this.loading = 'loading'
this.$http.get('/api/rice-shrimp-weekly-prices',{params:params}).then(({data})=>{ this.$http
.get('/api/rice-shrimp-weekly-prices', { params: params })
.then(({ data }) => {
console.log(data) console.log(data)
this.screenShow = false; this.screenShow = false
if(refresh){ if (refresh) {
this.list = []; this.list = []
} }
this.loading = 'loadmore'; this.loading = 'loadmore'
if(data.code==200){ if (data.code == 200) {
let _list = data.data|| []; let _list = data.data || []
for(let item of _list){ for (let item of _list) {
item.show = false; item.show = false
} }
this.list = this.list.concat(_list); this.list = this.list.concat(_list)
console.log(this.list); console.log(this.list)
if(this.list.length>= data.meta.total){ if (this.list.length >= data.meta.total) {
this.loading ='nomore'; this.loading = 'nomore'
} }
} }
}).catch(()=>{ })
this.loading = 'loadmore'; .catch(() => {
this.screenShow = false; this.loading = 'loadmore'
this.screenShow = false
}) })
}, },
// //
editInfoBtn(){ editInfoBtn() {
if(!this.valiFormRule()){ if (!this.valiFormRule()) {
return false; return false
} }
let params = {} let params = {}
params = this.setInfo; params = this.setInfo
showLoading('请稍等'); showLoading('请稍等')
if(params['id']){ if (params['id']) {
this.$http.put(`/api/rice-shrimp-weekly-prices/${params['id']}`,params).then(({data})=>{ this.$http
hideLoading(); .put(`/api/rice-shrimp-weekly-prices/${params['id']}`, params)
if(data.code==200){ .then(({ data }) => {
hideLoading()
this.editShow = false; if (data.code == 200) {
this.queryDataList(true); this.editShow = false
this.queryDataList(true)
} }
uni.showToast({ title: data.message, icon: 'none' }); uni.showToast({ title: data.message, icon: 'none' })
}).catch(()=>{
hideLoading();
}) })
}else{ .catch(() => {
delete params['id']; hideLoading()
this.$http.post(`/api/rice-shrimp-weekly-prices`,params).then(({data})=>{ })
hideLoading(); } else {
if(data.code==200){ delete params['id']
this.queryDataList(true); this.$http
this.editShow = false; .post(`/api/rice-shrimp-weekly-prices`, params)
uni.showToast({ title: data.message, icon: 'none' }); .then(({ data }) => {
}else{ hideLoading()
uni.showToast({ title: data.message, icon: 'none' }); if (data.code == 200) {
this.queryDataList(true)
this.editShow = false
uni.showToast({ title: data.message, icon: 'none' })
} else {
uni.showToast({ title: data.message, icon: 'none' })
} }
}).catch(()=>{ })
hideLoading(); .catch(() => {
hideLoading()
}) })
} }
}, },
queryInfo(id){ queryInfo(id) {
// this.$http.get(`/api/rice-shrimp-weekly-prices/${id}`).then(({data})=>{ // this.$http.get(`/api/rice-shrimp-weekly-prices/${id}`).then(({data})=>{
// console.log(data,'queryInfo===') // console.log(data,'queryInfo===')
// if(data.code==200){ // if(data.code==200){
@ -414,118 +489,117 @@
// this.setInfoKeys(); // this.setInfoKeys();
// } // }
// }).catch((err)=>{ // }).catch((err)=>{
// }) // })
}, },
editInfoId(id){ editInfoId(id) {
// this.queryInfo(id); // this.queryInfo(id);
this.setInfoKeys(); this.setInfoKeys()
this.editShow = true; this.editShow = true
this.popupShow = false; this.popupShow = false
}, },
getweeksperyear(){ getweeksperyear() {
this.$http.get(`/api/weeks-per-year`).then(({data})=>{ this.$http
if(data.code==200){ .get(`/api/weeks-per-year`)
let list = data.data; .then(({ data }) => {
let weeks = []; if (data.code == 200) {
for(let item of list){ let list = data.data
weeks.push({label:item.name,value:item.id}) let weeks = []
for (let item of list) {
weeks.push({ label: item.name, value: item.id })
} }
this.weeksperyearlist = weeks; this.weeksperyearlist = weeks
} }
}).catch((err)=>{
}) })
.catch((err) => {})
}, },
//deleteInfoId //deleteInfoId
deleteInfoId(id){ deleteInfoId(id) {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '是否确定删除?', content: '是否确定删除?',
success: (res)=> { success: (res) => {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定'); console.log('用户点击确定')
showLoading('请稍等'); showLoading('请稍等')
this.$http.delete(`/api/rice-shrimp-weekly-prices/${id}`).then(({data})=>{ this.$http
hideLoading(); .delete(`/api/rice-shrimp-weekly-prices/${id}`)
if(data.code==200){ .then(({ data }) => {
this.formInfo = {};// hideLoading()
this.popupShow = false; if (data.code == 200) {
this.list.splice(this.cindex,1); this.formInfo = {} //
this.popupShow = false
this.list.splice(this.cindex, 1)
// this.queryDataList(true); // this.queryDataList(true);
} }
uni.showToast({ title: data.message, icon: 'none' }); uni.showToast({ title: data.message, icon: 'none' })
}).catch(()=>{ })
hideLoading(); .catch(() => {
hideLoading()
}) })
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消'); console.log('用户点击取消')
} }
}
});
}, },
setInfoKeys(type){ })
},
setInfoKeys(type) {
let info = { let info = {
id:'', id: '',
year:'', year: '',
week:'', week: '',
week_name:'', week_name: '',
price:'' price: '',
} }
if(type=='add'){ if (type == 'add') {
this.setInfo = info; this.setInfo = info
}else{ } else {
let {id,year,week,price} = this.formInfo; let { id, year, week, price } = this.formInfo
try{ try {
for(let item of this.weeksperyearlist){ for (let item of this.weeksperyearlist) {
if(week == item.value){ if (week == item.value) {
info.week_name = item.label; info.week_name = item.label
break; break
} }
} }
info['id'] = id; info['id'] = id
info['year'] = year; info['year'] = year
info['week'] = week; info['week'] = week
info['price'] = price; info['price'] = price
this.setInfo = info; this.setInfo = info
} catch (e) {
}catch(e){
//TODO handle the exception //TODO handle the exception
uni.showToast({ title: '数据错误', icon: 'none' }) uni.showToast({ title: '数据错误', icon: 'none' })
} }
} }
}, },
valiFormRule(){ valiFormRule() {
let {id,year,week,price} = this.setInfo; let { id, year, week, price } = this.setInfo
if(year==''){ if (year == '') {
uni.showToast({ title: '年份不能为空', icon: 'none' }); uni.showToast({ title: '年份不能为空', icon: 'none' })
return false; return false
} }
if(week==''){ if (week == '') {
uni.showToast({ title: '周不能为空', icon: 'none' }); uni.showToast({ title: '周不能为空', icon: 'none' })
return false; return false
} }
if(price==''){ if (price == '') {
uni.showToast({ title: '价格不能为空', icon: 'none' }); uni.showToast({ title: '价格不能为空', icon: 'none' })
return false; return false
} }
return true; return true
}, },
goback(){ goback() {
navigateBack() navigateBack()
} },
}, },
// //
onReachBottom() { onReachBottom() {
if(this.loading=='loadmore'){ if (this.loading == 'loadmore') {
this.queryDataList(); this.queryDataList()
} }
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss"></style>
</style>

View File

@ -10,13 +10,13 @@
<view class="content-box"> <view class="content-box">
<view <view
class="menus-section" class="menus-section"
v-for="(menu, index) in menuList" v-for="(menu, index) in menus"
:key="index" :key="index"
> >
<view class="title-t" v-if="menu.parent" <view class="title-t" v-if="menu.parent && menu.children.length>0"
>{{ menu.parent }}-{{ menu.label }}</view >{{ menu.parent }}-{{ menu.label }}</view
> >
<view class="title-t" v-else>{{ menu.label }}</view> <view class="title-t" v-if="!menu.parent && menu.children.length>0">{{ menu.label }}</view>
<view class="menu-ul"> <view class="menu-ul">
<view class="menu-li" v-for="(cdm, i) in menu.children" :key="i"> <view class="menu-li" v-for="(cdm, i) in menu.children" :key="i">
<view class="menu_item" @click="linknavFn(cdm)"> <view class="menu_item" @click="linknavFn(cdm)">
@ -31,6 +31,7 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
data() { data() {
return { return {
@ -42,44 +43,40 @@ export default {
{ {
label: '气象监测', label: '气象监测',
url: '/pages/index/meteorological', url: '/pages/index/meteorological',
permission: 'endpoint.weather.index',
}, },
{ {
label: '智能监控', label: '智能监控',
url: '/pages/index/monitor', url: '/pages/index/monitor',
permission: 'endpoint.camera.index',
}, },
{ {
label: '土壤监控', label: '土壤监控',
url: '/pages/index/soil-monitoring', url: '/pages/index/soil-monitoring',
permission: 'endpoint.soil.index',
}, },
{ {
label: '水质监控', label: '水质监控',
url: '/pages/index/water-quality', url: '/pages/index/water-quality',
permission: 'endpoint.water.index',
}, },
{ {
label: '昆虫性诱监测', label: '昆虫性诱监测',
url: '/pages/index/insect-monitors', url: '/pages/index/insect-monitors',
permission: 'endpoint.insect.index',
}, },
{ {
label: '虫情监测', label: '虫情监测',
url: '/pages/index/pests', url: '/pages/index/pests',
permission: 'endpoint.worm_statics.index',
}, },
{ {
label: '杀虫灯检测', label: '杀虫灯检测',
url: '/pages/index/insecticidal-lamp', url: '/pages/index/insecticidal-lamp',
permission: 'endpoint.insecticidal_lamp.index',
}, },
], ],
}, },
// {
// label:'',
// children:[
// {
// label:'',
// },
// {
// label:'',
// },
// ],
// },
{ {
label: '全市基础数据', label: '全市基础数据',
parent: '基础数据管理', parent: '基础数据管理',
@ -87,10 +84,12 @@ export default {
{ {
label: '城镇数据', label: '城镇数据',
url: '/pages/basics/town-base', url: '/pages/basics/town-base',
permission: 'endpoint.town_street.index',
}, },
{ {
label: '基地数据', label: '基地数据',
url: '/pages/basics/basics-base', url: '/pages/basics/basics-base',
permission: 'endpoint.agricultural_basic.index',
}, },
], ],
}, },
@ -101,10 +100,12 @@ export default {
{ {
label: '城镇农作物', label: '城镇农作物',
url: '/pages/crop/town-crop', url: '/pages/crop/town-crop',
permission: 'endpoint.town_crops.index',
}, },
{ {
label: '基地农作物', label: '基地农作物',
url: '/pages/crop/basics-crop', url: '/pages/crop/basics-crop',
permission: 'endpoint.crops.index',
}, },
], ],
}, },
@ -115,10 +116,12 @@ export default {
{ {
label: '城镇产量', label: '城镇产量',
url: '/pages/yield/town-yield', url: '/pages/yield/town-yield',
permission: 'endpoint.town_crops_output.index',
}, },
{ {
label: '基地产量', label: '基地产量',
url: '/pages/yield/basics-yield', url: '/pages/yield/basics-yield',
permission: 'endpoint.crops_output.index',
}, },
], ],
}, },
@ -129,22 +132,27 @@ export default {
{ {
label: '稻虾价格', label: '稻虾价格',
url: '/pages/estate/estate-price', url: '/pages/estate/estate-price',
permission: 'endpoint.rice_shrimp_prices.index',
}, },
{ {
label: '稻虾每周价格', label: '稻虾每周价格',
url: '/pages/estate/estate-week-price', url: '/pages/estate/estate-week-price',
permission: 'endpoint.rice_shrimp_weekly_prices.index',
}, },
{ {
label: '稻虾产业', label: '稻虾产业',
url: '/pages/estate/estate-industry', url: '/pages/estate/estate-industry',
permission: 'endpoint.rice_shrimp_industries.index',
}, },
{ {
label: '稻虾流向', label: '稻虾流向',
url: '/pages/estate/estate-flows', url: '/pages/estate/estate-flows',
permission: 'endpoint.rice_shrimp_flows.index',
}, },
{ {
label: '大宗物资', label: '大宗物资',
url: '/pages/estate/estate-materiels', url: '/pages/estate/estate-materiels',
permission: 'endpoint.materiels.index',
}, },
], ],
}, },
@ -154,18 +162,48 @@ export default {
{ {
label: '设备管理', label: '设备管理',
url: '/pages/device/index', url: '/pages/device/index',
permission: 'endpoint.device.index',
}, },
{ {
label: '警报明细', label: '警报明细',
url: '/pages/device/warning', url: '/pages/device/warning',
permission: 'endpoint.warnings.index',
}, },
], ],
}, },
], ],
} }
}, },
computed: {
...mapGetters(['userInfo']),
menus(){
return this.filterAsyncRoutes(this.menuList, this.userInfo?.permissions_slug ?? [])
}
},
onLoad() {}, onLoad() {},
methods: { methods: {
hasPermission(roles, route) {
if (route.permission) {
return roles.some((role) => route.permission.includes(role))
} else {
return true
}
},
filterAsyncRoutes(routes, roles) {
const res = []
routes.forEach((route) => {
const tmp = { ...route }
if (this.hasPermission(roles, tmp)) {
if (tmp.children) {
tmp.children = this.filterAsyncRoutes(tmp.children, roles)
}
res.push(tmp)
}
})
return res
},
linknavFn(item) { linknavFn(item) {
console.log(item) console.log(item)
uni.navigateTo({ uni.navigateTo({

View File

@ -1,156 +1,233 @@
<template> <template>
<view class="monitor-page bg-page" > <view class="monitor-page bg-page">
<view class="utab-section"> <view class="utab-section">
<u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection> <u-subsection
:list="list"
:current="current"
@change="sectionChange"
></u-subsection>
</view> </view>
<view class="secreen-section" style="background-color: #fff;"> <view class="secreen-section" style="background-color: #fff">
<u-dropdown class="dropdown-box" v-if="current==0" ref="uDropdown"> <u-dropdown class="dropdown-box" v-if="current == 0" ref="uDropdown">
<u-dropdown-item v-model="addressValue" title="基地" <u-dropdown-item
v-model="addressValue"
title="基地"
height="700rpx" height="700rpx"
:options="deviceAddressList" @change="change"></u-dropdown-item> :options="deviceAddressList"
<u-dropdown-item v-model="device_id" title="检测点" height="700rpx" @change="change"
:options="options2" @change="change2"></u-dropdown-item> ></u-dropdown-item>
<u-dropdown-item v-model="is_recommend" title="全部" <u-dropdown-item
:options="options3" @change="change3"></u-dropdown-item> v-model="device_id"
title="检测点"
height="700rpx"
:options="options2"
@change="change2"
></u-dropdown-item>
<u-dropdown-item
v-model="is_recommend"
title="全部"
:options="options3"
@change="change3"
></u-dropdown-item>
</u-dropdown> </u-dropdown>
<u-dropdown class="dropdown-box" v-if="current==1" ref="uDropdown2" <u-dropdown
@open="openDropDown"> class="dropdown-box"
<u-dropdown-item v-model="addressValue2" title="基地" height="700rpx" v-if="current == 1"
:options="deviceAddressList2" @change="change"></u-dropdown-item> ref="uDropdown2"
<u-dropdown-item v-model="device_id2" title="检测点" height="700rpx" @open="openDropDown"
:options="options4" @change="change4"></u-dropdown-item> >
<u-dropdown-item v-if="current==1" title="日期"> <u-dropdown-item
<view class="slot-content" style="background-color: #FFFFFF;"> v-model="addressValue2"
<view class="select-date u-border-bottom" style="margin-bottom: 0;"> title="基地"
height="700rpx"
:options="deviceAddressList2"
@change="change"
></u-dropdown-item>
<u-dropdown-item
v-model="device_id2"
title="检测点"
height="700rpx"
:options="options4"
@change="change4"
></u-dropdown-item>
<u-dropdown-item v-if="current == 1" title="日期">
<view class="slot-content" style="background-color: #ffffff">
<view class="select-date u-border-bottom" style="margin-bottom: 0">
<view class="name" @click="pickerTimeFn('start')"> <view class="name" @click="pickerTimeFn('start')">
<u-icon name="calendar" color="#333" size="32"></u-icon> <u-icon name="calendar" color="#333" size="32"></u-icon>
<text style="margin-left: 6rpx;">开始时间</text> <text style="margin-left: 6rpx">开始时间</text>
</view> </view>
<view class="time_box"> <view class="time_box">
<view class="tip_txt" v-if="!start_date_c" <view
@click="pickerTimeFn('start')">请选择开始时间</view> class="tip_txt"
<view class="tile_val" v-else v-if="!start_date_c"
@click="pickerTimeFn('start')">{{start_date_c}}</view> @click="pickerTimeFn('start')"
<view class="delete_btn" v-if="start_date_c" @click="deleteDateFn('start')"> >请选择开始时间</view
>
<view class="tile_val" v-else @click="pickerTimeFn('start')">{{
start_date_c
}}</view>
<view
class="delete_btn"
v-if="start_date_c"
@click="deleteDateFn('start')"
>
<u-icon name="close-circle" color="#333" size="34"></u-icon> <u-icon name="close-circle" color="#333" size="34"></u-icon>
</view> </view>
</view> </view>
</view> </view>
<view class="select-date u-border-bottom" style="margin-bottom: 0;"> <view class="select-date u-border-bottom" style="margin-bottom: 0">
<view class="name" @click="pickerTimeFn('end')"> <view class="name" @click="pickerTimeFn('end')">
<u-icon name="calendar" color="#333" size="32"></u-icon> <u-icon name="calendar" color="#333" size="32"></u-icon>
<text style="margin-left: 6rpx;">结束时间</text> <text style="margin-left: 6rpx">结束时间</text>
</view> </view>
<view class="time_box"> <view class="time_box">
<view class="tip_txt" v-if="!end_date_c" <view
@click="pickerTimeFn('end')">请选择结束时间</view> class="tip_txt"
<view class="tile_val" v-else v-if="!end_date_c"
@click="pickerTimeFn('end')">{{end_date_c}}</view> @click="pickerTimeFn('end')"
<view class="delete_btn" v-if="end_date_c" @click="deleteDateFn('end')"> >请选择结束时间</view
>
<view class="tile_val" v-else @click="pickerTimeFn('end')">{{
end_date_c
}}</view>
<view
class="delete_btn"
v-if="end_date_c"
@click="deleteDateFn('end')"
>
<u-icon name="close-circle" color="#333" size="34"></u-icon> <u-icon name="close-circle" color="#333" size="34"></u-icon>
</view> </view>
</view> </view>
</view> </view>
<view class="select-date u-border-bottom" v-if="selectedTimeTip"> <view class="select-date u-border-bottom" v-if="selectedTimeTip">
<view class="tip_err_text" > <view class="tip_err_text">
请选择开始时间和结束时间查询视频 请选择开始时间和结束时间查询视频
</view> </view>
</view> </view>
<view class="btn_group"> <view class="btn_group">
<u-button class="btn" @click="resetSecreen()"></u-button> <u-button class="btn" @click="resetSecreen()"></u-button>
<u-button class="btn" type="primary" @click="selectedDateConform()"></u-button> <u-button
class="btn"
type="primary"
@click="selectedDateConform()"
>查询</u-button
>
</view> </view>
</view> </view>
</u-dropdown-item> </u-dropdown-item>
</u-dropdown> </u-dropdown>
</view> </view>
<view class="secreen-show-box mt20" v-if="current==0&&addressName"> <view class="secreen-show-box mt20" v-if="current == 0 && addressName">
<view class="label_t">当前位置</view> <view class="label_t">当前位置</view>
<view class="info">{{addressName}}-{{device_id?device_id:'全部'}}-{{is_recommend?'推荐':'全部'}}</view> <view class="info"
>{{ addressName }}-{{ device_id ? device_id : '全部' }}-{{
is_recommend ? '推荐' : '全部'
}}</view
>
</view> </view>
<view class="secreen-show-box mt20" v-if="current==1&&q_start_time"> <view class="secreen-show-box mt20" v-if="current == 1 && q_start_time">
<view class="label_t">查询</view> <view class="label_t">查询</view>
<view class="info"> <view class="info">
<view>{{addressName2}}-{{device_id2}}</view> <view>{{ addressName2 }}-{{ device_id2 }}</view>
<view>{{q_start_time}} {{q_end_time}}</view> <view>{{ q_start_time }} {{ q_end_time }}</view>
</view> </view>
</view> </view>
<view class="content-box"> <view class="content-box">
<view class="video_ul" v-show="current==0"> <view class="video_ul" v-show="current == 0">
<view class="video_li" v-for="(video,index) in videoList" :key="index"> <view class="video_li" v-for="(video, index) in videoList" :key="index">
<view class="video_cd"> <view class="video_cd">
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<video-flv-h5 :url="video.video_url"></video-flv-h5> <videoM3u8H5 v-if="video.video_type=='m3u8'" :url="video.video_url" :id="`m_${index}_refsM3u8`"></videoM3u8H5>
<video-flv-h5 v-else :url="video.video_url"></video-flv-h5>
<!-- #endif --> <!-- #endif -->
</view> </view>
<view class="bottom-box"> <view class="bottom-box">
<view class="row flex-row"> <view class="row flex-row">
<view class="lab">推荐</view> <view class="lab">推荐</view>
<u-switch v-model="video.bl_recommend" size="30" <u-switch
@change="changeRecommend($event,index)"></u-switch> v-model="video.bl_recommend"
size="30"
@change="changeRecommend($event, index)"
></u-switch>
</view> </view>
<view class="address">{{video.base_name}}-{{video.monitoring_point}}</view> <view class="address"
>{{ video.base_name }}-{{ video.monitoring_point }}</view
>
</view> </view>
</view> </view>
<u-loadmore :status="loading" /> <u-loadmore :status="loading" />
</view> </view>
<view class="video_ul" v-show="current==1"> <view class="video_ul" v-show="current == 1">
<view class="video_li" v-for="(video,index) in videoList2" :key="index"> <view
class="video_li"
v-for="(video, index) in videoList2"
:key="index"
>
<view class="video_cd"> <view class="video_cd">
<!-- #ifdef H5 --> <!-- #ifdef H5 -->
<video-flv-h5 :url="video.video_url"></video-flv-h5> <videoM3u8H5 v-if="video.video_type=='m3u8'" :url="video.video_url" :id="`m_${index}_refsM3u82`" ></videoM3u8H5>
<video-flv-h5 v-else :url="video.video_url"></video-flv-h5>
<!-- #endif --> <!-- #endif -->
</view> </view>
<view class="bottom-box"> <view class="bottom-box">
<view class="address">{{video.base_name}}-{{video.monitoring_point}}</view> <view class="address"
>{{ video.base_name }}-{{ video.monitoring_point }}</view
>
</view> </view>
</view> </view>
<u-loadmore :status="loading2" v-if="loading2"/> <u-loadmore :status="loading2" v-if="loading2" />
<u-empty text="请选择要查看的视频的日期" mode="history" margin-top="100" <u-empty
v-if="!(videoList2&&videoList2.length)"></u-empty> text="请选择要查看的视频的日期"
mode="history"
margin-top="100"
v-if="!(videoList2 && videoList2.length)"
></u-empty>
</view> </view>
</view> </view>
<!-- 选择时间 --> <!-- 选择时间 -->
<u-picker mode="time" v-model="pickerShow" @confirm="pickerChange" <u-picker
:params="pickerParams" :default-time="defaultTime"></u-picker> mode="time"
v-model="pickerShow"
@confirm="pickerChange"
:params="pickerParams"
:default-time="defaultTime"
></u-picker>
</view> </view>
</template> </template>
<script> <script>
import videoFlvH5 from '@/components/video-flv-h5/video-flv-h5.vue' import videoFlvH5 from '@/components/video-flv-h5/video-flv-h5.vue'
export default { import videoM3u8H5 from '@/components/video-m3u8-h5/video-m3u8-h5.vue'
components: { videoFlvH5 }, import Request from '@/api/luch-request/index.js'
const http = new Request()
export default {
components: { videoFlvH5,videoM3u8H5 },
data() { data() {
return { return {
list:[ list: [
{ {
name: '监控' name: '监控',
}, },
{ {
name: '视频' name: '视频',
}, },
], ],
current:0, current: 0,
// //
q_start_time:'', q_start_time: '',
q_end_time:'', q_end_time: '',
deviceAddressList:[],// deviceAddressList: [], //
addressName:'', addressName: '',
addressValue:'', addressValue: '',
device_id:'',// - options2id device_id: '', // - options2id
options2:[], options2: [],
start_date_c:'', start_date_c: '',
end_date_c:'', end_date_c: '',
device_type:1,// device_type: 1, //
is_recommend:0, is_recommend: 0,
options3:[ options3: [
{ {
label: '全部', label: '全部',
value: 0, value: 0,
@ -158,373 +235,413 @@
{ {
label: '推荐', label: '推荐',
value: 1, value: 1,
} },
], ],
per_page:4, per_page: 4,
page:1, page: 1,
pickerParams: { pickerParams: {
year: true, year: true,
month: true, month: true,
day: true, day: true,
hour: true, hour: true,
minute: true, minute: true,
second: false second: false,
}, },
defaultTime:'', defaultTime: '',
pickerShow:false,// pickerShow: false, //
ctimeType:'',// ctimeType: '', //
addressValue2:'', addressValue2: '',
addressName2:'', addressName2: '',
device_id2:'', device_id2: '',
options4:[], options4: [],
websocket:{}, websocket: {},
videoList:[], videoList: [],
videoList2:[], videoList2: [],
per_page2:4, per_page2: 4,
page2:1, page2: 1,
loading:'loading', loading: 'loading',
loading2:'', loading2: '',
selectedTimeTip:false,// selectedTimeTip: false, //
}; }
}, },
onLoad(){ onLoad() {
this.queryWebsocketIp(); this.queryWebsocketIp()
}, },
methods:{ methods: {
sectionChange(index) { sectionChange(index) {
this.current = index; this.current = index
}, },
//1 //1
change(val){ change(val) {
console.log(val); console.log(val)
let narray = this.deviceAddressList.filter(item=>{ let narray = this.deviceAddressList.filter((item) => {
return item.value==val; return item.value == val
}) })
console.log(narray); console.log(narray)
if(this.current==0){ if (this.current == 0) {
this.addressName = narray[0].name; this.addressName = narray[0].name
}else{ } else {
this.addressName2 = narray[0].name; this.addressName2 = narray[0].name
} }
if(val==''){ if (val == '') {
this.addressName = '全部'; this.addressName = '全部'
this.queryDevices(); this.queryDevices()
}else{ } else {
this.queryAddressDevicePoints(val); this.queryAddressDevicePoints(val)
} }
}, },
//id //id
change2(val){ change2(val) {
console.log(val) console.log(val)
this.queryDevices(); this.queryDevices()
}, },
// //
change3(val){ change3(val) {
this.queryDevices(); this.queryDevices()
}, },
//- //-
change4(val){ change4(val) {},
},
// //
pickerTimeFn(type){ pickerTimeFn(type) {
this.ctimeType = type; this.ctimeType = type
this.pickerShow = true; this.pickerShow = true
}, },
// //
pickerChange(e){ pickerChange(e) {
console.log(e,'日期范围') console.log(e, '日期范围')
let dateTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`; let dateTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`
if(this.ctimeType=='start'){ if (this.ctimeType == 'start') {
this.start_date_c = dateTime; this.start_date_c = dateTime
}else if(this.ctimeType=='end'){ } else if (this.ctimeType == 'end') {
this.end_date_c = dateTime; this.end_date_c = dateTime
}else{} } else {
console.log(dateTime,'日期范围') }
console.log(dateTime, '日期范围')
}, },
// //
deleteDateFn(type){ deleteDateFn(type) {
if(type=='start'){ if (type == 'start') {
this.start_date_c = ''; this.start_date_c = ''
}else if(type=='end'){ } else if (type == 'end') {
this.end_date_c = ''; this.end_date_c = ''
}else{} } else {
}
}, },
resetSecreen(){ resetSecreen() {
this.start_date_c = ''; this.start_date_c = ''
this.end_date_c = ''; this.end_date_c = ''
}, },
selectedDateConform(){ selectedDateConform() {
if(this.start_date_c&&this.end_date_c){ if (this.start_date_c && this.end_date_c) {
this.selectedTimeTip = false; this.selectedTimeTip = false
this.q_start_time = this.start_date_c; this.q_start_time = this.start_date_c
this.q_end_time = this.end_date_c; this.q_end_time = this.end_date_c
this.queryDevices2(); this.queryDevices2()
this.$refs.uDropdown2.close(); this.$refs.uDropdown2.close()
}else{ } else {
this.selectedTimeTip = true; this.selectedTimeTip = true
} }
}, },
// //
openDropDown(index){ openDropDown(index) {
console.log(index,'openDropDown'); console.log(index, 'openDropDown')
this.selectedTimeTip = false; this.selectedTimeTip = false
if(index==2){// if (index == 2) {
this.start_date_c = this.q_start_time; //
this.end_date_c = this.q_end_time; this.start_date_c = this.q_start_time
this.end_date_c = this.q_end_time
} }
}, },
// //
changeRecommend(value,index){ changeRecommend(value, index) {
console.log(value,index); console.log(value, index)
let id = this.videoList[index].id; let id = this.videoList[index].id
this.recommendId(id); this.recommendId(id)
}, },
recommendId(id){ recommendId(id) {
this.$http.put(`/api/devices-update-recommend/${id}`).then(({data})=>{ this.$http
console.log(data,'recommendId===') .put(`/api/devices-update-recommend/${id}`)
.then(({ data }) => {
}).catch((err)=>{ console.log(data, 'recommendId===')
}) })
.catch((err) => {})
}, },
async queryWebsocketIp(){ async queryWebsocketIp() {
let params = { let params = {
_t: new Date().getTime() _t: new Date().getTime(),
} }
const {data} = await this.$http.get('/api/ffmpeg-websocket-ip',{params:params}); const { data } = await this.$http.get('/api/ffmpeg-websocket-ip', {
try{ params: params,
console.log(data,'queryWebsocketIp'); })
if(data.code==200){ try {
this.websocket = data.data; console.log(data, 'queryWebsocketIp')
if (data.code == 200) {
this.websocket = data.data
} }
}catch(e){ } catch (e) {
//TODO handle the exception //TODO handle the exception
} }
this.queryDeviceBasics('init'); this.queryDeviceBasics('init')
}, },
// //
queryDevices(type){ queryDevices(type) {
if(type!='more'){ if (type != 'more') {
this.loading = 'loadmore'; this.loading = 'loadmore'
this.page = 1; this.page = 1
} }
let params = { let params = {
type:this.device_type, type: this.device_type,
status:1,//线 status: 1, //线
per_page:this.per_page, per_page: this.per_page,
page:this.page++, page: this.page++,
_t: new Date().getTime() _t: new Date().getTime(),
} }
if(this.addressValue){ if (this.addressValue) {
params['base'] = this.addressValue; params['base'] = this.addressValue
} }
if(this.device_id){ if (this.device_id) {
params['point'] = this.device_id; params['point'] = this.device_id
} }
if(this.is_recommend){ if (this.is_recommend) {
params['is_recommend'] = this.is_recommend; params['is_recommend'] = this.is_recommend
} }
this.loading = 'loading'; this.loading = 'loading'
this.$http.get('/api/devices',{params:params}).then(({data})=>{ this.$http
this.loading = 'loadmore'; .get('/api/devices', { params: params })
if(type!='more'){ .then(async ({ data }) => {
this.videoList = []; this.loading = 'loadmore'
if (type != 'more') {
this.videoList = []
} }
console.log(data,'监测视频'); console.log(data, '监测视频')
if(data.code==200){ if (data.code == 200) {
let list = data.data; let list = data.data
for(let item of list){ for (let item of list) {
let url = item.extends.rtsp_url; let url = item.extends.rtsp_url
let {ip,port} = this.websocket; let { ip, port } = this.websocket
if(url){
item.video_url = `ws://${ip}:${port}/rtsp?url=${window.btoa(url)}` if (url) {
item.video_url = `ws://${ip}:${port}/rtsp?url=${window.btoa(
url
)}`
} }
item.bl_recommend = item.is_recommend==1?true:false; const { supplier, extends: extend, sn } = item
if (item.supplier.id == 'device-supplier-biang') {
const { data } = await http.get(
'https://yun.bigdata5s.com/api/open-api/open/getSeedingLive',
{
params: {
username: extend.username,
password: extend.password,
equipmentCode: sn,
channelNo: extend.passage,
},
} }
this.videoList = this.videoList.concat(list); )
if(data.meta.current_page>= data.meta.last_page){ item.video_url = data.data
this.loading = 'nomore'; item.video_type = 'm3u8'
} }
console.log(this.videoList,data);
item.bl_recommend = item.is_recommend == 1 ? true : false
} }
}).catch(()=>{ this.videoList = this.videoList.concat(list)
this.loading = 'loadmore'; if (data.meta.current_page >= data.meta.last_page) {
this.loading = 'nomore'
}
console.log(this.videoList, data)
}
})
.catch(() => {
this.loading = 'loadmore'
}) })
}, },
// //
queryDevices2(type){ queryDevices2(type) {
if(type!='more'){ if (type != 'more') {
this.loading2 = 'loadmore'; this.loading2 = 'loadmore'
this.page2 = 1; this.page2 = 1
} }
let params = { let params = {
type:this.device_type, type: this.device_type,
status:1,//线 status: 1, //线
per_page:this.per_page2, per_page: this.per_page2,
page:this.page2++, page: this.page2++,
_t: new Date().getTime() _t: new Date().getTime(),
} }
if(this.addressValue2){ if (this.addressValue2) {
params['base'] = this.addressValue2; params['base'] = this.addressValue2
} }
if(this.device_id){ if (this.device_id) {
params['point'] = this.device_id2; params['point'] = this.device_id2
} }
if(this.q_start_time){// if (this.q_start_time) {
params['start_time'] = this.q_start_time; //
params['end_time'] = this.q_end_time; params['start_time'] = this.q_start_time
params['end_time'] = this.q_end_time
} }
this.loading2 = 'loading'; this.loading2 = 'loading'
this.$http.get('/api/devices',{params:params}).then(({data})=>{ this.$http
this.loading2 = 'loadmore'; .get('/api/devices', { params: params })
if(type!='more'){this.videoList2 = [];} .then(({ data }) => {
console.log(data,'监测视频'); this.loading2 = 'loadmore'
if(data.code==200){ if (type != 'more') {
let list = data.data; this.videoList2 = []
for(let item of list){ }
let url = item.extends.rtsp_url; console.log(data, '监测视频')
if(url){ if (data.code == 200) {
let {username,password,ip,passage,port} = item.extends let list = data.data
let stime = this.$u.timeFormat(params['start_time'], 'yyyy_mm_dd_hh_MM_ss'); for (let item of list) {
let etime = this.$u.timeFormat(params['end_time'], 'yyyy_mm_dd_hh_MM_ss'); let url = item.extends.rtsp_url
let p_url = `rtsp://${username}:${password}@${ip}:${port}/cam/playback?channel=${passage}&subtype=0`; if (url) {
let rtsp_url = `${p_url}&starttime=${stime}&endtime=${etime}`; let { username, password, ip, passage, port } = item.extends
item.video_url = `ws://${this.websocket.ip}:${this.websocket.port}/rtsp?url=${window.btoa(rtsp_url)}}` let stime = this.$u.timeFormat(
console.log(rtsp_url,item.video_url,'视频url'); params['start_time'],
'yyyy_mm_dd_hh_MM_ss'
)
let etime = this.$u.timeFormat(
params['end_time'],
'yyyy_mm_dd_hh_MM_ss'
)
let p_url = `rtsp://${username}:${password}@${ip}:${port}/cam/playback?channel=${passage}&subtype=0`
let rtsp_url = `${p_url}&starttime=${stime}&endtime=${etime}`
item.video_url = `ws://${this.websocket.ip}:${
this.websocket.port
}/rtsp?url=${window.btoa(rtsp_url)}}`
console.log(rtsp_url, item.video_url, '视频url')
} }
} }
this.videoList2 = this.videoList2.concat(list); this.videoList2 = this.videoList2.concat(list)
if(data.meta.current_page>= data.meta.last_page){ if (data.meta.current_page >= data.meta.last_page) {
this.loading2 = 'nomore'; this.loading2 = 'nomore'
} }
} }
}).catch(()=>{ })
this.loading2 = 'loadmore'; .catch(() => {
this.loading2 = 'loadmore'
}) })
}, },
// //
queryDeviceBasics(type){ queryDeviceBasics(type) {
let params = { let params = {
device_type:this.device_type, device_type: this.device_type,
_t: new Date().getTime() _t: new Date().getTime(),
} }
this.$http.get('/api/agricultural-device-basic',{params:params}).then(({data})=>{ this.$http
console.log(data); .get('/api/agricultural-device-basic', { params: params })
if(data.code==200){ .then(({ data }) => {
let _data = data.data; console.log(data)
for(let item of _data){ if (data.code == 200) {
item['label'] = item.name; let _data = data.data
item['value'] = item.id; for (let item of _data) {
item['label'] = item.name
item['value'] = item.id
} }
this.deviceAddressList = JSON.parse(JSON.stringify(_data)); this.deviceAddressList = JSON.parse(JSON.stringify(_data))
this.deviceAddressList2 =_data; this.deviceAddressList2 = _data
this.addressValue = _data[0].id; this.addressValue = _data[0].id
this.addressName = _data[0].name; this.addressName = _data[0].name
this.addressValue2 = _data[0].id; this.addressValue2 = _data[0].id
this.addressName2 = _data[0].name; this.addressName2 = _data[0].name
this.deviceAddressList.unshift({label:'全部',value:''}); this.deviceAddressList.unshift({ label: '全部', value: '' })
this.queryAddressDevicePoints(_data[0].id,type); this.queryAddressDevicePoints(_data[0].id, type)
} }
}).catch(()=>{
}) })
.catch(() => {})
}, },
// //
queryAddressDevicePoints(id,type){ queryAddressDevicePoints(id, type) {
let params = { let params = {
device_type:this.device_type, device_type: this.device_type,
agricultural_basic:id, agricultural_basic: id,
_t: new Date().getTime() _t: new Date().getTime(),
} }
this.$http.get(`/api/agricultural-device-point/${id}`,{params:params}).then(({data})=>{ this.$http
console.log(data); .get(`/api/agricultural-device-point/${id}`, { params: params })
if(data.code==200){ .then(({ data }) => {
let _data = data.data; console.log(data)
let options = []; if (data.code == 200) {
for(let k in _data){ let _data = data.data
let item = {}; let options = []
item['label'] = _data[k]; for (let k in _data) {
item['value'] = _data[k]; let item = {}
options.push(item); item['label'] = _data[k]
item['value'] = _data[k]
options.push(item)
} }
console.log(type,'初始查询') console.log(type, '初始查询')
console.log(this.options2,this.device_id,'this.options2');
if(this.current==0){//
this.options2 = JSON.parse(JSON.stringify(options));;
this.device_id = options[0].value;
this.options2.unshift({label:'全部',value:''});
this.queryDevices();
}else{//
this.options4 = options;
this.device_id2 = options[0].value;
console.log(this.options2, this.device_id, 'this.options2')
if (this.current == 0) {
//
this.options2 = JSON.parse(JSON.stringify(options))
this.device_id = options[0].value
this.options2.unshift({ label: '全部', value: '' })
this.queryDevices()
} else {
//
this.options4 = options
this.device_id2 = options[0].value
} }
if(type=='init'){// if (type == 'init') {
this.options4 = options; //
this.device_id2 = options[0].value; this.options4 = options
this.device_id2 = options[0].value
} }
} }
}).catch(()=>{
}) })
.catch(() => {})
}, },
}, },
// //
onReachBottom() { onReachBottom() {
if(this.current==0){ if (this.current == 0) {
if(this.loading=='loadmore'){ if (this.loading == 'loadmore') {
this.queryDevices('more'); this.queryDevices('more')
} }
}else{ } else {
if(this.loading2=='loadmore'){ if (this.loading2 == 'loadmore') {
this.queryDevices2('more'); this.queryDevices2('more')
} }
} }
}, },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.monitor-page{ .monitor-page {
background-color: #fafafa; background-color: #fafafa;
} }
.utab-section{ .utab-section {
padding: 30rpx; padding: 30rpx;
} }
.content-box{ .content-box {
padding: 30rpx; padding: 30rpx;
} }
.video_ul{ .video_ul {
.video_li{ .video_li {
background-color: #fff; background-color: #fff;
width: 100%; width: 100%;
padding: 0 12rpx; padding: 0 12rpx;
margin-bottom: 30rpx; margin-bottom: 30rpx;
.video_cd{ .video_cd {
width: 100%; width: 100%;
height: 400rpx; height: 400rpx;
padding-top: 20rpx; padding-top: 20rpx;
} }
.bottom-box{ .bottom-box {
padding-top: 30rpx; padding-top: 30rpx;
padding-bottom: 30rpx; padding-bottom: 30rpx;
padding-left: 20rpx; padding-left: 20rpx;
padding-right: 20rpx; padding-right: 20rpx;
.row{ .row {
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 12rpx; margin-bottom: 12rpx;
} }
} }
.address{ .address {
font-size: 28rpx; font-size: 28rpx;
} }
} }

View File

@ -44,7 +44,7 @@
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="tit">预警数据统计</view> <view class="tit">预警数据统计</view>
<view class="set_warning"> <view class="set_warning">
<u-button class="set_btn" @click="setWarnInfo()" size="mini">设置</u-button> <u-button v-auth="['endpoint.soil.setting','endpoint.soil.setting_edit']" class="set_btn" @click="setWarnInfo()" size="mini"></u-button>
</view> </view>
</view> </view>
<view class="cont-box"> <view class="cont-box">

View File

@ -44,7 +44,7 @@
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="tit">预警数据统计</view> <view class="tit">预警数据统计</view>
<view class="set_warning"> <view class="set_warning">
<u-button class="set_btn" @click="setWarnInfo()" size="mini">设置</u-button> <u-button v-auth="['endpoint.water.setting','endpoint.water.setting_edit']" class="set_btn" @click="setWarnInfo()" size="mini"></u-button>
</view> </view>
</view> </view>
<view class="cont-box"> <view class="cont-box">

View File

@ -1,23 +1,29 @@
<template> <template>
<view class="login-page bg-page"> <view class="login-page bg-page">
<view class="img-a"> <view class="img-a">
<view class="t-b"> <view class="t-b"> 隆昌农业大数据监控平台 </view>
隆昌农业大数据监控平台
</view>
</view> </view>
<view class="login-view" style=""> <view class="login-view" style="">
<view class="t-login"> <view class="t-login">
<form class="cl"> <form class="cl">
<view class="t-a"> <view class="t-a">
<text class="txt">账号</text> <text class="txt">账号</text>
<input type="text" name="username" placeholder="请输入您的账号" <input
v-model="username" /> type="text"
name="username"
placeholder="请输入您的账号"
v-model="username"
/>
</view> </view>
<view class="t-a"> <view class="t-a">
<text class="txt">密码</text> <text class="txt">密码</text>
<input type="password" name="password" maxlength="18" <input
placeholder="请输入您的密码" v-model="password" /> type="password"
name="password"
maxlength="18"
placeholder="请输入您的密码"
v-model="password"
/>
</view> </view>
<button @tap="login()" type="button"> </button> <button @tap="login()" type="button"> </button>
<!-- <view class="reg" @tap="reg()"> </view> --> <!-- <view class="reg" @tap="reg()"> </view> -->
@ -27,64 +33,67 @@
</view> </view>
</template> </template>
<script> <script>
import {getStorageSync,setStorageSync,setStorage, toast} from '@/com/utils.js' import {
getStorageSync,
setStorageSync,
setStorage,
toast,
} from '@/com/utils.js'
import jwt from '@/api/jwt.js' import jwt from '@/api/jwt.js'
export default { export default {
data() { data() {
return { return {
username: '', // username: '', //
password: '' // password: '', //
}; }
},
onLoad() {
}, },
onLoad() {},
methods: { methods: {
// //
login() { login() {
if (!this.username) { if (!this.username) {
uni.showToast({ title: '请输入您的账号', icon: 'none' }); uni.showToast({ title: '请输入您的账号', icon: 'none' })
return; return
} }
if (!this.password) { if (!this.password) {
uni.showToast({ title: '请输入您的密码', icon: 'none' }); uni.showToast({ title: '请输入您的密码', icon: 'none' })
return; return
} }
let params = { let params = {
username:this.username, username: this.username,
password:this.password password: this.password,
};
this.$http.post('/api/auth/login',params,{
custom:{
auth:false
} }
}).then(({data})=>{
console.log(data); this.$http
if(data.code==200){ .post('/api/auth/login', params, {
let _data = data.data; custom: {
let _info = _data.info; auth: false,
},
})
.then(({ data }) => {
console.log(data)
if (data.code == 200) {
let _data = data.data
let _info = _data.info
console.log(_data) console.log(_data)
jwt.setAccessToken(_data.token) jwt.setAccessToken(_data.token)
this.$store.dispatch('USER_INFO',_info); this.$store.dispatch('getUserInfo')
uni.switchTab({ uni.switchTab({
url:'/pages/index/index' url: '/pages/index/index',
}) })
uni.showToast({ title: '登录成功!', icon: 'none' }); uni.showToast({ title: '登录成功!', icon: 'none' })
} }
}).catch(()=>{
uni.showToast({ title: '登录失败!', icon: 'none' });
}) })
.catch(() => {
uni.showToast({ title: '登录失败!', icon: 'none' })
})
}, },
},
} }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.login-page{ .login-page {
background-color: #fff; background-color: #fff;
.txt { .txt {
font-size: 32rpx; font-size: 32rpx;

View File

@ -4,7 +4,7 @@
<view class="top-title-box"> <view class="top-title-box">
<view class="title">账号列表</view> <view class="title">账号列表</view>
<view class="handle-option"> <view class="handle-option">
<u-button class="btn" size="medium" <u-button v-auth="['endpoint.admin_users.create']" class="btn" size="medium"
@click="addBtn()" type="primary">新增</u-button> @click="addBtn()" type="primary">新增</u-button>
</view> </view>
</view> </view>
@ -127,9 +127,9 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view v-auth="['endpoint.admin_users.destroy']" class="btn_del" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editPwdPopup(formInfo.id)"></view> <view v-auth="['endpoint.admin_users.edit_password']" class="btn_edit" @click="editPwdPopup(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> <view v-auth="['endpoint.admin_users.edit']" class="btn_edit" @click="editInfoId(formInfo.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
@ -235,6 +235,7 @@
<script> <script>
import {showLoading,hideLoading} from '@/com/utils.js' import {showLoading,hideLoading} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default { export default {
data() { data() {
return { return {
@ -242,20 +243,6 @@
page:1, page:1,
list:[], list:[],
loading:'loadmore', loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false, popupShow:false,
cindex:-1,// cindex:-1,//
editShow:false, editShow:false,
@ -324,6 +311,26 @@
}; };
}, },
computed:{ computed:{
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.device.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.device.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
seletedShow(){ seletedShow(){
let arrName = []; let arrName = [];
for(let item of this.seletedBaseList){ for(let item of this.seletedBaseList){

View File

@ -3,7 +3,7 @@
<u-navbar title="友情链接" :background="background" :custom-back="goback" <u-navbar title="友情链接" :background="background" :custom-back="goback"
:title-color="titleColor" :back-icon-color="titleColor"> :title-color="titleColor" :back-icon-color="titleColor">
<view class="nav_slot_right_box" slot="right"> <view class="nav_slot_right_box" slot="right">
<view class="custom_btn add_btn" @click="addBtn()"></view> <view v-auth="['endpoint.friend_links.edit']" class="custom_btn add_btn" @click="addBtn()"></view>
</view> </view>
</u-navbar> </u-navbar>
<u-sticky z-index="99"> <u-sticky z-index="99">
@ -164,8 +164,8 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box u-border-bottom"> <view class="top_box u-border-bottom">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteInfoId(formInfo.id)"></view> <view v-auth="['endpoint.friend_links.destroy']" class="btn_del" @click="deleteInfoId(formInfo.id)"></view>
<view class="btn_edit" @click="editInfoId(formInfo.id)"></view> <view v-auth="['endpoint.friend_links.edit']" class="btn_edit" @click="editInfoId(formInfo.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
@ -218,6 +218,7 @@
<script> <script>
import {formatDate,navigateBack,showLoading,hideLoading} from '@/com/utils.js' import {formatDate,navigateBack,showLoading,hideLoading} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default { export default {
data() { data() {
return { return {
@ -229,20 +230,6 @@
page:1, page:1,
list:[], list:[],
loading:'loadmore', loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false, popupShow:false,
cindex:-1,// cindex:-1,//
editShow:false, editShow:false,
@ -286,6 +273,28 @@
q_type:'', q_type:'',
dropDownShow:false, dropDownShow:false,
}; };
},
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.friend_links.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.friend_links.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
}, },
filters:{ filters:{
timeFormat(val){ timeFormat(val){

View File

@ -4,7 +4,7 @@
<view class="top-title-box"> <view class="top-title-box">
<view class="title">角色列表</view> <view class="title">角色列表</view>
<view class="handle-option"> <view class="handle-option">
<u-button class="btn" size="medium" <u-button v-auth="['endpoint.admin_roles.create']" class="btn" size="medium"
@click="addBtn()" type="primary">新增</u-button> @click="addBtn()" type="primary">新增</u-button>
</view> </view>
</view> </view>
@ -82,8 +82,8 @@
<view class="popup-form-info"> <view class="popup-form-info">
<view class="top_box"> <view class="top_box">
<view class="handle-btns"> <view class="handle-btns">
<view class="btn_del" @click="deleteRoleId(info.id)"></view> <view v-auth="['endpoint.admin_roles.destroy']" class="btn_del" @click="deleteRoleId(info.id)"></view>
<view class="btn_edit" @click="editRoleId(info.id)"></view> <view v-auth="['endpoint.admin_roles.edit']" class="btn_edit" @click="editRoleId(info.id)"></view>
</view> </view>
</view> </view>
<view class="section_c"> <view class="section_c">
@ -106,6 +106,7 @@
<script> <script>
import DaTreeVue2 from '@/components/da-tree-vue2/index.vue' import DaTreeVue2 from '@/components/da-tree-vue2/index.vue'
import {showLoading,hideLoading} from '@/com/utils.js' import {showLoading,hideLoading} from '@/com/utils.js'
import checkPermission from '@/utils/permission.js'
export default { export default {
components: { DaTreeVue2 }, components: { DaTreeVue2 },
data() { data() {
@ -114,20 +115,6 @@
page:1, page:1,
rolelist:[], rolelist:[],
loading:'loadmore', loading:'loadmore',
options: [
{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#dd524d'
}
}
],
popupShow:false, popupShow:false,
info:{},// info:{},//
cindex:-1,// cindex:-1,//
@ -143,6 +130,28 @@
permissionsList:[], permissionsList:[],
defaultCheckedKeysValue: [], defaultCheckedKeysValue: [],
}; };
},
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.admin_roles.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.admin_roles.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
}, },
onLoad() { onLoad() {
this.queryAdminRoleList(); this.queryAdminRoleList();

View File

@ -40,16 +40,16 @@
<view class="arrow_R"></view> <view class="arrow_R"></view>
</view> </view>
</view> </view>
<view class="nav-list" @click="linnavF('/pages/system/role')"> <view v-auth="['endpoint.admin_roles.index']" class="nav-list" @click="linnavF('/pages/system/role')">
<view class="icon_img"> <view class="icon_img">
<u-icon name="man-add" size="46"></u-icon> <u-icon name="man-add" size="46"></u-icon>
</view> </view>
<view class="item-c"> <view class="item-c" >
<view class="tname">角色管理</view> <view class="tname">角色管理</view>
<view class="arrow_R"></view> <view class="arrow_R"></view>
</view> </view>
</view> </view>
<view class="nav-list" @click="linnavF('/pages/system/account')"> <view v-auth="['endpoint.admin_users.index']" class="nav-list" @click="linnavF('/pages/system/account')">
<view class="icon_img"> <view class="icon_img">
<u-icon name="account" size="46"></u-icon> <u-icon name="account" size="46"></u-icon>
</view> </view>
@ -58,7 +58,7 @@
<view class="arrow_R"></view> <view class="arrow_R"></view>
</view> </view>
</view> </view>
<view class="nav-list" @click="linnavF('/pages/system/log')"> <view v-auth="['endpoint.operation_log.index']" class="nav-list" @click="linnavF('/pages/system/log')">
<view class="icon_img"> <view class="icon_img">
<u-icon name="clock" size="46"></u-icon> <u-icon name="clock" size="46"></u-icon>
</view> </view>
@ -67,7 +67,7 @@
<view class="arrow_R"></view> <view class="arrow_R"></view>
</view> </view>
</view> </view>
<view class="nav-list" @click="linnavF('/pages/system/links')"> <view v-auth="['endpoint.friend_links.index']" class="nav-list" @click="linnavF('/pages/system/links')">
<view class="icon_img"> <view class="icon_img">
<u-icon name="attach" size="46"></u-icon> <u-icon name="attach" size="46"></u-icon>
</view> </view>

View File

@ -2,7 +2,7 @@
<view> <view>
<Appbar title="基地产量"> <Appbar title="基地产量">
<template #right> <template #right>
<view class="text-white mr-20px" @click="handleCreate"></view> <view v-auth="['endpoint.crops_output.create']" class="text-white mr-20px" @click="handleCreate"></view>
</template> </template>
</Appbar> </Appbar>
<u-sticky> <u-sticky>
@ -61,6 +61,8 @@
:data="currentData" :data="currentData"
@onEdit="handleEdit" @onEdit="handleEdit"
@onDel="handleDel" @onDel="handleDel"
:eidtAuth="['endpoint.crops_output.edit']"
:delAuth="['endpoint.crops_output.destroy']"
></BaseTablePopup> ></BaseTablePopup>
<!-- 编辑 --> <!-- 编辑 -->
<cuPopup v-model="formShow" :title="currentData ? '编辑产量' : '新增产量'"> <cuPopup v-model="formShow" :title="currentData ? '编辑产量' : '新增产量'">
@ -81,6 +83,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue' import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue' import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue' import BasicsEdit from './components/basics-edit.vue'
import checkPermission from '@/utils/permission.js'
const baseTableColums = [ const baseTableColums = [
{ {
title: '街镇名称', title: '街镇名称',
@ -147,22 +150,6 @@ export default {
}, },
}, },
dataList: [], dataList: [],
options: [
{
text: '编辑',
opt: 'edit',
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
style: {
backgroundColor: '#dd524d',
},
},
],
formShow: false, formShow: false,
baseShow: false, baseShow: false,
searchFormSchema: [ searchFormSchema: [
@ -203,6 +190,28 @@ export default {
], ],
} }
}, },
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.crops_output.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.crops_output.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
},
methods: { methods: {
handleSubmit(e) { handleSubmit(e) {
this.filterParmas = e this.filterParmas = e

View File

@ -2,7 +2,7 @@
<view> <view>
<Appbar title="城镇产量"> <Appbar title="城镇产量">
<template #right> <template #right>
<view class="text-white mr-20px" @click="handleCreate"></view> <view v-auth="['endpoint.town_crops_output.create']" class="text-white mr-20px" @click="handleCreate"></view>
</template> </template>
</Appbar> </Appbar>
<u-sticky> <u-sticky>
@ -61,6 +61,8 @@
:data="currentData" :data="currentData"
@onEdit="handleEdit" @onEdit="handleEdit"
@onDel="handleDel" @onDel="handleDel"
:eidtAuth="['endpoint.town_crops_output.edit']"
:delAuth="['endpoint.town_crops_output.destroy']"
></BaseTablePopup> ></BaseTablePopup>
<!-- 编辑 --> <!-- 编辑 -->
<cuPopup v-model="formShow" :title="currentData ? '编辑产量' : '新增产量'"> <cuPopup v-model="formShow" :title="currentData ? '编辑产量' : '新增产量'">
@ -80,6 +82,7 @@ import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/me
import cuPopup from '@/components/cu-popup/index.vue' import cuPopup from '@/components/cu-popup/index.vue'
import BaseTablePopup from '@/components/base-table/popup.vue' import BaseTablePopup from '@/components/base-table/popup.vue'
import BasicsEdit from './components/basics-edit.vue' import BasicsEdit from './components/basics-edit.vue'
import checkPermission from '@/utils/permission.js'
const baseTableColums = [ const baseTableColums = [
{ {
title: '街镇名称', title: '街镇名称',
@ -146,22 +149,7 @@ export default {
}, },
}, },
dataList: [], dataList: [],
options: [
{
text: '编辑',
opt: 'edit',
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
style: {
backgroundColor: '#dd524d',
},
},
],
formShow: false, formShow: false,
baseShow: false, baseShow: false,
searchFormSchema: [ searchFormSchema: [
@ -202,6 +190,28 @@ export default {
], ],
} }
}, },
computed: {
options() {
return [
{
text: '编辑',
opt: 'edit',
permission: ['endpoint.town_crops_output.edit'],
style: {
backgroundColor: '#007aff',
},
},
{
text: '删除',
opt: 'delete',
permission: ['endpoint.town_crops_output.destroy'],
style: {
backgroundColor: '#dd524d',
},
},
].filter((e) => checkPermission(e.permission))
},
},
methods: { methods: {
handleSubmit(e) { handleSubmit(e) {
this.filterParmas = e this.filterParmas = e

View File

@ -1,16 +1,36 @@
import * as types from "./mutation-types"; import * as types from "./mutation-types";
import {getStorageSync,setStorageSync,setStorage} from '@/com/utils.js' import { getStorageSync, setStorageSync, setStorage, clearStorageSync } from '@/com/utils.js'
import jwt from '@/api/jwt.js'
import { http } from '@/api/index.js'
const actions = { const actions = {
[types.USER_INFO]({commit},userInfo){ [types.USER_INFO]({ commit }, userInfo) {
let _data = {}; let _data = {};
if(userInfo&&userInfo.id){ if (userInfo) {
console.log(userInfo);
_data = userInfo; _data = userInfo;
// setStorage('userInfo',userInfo) // setStorage('userInfo',userInfo)
}else{ } else {
_data = getStorageSync('userInfo'); _data = getStorageSync('userInfo');
} }
commit(types.USER_INFO, _data); commit(types.USER_INFO, _data);
}, },
logout({ commit }) {
clearStorageSync()
jwt.clearAccessToken()
},
async getUserInfo({ commit, dispatch }, userInfo) {
try {
const { data } = await http.get('/api/users/info')
dispatch(types.USER_INFO, data.data)
} catch (error) {
dispatch('logout')
uni.reLaunch({
url:'/pages/login/login'
})
}
}
}; };
export default actions; export default actions;

View File

@ -17,11 +17,11 @@ const store = new Vuex.Store({
createPersistedState({ createPersistedState({
// 当state中的值发生变化的时候出发reduce函数 // 当state中的值发生变化的时候出发reduce函数
reducer(val) { reducer(val) {
console.log(val,'createPersistedState') // value值为当前state中的所有值对象 console.log(val, 'createPersistedState') // value值为当前state中的所有值对象
// return什么localstorage中的key值为vuex的value值就是什么而且是实时与state中的值保持同步 // return什么localstorage中的key值为vuex的value值就是什么而且是实时与state中的值保持同步
return { return {
userInfo: val.userInfo, userInfo: val.userInfo,
user_access_token:val.user_access_token user_access_token: val.user_access_token
} }
} }
}) })

View File

@ -0,0 +1,16 @@
import store from '@/store'
export default function checkPermission(value) {
if (value && value instanceof Array && value.length > 0) {
const roles = store.getters && (store.getters.userInfo?.permissions_slug ?? [])
const permissionRoles = value
const hasPermission = roles.some(role => {
return permissionRoles.includes(role)
})
return hasPermission
} else {
return false
}
}

21581
yarn.lock

File diff suppressed because it is too large Load Diff