| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- // packagePersonnel/pages/parkStaff/parkStaff.js
- const app = getApp();
- var startPoint;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- listData: [], // 人员数据
- parkList: [], //公园列表
- array: [], //公园名字列表
- index: 0, //当前公园下标
- current: 1,
- size: 15,
- parkId: '', // 公园id
- parkName: '', // 公园名称
- workTypeList: [], //工种列表
- array1: [], //工种名字列表
- index1: null, //当前工种 下标
- // 公园 权限
- iSdisabled: false,
- flag: true,
- Scaling: false, // 筛选框
- userName: null, // 姓名
- fdyname: null, //职务
- fYhcompanyid: null,
- },
- bindPickerChange: function (e) {
- this.setData({
- listData: [],
- current: 1,
- flag: true,
- });
- // ////console.log("picker发送选择改变,携带值为", this.data.array[e.detail.value])
- let obj = this.data.parkList.find((v) => {
- return v.fParkname == this.data.array[e.detail.value];
- });
- let parkId = obj.fParkid;
- let parkName = obj.fParkname;
- this.setData({
- index: e.detail.value,
- parkId: parkId,
- parkName: parkName,
- });
- ////console.log("公园id", parkId)
- // 获得当前 公园 人员列表
- this.getInfoById(parkId);
- // let data1 = {
- // fDictionaryFlag: "POSITIONTYPE",
- // }
- // app.getDictionaries(data1, (res) => {
- // ////console.log("res", res)
- // })
- },
- // 点击新增按钮
- buttontap(e) {
- let id = this.data.parkId;
- let name = this.data.parkName;
- wx.navigateTo({
- url: `/packagePersonnel/pages/personAdd/personAdd?id=${id}&name=${name}&fYhcompanyid=${this.data.fYhcompanyid}`,
- });
- },
- // 公园接口----------------start
- getAllParkData() {
- var that = this;
- let url =
- app.globalData.httpsUrlServer + '/parkInfoApp/selectAppParkInfoList';
- app.getReq(url, (res) => {
- ////console.log("res", res)
- if (res.status == 200) {
- that.setData({
- parkList: res.data,
- });
- let arr = that.data.parkList.map((v) => {
- return v.fParkname;
- });
- // ////console.log("公园名字列表", arr)
- that.setData({
- array: arr,
- });
- let obj = that.data.parkList.find((v) => {
- return v.fParkname == that.data.array[that.data.index];
- });
- let parkId = obj.fParkid;
- let parkName = obj.fParkname;
- ////console.log("养护oid", obj)
- that.setData({
- parkId: parkId,
- parkName: parkName,
- fYhcompanyid: obj.fYhcompanyid,
- });
- that.getInfoById(parkId);
- }
- });
- },
- // 获得 所有 工种接口
- getInfoGZ() {
- let that = this;
- let data = {
- fDictionaryflag: 'POSITIONTYPE',
- };
- app.getDictionaries(data, (res) => {
- ////console.log("所有工种", res)
- if (res.status == 200) {
- that.setData({
- workTypeList: res.data,
- });
- ////console.log("所有工种", that.data.workTypeList)
- let arr = that.data.workTypeList.map((item) => {
- return item.fName;
- });
- that.setData({
- array1: arr,
- });
- ////console.log("array", that.data.array1)
- }
- });
- },
- // 修改 查看
- nav(e) {
- ////console.log("e", e)
- var info = JSON.stringify(e.currentTarget.dataset.val);
- ////console.log(info)
- wx.navigateTo({
- url: `/packagePersonnel/pages/personInfo/personInfo?info=${info}`,
- });
- },
- // 删除
- remove(e) {
- ////console.log("e", e.currentTarget.dataset.val)
- let data = e.currentTarget.dataset.val;
- var that = this;
- ////console.log()
- wx.showModal({
- title: '温馨提示',
- content: '确定要删除该成员吗',
- success(res) {
- if (res.confirm) {
- ////console.log("删除")
- let url =
- app.globalData.httpsUrlServer +
- '/baseemployeeinfo/deleteEmployeeinfo';
- app.postReq(url, data, (res) => {
- ////console.log("res", res)
- if (res.status == 200) {
- that.setData({
- listData: [],
- current: 1,
- flag: true,
- });
- that.getInfoById(that.data.parkId);
- } else {
- return app.toast(res.message);
- }
- });
- ////console.log("用户点击确定")
- } else if (res.cancel) {
- ////console.log("用户点击取消")
- }
- },
- });
- },
- // 通过 公园Id 获得 所有人员
- getInfoById(parkId) {
- wx.showLoading({
- title: '加载中',
- });
- let that = this;
- let url =
- app.globalData.httpsUrlServer +
- '/baseemployeeinfo/selectEmployeeinfoByPageList';
- let data = {
- fParkid: parkId,
- current: this.data.current,
- size: this.data.size,
- };
- app.postReq(url, data, (res) => {
- ////console.log("res", res)
- if (res.status == 200) {
- const { data } = res.data;
- if (data.length < 15) {
- that.setData({
- flag: false,
- });
- }
- this.setData({
- listData: [...that.data.listData, ...data],
- });
- wx.hideLoading();
- }
- });
- },
- // 拨打电话
- freeTell(e) {
- let phoneNumber = e.currentTarget.dataset.num;
- wx.makePhoneCall({
- phoneNumber: phoneNumber,
- });
- },
- // 显示筛选框
- showScaling() {
- this.setData({
- Scaling: true,
- });
- },
- // 关闭筛选框
- close() {
- this.setData({
- Scaling: false,
- });
- },
- // 筛选工种
- bindPickerChange1(e) {
- this.setData({
- index1: e.detail.value,
- });
- let name = this.data.array1[this.data.index1];
- let obj = this.data.workTypeList.find((v) => {
- return v.fName == name;
- });
- this.setData({
- fValuecode: obj.fValuecode,
- });
- ////console.log("obj", obj.fValuecode)
- },
- // 筛选姓名
- IptuserName(e) {
- this.setData({
- userName: e.detail.value,
- });
- },
- // 筛选职务
- Iptfdyname(e) {
- this.setData({
- fdyname: e.detail.value,
- });
- },
- // 重置筛选
- czScaling() {
- this.setData({
- index1: null,
- userName: null,
- fValuecode: null,
- fdyname: null,
- });
- },
- // 确定筛选
- qdScaling() {
- if (!this.data.fValuecode && !this.data.userName && !this.data.fdyname) {
- this.setData({
- current: 1,
- listData: [],
- });
- this.getInfoById(this.data.parkId);
- this.setData({
- Scaling: false,
- });
- return;
- }
- wx.showLoading({
- title: '加载中',
- });
- let that = this;
- let url =
- app.globalData.httpsUrlServer +
- '/baseemployeeinfo/selectEmployeeinfoByPageList';
- let data = {
- current: 1,
- size: 10000,
- fParkid: this.data.parkId, // 公园id
- fExpand4: this.data.fValuecode, // 工种id
- fRealname: this.data.userName, // 人员名称
- fDuty: this.data.fdyname, // 职务
- };
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- let { data } = res.data;
- that.setData({
- listData: data,
- Scaling: false,
- });
- wx.hideLoading();
- }
- ////console.log("res", res)
- });
- },
- //所有公园-----------------end
- onLoad: function (options) {
- var that = this;
- let position = wx.getStorageSync('position');
- this.getInfoGZ(); // 获取所有工种留做筛选
- // if (position == '中心') {
- this.setData({
- iSdisabled: true,
- });
- this.getAllParkData(); // 获取公园数据
- // return;
- // }
- /* 判断是否是中心人员 还是园长 */
- let url =
- app.globalData.httpsUrlServer +
- '/sysuseraccount/selectEmployeeinfoByUserId';
- app.getReq(url, (res) => {
- ////console.log("res", res)
- if (res.status == 200) {
- if (res.data == null) {
- // 没有data 是中心人员
- that.setData({
- iSdisabled: true,
- });
- } else {
- // 没有公园id 是中心人员
- if (!res.data.fParkid) {
- that.setData({
- iSdisabled: true,
- });
- } else {
- console.log('res', res);
- // ////console.log(that.data.array)
- that.setData({
- parkId: res.data.fParkid,
- parkName: res.data.fNativeplace,
- iSdisabled: false,
- fYhcompanyid: res.data.fYhcompanyid,
- });
- ////console.log(that.data.parkId)
- that.getInfoById(that.data.parkId);
- return;
- }
- }
- } else {
- ////console.log("请求失败")
- }
- });
- },
- onReady: function () {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function (e) {
- if (e == 'toast') {
- app.toast('保存成功');
- }
- this.setData({
- listData: [],
- current: 1,
- flag: true,
- });
- this.getInfoById(this.data.parkId);
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- ////console.log("触底")
- this.setData({
- current: this.data.current + 1,
- });
- if (this.data.flag) {
- this.getInfoById(this.data.parkId);
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {},
- });
|