增加管理制度

This commit is contained in:
caoqianming 2022-04-18 16:33:29 +08:00
parent 196e82bc95
commit 5eaf074413
10 changed files with 310 additions and 15 deletions

View File

@ -96,7 +96,8 @@
"pages/safelist/index",
"pages/safefeedback/index",
"pages/safefeedback/add",
"pages/operation/operationedit"
"pages/operation/operationedit",
"pages/mgt/index"
],
"window": {
"backgroundTextStyle": "light",

View File

@ -191,6 +191,11 @@ Page({
url = '/pages/safelist/index?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
else if(q.indexOf("mgt")!=-1){
let id = util.getQueryString(q, 'id')
url = '/pages/mgt/index?fromwx=1&id='+id
getApp().globalData.hopeUrl = url
}
}
}
if(getApp().globalData.sessionId){

View File

@ -84,19 +84,19 @@
</navigator>
</view>
</view>
<!-- <view class="weui-media-box weui-media-box_small-appmsg">
<view class="weui-media-box weui-media-box_small-appmsg">
<view class="weui-cells weui-cells_in-small-appmsg">
<navigator url="../operins/index" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
<navigator url="../mgt/index" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
<view class="weui-cell__hd">
<image src="../images/data.png" style="width: 20px;height: 20px;margin-right: 5px" />
</view>
<view class="weui-cell__bd weui-cell_primary">
<view>规章制度</view>
<view>管理制度</view>
</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</navigator>
</view>
</view> -->
</view>
</view>
</view>
</view>

195
pages/mgt/index.js Normal file
View File

@ -0,0 +1,195 @@
Page({
/**
* 页面的初始数据
*/
data: {
page: 1,
serverUrl: getApp().globalData.serverUrl,
datalist: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
that.onPullDownRefresh();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
var that = this;
that.getDatalist(1);
wx.stopPullDownRefresh();
this.data.page = 1;
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
//上拉分页,将页码加1然后调用分页函数
this.data.page = this.data.page + 1;
this.getDatalist();
wx.stopPullDownRefresh();
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
getDatalist: function (page, search = '') {
var that = this;
if (page != 1) { page = that.data.page }
wx.showLoading({
title: '加载中',
}),
wx.request({
url: this.data.serverUrl + 'mgt/api?a=listall&rows=10&page=' + page + '&search=' + search,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
if (res.statusCode === 200) {
if (res.data.rows.length == 0) {
if (page == 1) {
this.setData({
total: 0,
datalist: []
})
}
else {
wx.showModal({
content: "已经到底啦!",
showCancel: false,
confirmText: "确定",
})
}
} else {
let list
if (page == 1) {
list = res.data.rows
} else {
list = this.data.datalist.concat(res.data.rows)
}
this.setData({
total: res.data.total,
datalist: list
})
}
}
wx.hideLoading();
}
});
},
//搜索框文本内容显示
inputBind: function (event) {
this.setData({
inputValue: event.detail.value
})
},
query: function () {
this.page = 1
this.getDatalist(this.page, this.data.inputValue)
},
reset: function () {
this.page = 1
this.inputValue = ''
this.getDatalist(this.page)
},
openfj: function(e){
var that = this
let fileurl = getApp().globalData.serverUrl + e.currentTarget.dataset.operprocepath
wx.showLoading({
title: '正在下载...',
})
wx.request({
url: getApp().globalData.serverUrl + 'api/getprodata?a=readnum&id=' + e.currentTarget.dataset.id,
header: {
'content-type': 'application/json', // 默认值
'Cookie': getApp().globalData.sessionId,
},
success: res => {
}
});
wx.downloadFile({
url: fileurl,
success(res) {
wx.showLoading({
title: '成功,正在打开...',
})
const filePath = res.tempFilePath
var filetype
if (fileurl.indexOf(".docx") != -1) {
filetype = 'docx'
}
else if (fileurl.indexOf(".doc") != -1) {
filetype = 'doc'
}
else if (fileurl.indexOf(".xlsx") != -1) {
filetype = 'xlsx'
}
else if (fileurl.indexOf(".xls") != -1) {
filetype = 'xls'
}
else if (fileurl.indexOf(".pptx") != -1) {
filetype = 'pptx'
}
else if (fileurl.indexOf(".ppt") != -1) {
filetype = 'ppt'
}
else if (fileurl.indexOf(".pdf") != -1) {
filetype = 'pdf'
} else {
wx.hideLoading()
return
}
wx.openDocument({
filePath,
fileType: filetype,
success(res) {
wx.hideLoading()
console.log('打开文档成功')
}, fail: function (e) {
console.log(e)
}
})
}
})
}
})

5
pages/mgt/index.json Normal file
View File

@ -0,0 +1,5 @@
{
"enablePullDownRefresh": true,
"onReachBottomDistance": 50,
"navigationBarTitleText": "管理制度"
}

42
pages/mgt/index.wxml Normal file
View File

@ -0,0 +1,42 @@
<wxs src="../../wxs/subutil.wxs" module="tools" />
<view class="page__bd">
<view class="head">共{{total}}条管理制度</view>
<!-- <view class='search'>
<input type='text' placeholder='输入你想要的内容' confirm-type='search' value="{{inputValue}}" bindinput='inputBind' bindconfirm='query' style="flex: 1;"></input>
<view style="padding:2rpx">
<button type="primary" bindtap="query" >查询</button>
</view>
<view style="padding:2rpx">
<button type="primary" bindtap="reset" >重置</button>
</view>
</view> -->
<view class="weui-cells weui-cells_after-title" >
<block wx:for="{{datalist}}" wx:key="unique">
<view bindtap="openfj" data-operprocepath="{{item.mgtpath}}" data-id="{{item.id}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image wx:if="{{tools.indexOf(item.mgtpath)==1}}" class="weui-media-box__thumb" src="../images/mp4.svg"></image>
<image wx:elif="{{tools.indexOf(item.mgtpath)==2}}" class="weui-media-box__thumb" src="../images/word.svg"></image>
<image wx:elif="{{tools.indexOf(item.mgtpath)==3}}" class="weui-media-box__thumb" src="../images/ppt.svg"></image>
<image wx:elif="{{tools.indexOf(item.mgtpath)==4}}" class="weui-media-box__thumb" src="../images/pdf.svg"></image>
<image wx:elif="{{tools.indexOf(item.mgtpath)==5}}" class="weui-media-box__thumb" src="../images/excel.svg"></image>
<image wx:elif="{{tools.indexOf(item.mgtpath)==6}}" class="weui-media-box__thumb" src="../images/zip.svg"></image>
<image wx:else class="weui-media-box__thumb" src="../images/file.svg"></image>
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{item.mgtname}}</view>
<view class="weui-media-box__desc">{{item.mgtname}}</view>
<view class="weui-media-box__desc" wx:if="{{item.type__dickeyname}}"
style="color:orange"
>{{item.type__dickeyname}}</view>
</view>
<view class="weui-panel__ft weui-cell__ft_in-access">
<!-- <view class="weui-media-box__title">
<span >阅读量</span>
<span style="color:green;font-weight:bold"> {{item.reads}}</span>
</view> -->
</view>
</view>
</block>
</view>
</view>

31
pages/mgt/index.wxss Normal file
View File

@ -0,0 +1,31 @@
.weui-btn{
width:auto;
margin: 5px;
}
.container {
background-color: #fff;
color: #939393;
}
.head{
color:#fff;
background-color: cornflowerblue;
text-align: center;
}
.search
{
display: flex;
justify-content: flex-end;
align-items: center;
width:100%;
height:auto;
background-color:white;
border:2rpx solid goldenrod;
border-radius: 5rpx;
}
/* 搜索框提示文字样式 */
.search input
{
padding-left:30rpx;
}

View File

@ -14,7 +14,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
that.onPullDownRefresh();
},
/**
@ -28,8 +29,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
var that = this;
that.onPullDownRefresh();
},
/**

View File

@ -1,3 +1,4 @@
<wxs src="../../wxs/subutil.wxs" module="tools" />
<view class="page__bd">
<view class="head">共{{total}}条规程</view>
@ -14,12 +15,12 @@
<block wx:for="{{datalist}}" wx:key="unique">
<view bindtap="openfj" data-operprocepath="{{item.operprocepath}}" data-id="{{item.id}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image wx:if="{{item.type==1}}" class="weui-media-box__thumb" src="../images/mp4.svg"></image>
<image wx:elif="{{item.type==2}}" class="weui-media-box__thumb" src="../images/word.svg"></image>
<image wx:elif="{{item.type==3}}" class="weui-media-box__thumb" src="../images/ppt.svg"></image>
<image wx:elif="{{item.type==4}}" class="weui-media-box__thumb" src="../images/pdf.svg"></image>
<image wx:elif="{{item.type==5}}" class="weui-media-box__thumb" src="../images/excel.svg"></image>
<image wx:elif="{{item.type==6}}" class="weui-media-box__thumb" src="../images/zip.svg"></image>
<image wx:if="{{tools.indexOf(item.operprocepath)==1}}" class="weui-media-box__thumb" src="../images/mp4.svg"></image>
<image wx:elif="{{tools.indexOf(item.operprocepath)==2}}" class="weui-media-box__thumb" src="../images/word.svg"></image>
<image wx:elif="{{tools.indexOf(item.operprocepath)==3}}" class="weui-media-box__thumb" src="../images/ppt.svg"></image>
<image wx:elif="{{tools.indexOf(item.operprocepath)==4}}" class="weui-media-box__thumb" src="../images/pdf.svg"></image>
<image wx:elif="{{tools.indexOf(item.operprocepath)==5}}" class="weui-media-box__thumb" src="../images/excel.svg"></image>
<image wx:elif="{{tools.indexOf(item.operprocepath)==6}}" class="weui-media-box__thumb" src="../images/zip.svg"></image>
<image wx:else class="weui-media-box__thumb" src="../images/file.svg"></image>
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">

View File

@ -14,5 +14,20 @@ var subDate = function(val) {
}
return val.substring(0, 10);
}
function indexOf(val) {
if (val.indexOf(".doc") > 0 ||val.indexOf(".docx") > 0 ) {
return 2;
} else if(val.indexOf(".ppt") > 0 ||val.indexOf(".pptx") > 0 ) {
return 3;
} else if(val.indexOf(".pdf") > 0 ) {
return 4;
}else if(val.indexOf(".xls") > 0 ||val.indexOf(".xlsx") > 0 ) {
return 5;
}else{
return 7
}
}
module.exports.sub = sub;
module.exports.subDate = subDate;
module.exports.subDate = subDate;
module.exports.indexOf = indexOf;