billlist.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view class="uni-flex uni-column">
  3. <!--反馈日期范围控件组-->
  4. <view class="flex cu-bar bg-white solid-bottom margin-top">
  5. <view class="action">
  6. <text class="cuIcon-titles text-blue"></text>反馈日期
  7. </view>
  8. <!--dateRange()设置是否展示日期选择面板为true -->
  9. <view class="fkrq-range" @click="dateRange">
  10. <view class="padding-sm">{{range[0]}}</view>
  11. <view class="padding-sm">至</view>
  12. <view class="padding-sm">{{range[1]}}</view>
  13. </view>
  14. <!--日期面板,show显示方式-->
  15. <mx-date-picker :show="showPicker" type="range" format="yyyy-mm-dd" :value="value" @confirm="confirmDate" @cancel="cancelDate">
  16. </mx-date-picker>
  17. </view>
  18. <!--反馈类型复选框控件组-->
  19. <view class="cu-bar bg-white solid-bottom margin-top-sm">
  20. <view class="action">
  21. <text class="cuIcon-titles text-blue"></text>反馈类型
  22. </view>
  23. <!--multiple是否多选 -->
  24. <uni-data-checkbox mode="button" :multiple="true" v-model="fklx" :localdata="fklxs">
  25. </uni-data-checkbox>
  26. </view>
  27. <!--查询按钮及查询全部按钮-->
  28. <view class="padding-sm text-center querybtn margin-top-sm">
  29. <button class="btnflex round bg-blue" @click="search(0)">查询</button>
  30. <!-- v-if条件渲染,当条件为false时,不渲染该控件,因此界面中未显示 -->
  31. <button class="btnflex round bg-blue" v-if="isAllowQueryAll" @click="search(1)">查询全部</button>
  32. </view>
  33. <!--面料编码过滤框-->
  34. <view class="margin-top-sm">
  35. <!-- placeholder背景文字 -->
  36. <uni-search-bar class="search" v-model="searchValue" placeholder="面料编码" :radius="100" @confirm="searchBarEnter" @cancel="searchBarCancel"></uni-search-bar>
  37. </view>
  38. <!--筛选控件组,用于过滤有图无图的数据-->
  39. <view class="cu-bar bg-white solid-bottom margin-top-sm">
  40. <view class="action">
  41. <text class="cuIcon-titles text-blue"></text>筛选
  42. </view>
  43. <uni-data-checkbox mode="button" :multiple="false" v-model="filterImg" :localdata="filterImgs" @change="filterItemChange">
  44. </uni-data-checkbox>
  45. </view>
  46. <!--数据列表-->
  47. <view>
  48. <view class="example-body">
  49. <!-- 分页器 current当前页、total总页数、pageSize每页行数、@change点击左右箭头时 -->
  50. <uni-pagination :current="current" :total="total" :pageSize="pageSize" :show-icon="true" @change="change" />
  51. </view>
  52. <view class="text-center">总数据量:{{total}}</view>
  53. <uni-list>
  54. <!-- 列表项目 title标题列、note第二行内容、show-badge是否显示角标、badge-text角标内容,当前面料有反馈照片时显示照片数量、clickable表示该列表可点击 -->
  55. <uni-list-item v-for="(bill,index) in list" v-if="index >= (current-1)*pageSize && index < current*pageSize" :title="'面料编码:'+bill.ynDyeFabCode" :note="getNote(bill)" :show-badge="bill.imgCount>0" :badge-text="bill.imgCount+''" :showArrow="true" clickable @click="toDetailPage(bill)">
  56. </uni-list-item>
  57. </uni-list>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. showPicker: false, //控制日期选择面板是否显示
  66. range: [], //页面显示的反馈日期范围
  67. value: [], //反馈日期的控件值
  68. isQueyAll: 0, //是否查询全部,0:查询个人单据;1:查询全部单据,默认为0,即查询个人单据
  69. isAllowEdit: false, //编辑权限,用于设置是否允许用户上传图片
  70. isAllowQueryAll: false, //查询全部按钮权限
  71. list: [], //界面数据
  72. allBills: [], //数据库中取出的所有数据,经过滤后成为List
  73. searchValue: '', //面料编码过滤框内容
  74. fklx: ['YS', 'WG', 'JH'], //反馈类型复选框默认值
  75. fklxs: [{ //反馈类型复选框绑定的数据源
  76. "value": "YS",
  77. "text": "颜色"
  78. },
  79. {
  80. "value": "WG",
  81. "text": "外观"
  82. },
  83. {
  84. "value": "JH",
  85. "text": "计划"
  86. }
  87. ],
  88. filterImg: 'ALL', //筛选单选框默认值
  89. filterImgs: [{ //筛选单选框绑定的数据源
  90. "value": "ALL",
  91. "text": "全部"
  92. },
  93. {
  94. "value": "HAVE",
  95. "text": "有图"
  96. },
  97. {
  98. "value": "NONE",
  99. "text": "无图"
  100. }
  101. ],
  102. current: 1, //当前页
  103. total: 0, //总页数
  104. pageSize: 5, //每页行数
  105. }
  106. },
  107. onLoad(param) {
  108. //若加载页面时未提供参数,则默认查询个人反馈单据;否则,根据参数查询相应反馈单据
  109. if (Object.keys(param).length > 0) {
  110. var paramData = JSON.parse(param.paramData);
  111. this.isQueyAll = paramData.isQueryAll;
  112. this.value = this.range = paramData.dateRange;
  113. this.fklx = paramData.fklx;
  114. } else {
  115. //加载页面时,设置默认的日期范围
  116. var currDate = new Date();
  117. var currYear = currDate.getFullYear();
  118. var currMonth = currDate.getMonth() + 1; //getMonth() 返回0-11
  119. if (currMonth < 10) {
  120. currMonth = '0' + currMonth
  121. }
  122. var currDay = currDate.getDate(); //getDate():获取一月的某一天;getDay():获取星期几
  123. if (currDay < 10) {
  124. currDay = '0' + currDay
  125. }
  126. var defalutDate = currYear + "-" + currMonth + "-" + currDay;
  127. this.value = this.range = [defalutDate, defalutDate]; //默认查询当天的单据
  128. }
  129. //添加请求拦截器
  130. var vm = this
  131. uni.getStorage({
  132. key: 'token',
  133. success: function(res) {
  134. //请求拦截器
  135. uni.addInterceptor('request', {
  136. invoke(args) {
  137. args.header = {
  138. 'token': res.data
  139. }
  140. }
  141. })
  142. //访问网络获取权限
  143. uni.request({
  144. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/checkPermission',
  145. success: (res) => {
  146. if (res.data.code == 0) {
  147. vm.isAllowQueryAll = res.data.data.QueryAll;
  148. vm.isAllowEdit = res.data.data.EditRight;
  149. //根据反馈日期、反馈类型及是否查询全部获取反馈单据
  150. vm.search(vm.isQueyAll);
  151. } else if (res.data.code == 101) { //未登录
  152. //清空token缓存
  153. uni.removeStorage({
  154. key: 'token',
  155. success: function(res) {
  156. //从redis缓存中未获取到token失败时跳转登录界面
  157. uni.navigateTo({
  158. url: '../login/login?isback=1'
  159. })
  160. },
  161. fail() {
  162. //从清空token缓存失败时提示
  163. uni.showToast({
  164. title: '登录已过期时,清空token缓存失败!',
  165. icon: 'none'
  166. })
  167. }
  168. });
  169. } else {
  170. //弹出提示
  171. uni.showToast({
  172. title: '获取权限失败!原因是:' + res.data.msg,
  173. icon: 'none'
  174. })
  175. }
  176. },
  177. fail: (res) => {
  178. uni.showToast({
  179. title: '访问网络检查权限失败!原因是:' + res.errMsg,
  180. icon: 'none'
  181. })
  182. }
  183. });
  184. },
  185. fail() {
  186. //从缓存中未获取到token失败时跳转登录界面
  187. uni.navigateTo({
  188. url: '../login/login?isback=1'
  189. })
  190. }
  191. });
  192. },
  193. onBackPress(e) {
  194. //返回菜单页面
  195. uni.navigateTo({
  196. url: '../menu/menu'
  197. })
  198. return true
  199. },
  200. methods: {
  201. //反馈日期选择面板相关控制
  202. dateRange() {
  203. this.showPicker = true; //显示日期选择控件
  204. this.value = this.range;
  205. },
  206. confirmDate(e) {
  207. this.showPicker = false; //隐藏日期选择控件
  208. this.value = this.range = e.value;
  209. },
  210. cancelDate() {
  211. this.showPicker = false; //隐藏日期选择控件
  212. },
  213. //获取列表项的note属性值
  214. getNote(bill) {
  215. return '反馈日期:' + bill.fkrq + '\n反馈类型:' + bill.fklx + '\n通报标记:' + bill.fktbbj + '\n客户名称:' + bill.khmc + '\n统计米:' + bill.tjslm + '\n颜色米:' + bill.tjsly + '\n反馈原因:' + bill.fkyy + '\n反馈人:' + bill.fkr + '\n验装结论:' + bill.yzgccljl + '\n品管最终结论:' + bill.pgbzzcljl
  216. },
  217. /* 查询按钮点击方法 */
  218. search(isAll) {
  219. //记录是查询个人反馈单据还是查询全部反馈单据
  220. this.isQueyAll = isAll;
  221. //拼接反馈类型
  222. var fklxStr = ''
  223. for (let v of this.fklx) {
  224. fklxStr += v + ','
  225. }
  226. fklxStr = fklxStr.length > 0 ? fklxStr.substring(0, fklxStr.length - 1) : fklxStr
  227. //访问网络获取反馈单据列表
  228. uni.request({
  229. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/getData',
  230. data: {
  231. startDate: this.value[0],
  232. endDate: this.value[1],
  233. fklx: fklxStr,
  234. isSearchAll: this.isQueyAll,
  235. },
  236. success: (res) => {
  237. //获取数据成功后,界面绑定数据
  238. if (res.data.code == 0) {
  239. this.allBills = res.data.data;
  240. var vm = this;
  241. this.list = this.allBills.filter(item => {
  242. var flag = vm.filterImg == 'ALL' ? true : vm.filterImg == 'HAVE' ? item.imgCount > 0 : item.imgCount == 0;
  243. return item.ynDyeFabCode.indexOf(vm.searchValue) > -1 && flag;
  244. });
  245. this.total = this.list.length;
  246. this.current = 1;
  247. } else if (res.data.code == 101) { //未登录
  248. //清空token缓存
  249. uni.removeStorage({
  250. key: 'token',
  251. success: function(res) {
  252. //从redis缓存中未获取到token失败时跳转登录界面
  253. uni.navigateTo({
  254. url: '../login/login?isback=1'
  255. })
  256. },
  257. fail() {
  258. //从清空token缓存失败时提示
  259. uni.showToast({
  260. title: '登录已过期时,清空token缓存失败!',
  261. icon: 'none'
  262. })
  263. }
  264. });
  265. } else {
  266. //弹出提示
  267. uni.showToast({
  268. title: '获取质量反馈单据列表失败!原因是:' + res.data.msg,
  269. icon: 'none'
  270. })
  271. }
  272. },
  273. fail: (res) => {
  274. uni.showToast({
  275. title: '访问网络获取质量反馈单据列表失败!原因是:' + res.errMsg,
  276. icon: 'none'
  277. })
  278. }
  279. });
  280. },
  281. /* 面料编码控件过滤方法 */
  282. searchBarEnter() {
  283. //若列表单据为空时,直接返回
  284. if (this.allBills.length == 0) return
  285. //根据面料编码模糊查询,并筛选数据(全部、有图、无图)
  286. this.list = this.allBills.filter(item => {
  287. var flag = this.filterImg == 'ALL' ? true : this.filterImg == 'HAVE' ? item.imgCount > 0 : item.imgCount == 0;
  288. return item.ynDyeFabCode.indexOf(this.searchValue) > -1 && flag;
  289. });
  290. this.total = this.list.length;
  291. this.current = 1;
  292. },
  293. /* 面料编码控件取消按钮方法 */
  294. searchBarCancel() {
  295. //列表数据已过滤时,若取消过滤,则列表展示全部单据
  296. if (this.allBills.length > 0) {
  297. if (this.filterImg == 'ALL') {
  298. this.list = this.allBills;
  299. } else if (this.filterImg == 'HAVE') {
  300. this.list = this.allBills.filter(item => {
  301. return item.imgCount > 0
  302. })
  303. } else {
  304. this.list = this.allBills.filter(item => {
  305. return item.imgCount == 0
  306. })
  307. }
  308. this.total = this.list.length;
  309. this.current = 1;
  310. }
  311. },
  312. /* 跳转至明细页面方法 */
  313. toDetailPage(bill) {
  314. //点击列表中某一单据,跳转至明细页面查询单据详情
  315. let billData = JSON.stringify(bill); //JSON.stringify() 方法用于将 JavaScript 值转换为 JSON 字符串
  316. var json = {
  317. "isQueryAll": this.isQueyAll,
  318. "dateRange": this.value,
  319. "fklx": this.fklx
  320. }
  321. let paramData = JSON.stringify(json)
  322. billData = encodeURIComponent(billData) //数据中可能包括?、&这些特殊符号,需要通过encodeURIComponent编码
  323. uni.navigateTo({
  324. url: '../detail/detail?billData=' + billData + '&isAllowEdit=' + this.isAllowEdit + '&paramData=' + paramData
  325. });
  326. },
  327. change(e) {
  328. //切换单据列表的当前页面
  329. this.current = e.current;
  330. },
  331. /* 筛选控件切换方法 */
  332. filterItemChange() {
  333. //若列表单据为空时,直接返回
  334. if (this.allBills.length == 0) return
  335. //根据面料编码模糊查询,并筛选数据(全部、有图、无图)
  336. this.list = this.allBills.filter(item => {
  337. var flag = this.filterImg == 'ALL' ? true : this.filterImg == 'HAVE' ? item.imgCount > 0 : item.imgCount == 0;
  338. return item.ynDyeFabCode.indexOf(this.searchValue) > -1 && flag;
  339. });
  340. this.total = this.list.length;
  341. this.current = 1;
  342. }
  343. }
  344. }
  345. </script>
  346. <style>
  347. .fkrq-range {
  348. display: flex;
  349. flex-direction: row;
  350. flex: 1;
  351. justify-content: center;
  352. align-items: center;
  353. font-size: large;
  354. }
  355. .search {
  356. font-size: 20px;
  357. background-color: #ffffff;
  358. }
  359. .querybtn {
  360. display: flex;
  361. flex-direction: row;
  362. justify-content: center;
  363. align-items: center;
  364. flex-wrap: nowrap;
  365. background-color: #ffffff;
  366. }
  367. .btnflex {
  368. flex: 1;
  369. padding: 0 40upx;
  370. font-size: 32upx;
  371. height: 80upx;
  372. margin: 5upx;
  373. }
  374. </style>