billlist.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="uni-flex uni-column">
  3. <view class="flex cu-bar bg-white solid-bottom margin-top">
  4. <view class="action">
  5. <text class="cuIcon-titles text-blue"></text>反馈日期
  6. </view>
  7. <view class="fkrq-range" @click="dateRange">
  8. <view class="padding-sm">{{range[0]}}</view>
  9. <view class="padding-sm">至</view>
  10. <view class="padding-sm">{{range[1]}}</view>
  11. </view>
  12. <mx-date-picker :show="showPicker" type="range" format="yyyy-mm-dd" :value="value" @confirm="confirmDate" @cancel="cancelDate">
  13. </mx-date-picker>
  14. </view>
  15. <view class="cu-bar bg-white solid-bottom margin-top-sm">
  16. <view class="action">
  17. <text class="cuIcon-titles text-blue"></text>反馈类型
  18. </view>
  19. <uni-data-checkbox mode="button" :multiple="true" v-model="fklx" :localdata="fklxs">
  20. </uni-data-checkbox>
  21. </view>
  22. <view class="padding-sm text-center querybtn margin-top-sm">
  23. <button class="btnflex round bg-blue" @click="search(0)">查询</button>
  24. <button class="btnflex round bg-blue" v-if="isAllowQueryAll" @click="search(1)">查询全部</button>
  25. </view>
  26. <view class="margin-top-sm">
  27. <uni-search-bar class="search" v-model="searchValue" placeholder="面料编码" :radius="100" @confirm="searchBarEnter" @cancel="searchBarCancel"></uni-search-bar>
  28. </view>
  29. <view>
  30. <view class="example-body">
  31. <uni-pagination :current="current" :total="total" :pageSize="pageSize" :show-icon="true" @change="change" />
  32. </view>
  33. <uni-list>
  34. <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)">
  35. </uni-list-item>
  36. </uni-list>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. showPicker: false,
  45. range: [], //页面显示的反馈日期范围
  46. value: [], //反馈日期的控件值
  47. isQueyAll: 0, //是否查询全部,0:查询个人单据;1:查询全部单据,默认为0,即查询个人单据
  48. isAllowEdit: false,
  49. isAllowQueryAll: false,
  50. list: [],
  51. allBills: [],
  52. searchValue: '',
  53. fklx: ['YS', 'WG', 'JH'],
  54. fklxs: [{
  55. "value": "YS",
  56. "text": "颜色"
  57. },
  58. {
  59. "value": "WG",
  60. "text": "外观"
  61. },
  62. {
  63. "value": "JH",
  64. "text": "计划"
  65. }
  66. ],
  67. current: 1,
  68. total: 0,
  69. pageSize: 5,
  70. }
  71. },
  72. onLoad(param) {
  73. //若加载页面时未提供参数,则默认查询个人反馈单据;否则,根据参数查询相应反馈单据
  74. if (Object.keys(param).length > 0) {
  75. var paramData = JSON.parse(param.paramData);
  76. this.isQueyAll = paramData.isQueryAll;
  77. this.value = this.range = paramData.dateRange;
  78. this.fklx = paramData.fklx;
  79. } else {
  80. //加载页面时,设置默认的日期范围
  81. var currDate = new Date();
  82. var currYear = currDate.getFullYear();
  83. var currMonth = currDate.getMonth() + 1; //getMonth() 返回0-11
  84. if (currMonth < 10) {
  85. currMonth = '0' + currMonth
  86. }
  87. var currDay = currDate.getDate(); //getDate():获取一月的某一天;getDay():获取星期几
  88. if (currDay < 10) {
  89. currDay = '0' + currDay
  90. }
  91. var defalutDate = currYear + "-" + currMonth + "-" + currDay;
  92. this.value = this.range = [defalutDate, defalutDate]; //默认查询当天的单据
  93. }
  94. //添加请求拦截器
  95. var vm = this
  96. uni.getStorage({
  97. key: 'token',
  98. success: function(res) {
  99. //请求拦截器
  100. uni.addInterceptor('request', {
  101. invoke(args) {
  102. args.header = {
  103. 'token': res.data
  104. }
  105. }
  106. })
  107. //访问网络获取权限
  108. uni.request({
  109. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/checkPermission',
  110. success: (res) => {
  111. if (res.data.code == 0) {
  112. vm.isAllowQueryAll = res.data.data.QueryAll;
  113. vm.isAllowEdit = res.data.data.EditRight;
  114. //根据反馈日期、反馈类型及是否查询全部获取反馈单据
  115. vm.search(vm.isQueyAll);
  116. } else {
  117. //弹出提示
  118. uni.showToast({
  119. title: '获取权限失败!原因是:' + res.data.msg,
  120. icon: 'none'
  121. })
  122. }
  123. },
  124. fail: (res) => {
  125. uni.showToast({
  126. title: '访问网络检查权限失败!原因是:' + res.errMsg,
  127. icon: 'none'
  128. })
  129. }
  130. });
  131. },
  132. fail() {
  133. //从缓存中未获取到token失败时跳转登录界面
  134. uni.navigateTo({
  135. url: '../login/login?isback=1'
  136. })
  137. }
  138. });
  139. },
  140. onBackPress(e) {
  141. //返回菜单页面
  142. uni.navigateTo({
  143. url: '../menu/menu'
  144. })
  145. return true
  146. },
  147. methods: {
  148. dateRange() {
  149. this.showPicker = true; //显示日期选择控件
  150. this.value = this.range;
  151. },
  152. confirmDate(e) {
  153. this.showPicker = false; //隐藏日期选择控件
  154. this.value = this.range = e.value;
  155. },
  156. cancelDate() {
  157. this.showPicker = false; //隐藏日期选择控件
  158. },
  159. //获取列表项的note属性值
  160. getNote(bill) {
  161. 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
  162. },
  163. search(isAll) {
  164. //记录是查询个人反馈单据还是查询全部反馈单据
  165. this.isQueyAll = isAll
  166. //拼接反馈类型
  167. var fklxStr = ''
  168. for (let v of this.fklx) {
  169. fklxStr += v + ','
  170. }
  171. fklxStr = fklxStr.length > 0 ? fklxStr.substring(0, fklxStr.length - 1) : fklxStr
  172. //访问网络获取反馈单据列表
  173. uni.request({
  174. url: 'https://api.lttc.cn/mes/yzcj/qualityFeedback/getData',
  175. data: {
  176. startDate: this.value[0],
  177. endDate: this.value[1],
  178. fklx: fklxStr,
  179. isSearchAll: this.isQueyAll,
  180. },
  181. success: (res) => {
  182. //获取数据成功后,界面绑定数据
  183. if (res.data.code == 0) {
  184. this.list = this.allBills = res.data.data;
  185. this.total = this.list.length;
  186. this.current = 1;
  187. } else {
  188. //弹出提示
  189. uni.showToast({
  190. title: '获取质量反馈单据列表失败!原因是:' + res.data.msg,
  191. icon: 'none'
  192. })
  193. }
  194. },
  195. fail: (res) => {
  196. uni.showToast({
  197. title: '访问网络获取质量反馈单据列表失败!原因是:' + res.errMsg,
  198. icon: 'none'
  199. })
  200. }
  201. });
  202. },
  203. searchBarEnter() {
  204. //若列表单据为空时,直接返回
  205. if (this.allBills.length == 0) return
  206. //未设置过滤条件时,列表显示全部数据
  207. if (this.searchValue == '') {
  208. this.list = this.allBills;
  209. this.total = this.list.length;
  210. this.current = 1;
  211. return;
  212. }
  213. //根据面料编码模糊查询
  214. this.list = this.allBills.filter(item => {
  215. return item.ynDyeFabCode.indexOf(this.searchValue) > -1;
  216. });
  217. this.total = this.list.length;
  218. this.current = 1;
  219. },
  220. searchBarCancel() {
  221. //列表数据已过滤时,若取消过滤,则列表展示全部单据
  222. if (this.allBills.length > 0) {
  223. this.list = this.allBills;
  224. this.total = this.list.length;
  225. this.current = 1;
  226. }
  227. },
  228. toDetailPage(bill) {
  229. //点击列表中某一单据,跳转至明细页面查询单据详情
  230. let billData = JSON.stringify(bill);
  231. var json = {
  232. "isQueryAll": this.isQueyAll,
  233. "dateRange": this.value,
  234. "fklx": this.fklx
  235. }
  236. let paramData = JSON.stringify(json)
  237. uni.navigateTo({
  238. url: '../detail/detail?billData=' + billData + '&isAllowEdit=' + this.isAllowEdit + '&paramData=' + paramData
  239. });
  240. },
  241. change(e) {
  242. //切换单据列表的当前页面
  243. this.current = e.current;
  244. },
  245. }
  246. }
  247. </script>
  248. <style>
  249. .fkrq-range {
  250. display: flex;
  251. flex-direction: row;
  252. flex: 1;
  253. justify-content: center;
  254. align-items: center;
  255. font-size: large;
  256. }
  257. .search {
  258. font-size: 20px;
  259. background-color: #ffffff;
  260. }
  261. .querybtn {
  262. display: flex;
  263. flex-direction: row;
  264. justify-content: center;
  265. align-items: center;
  266. flex-wrap: nowrap;
  267. background-color: #ffffff;
  268. }
  269. .btnflex {
  270. flex: 1;
  271. padding: 0 40upx;
  272. font-size: 32upx;
  273. height: 80upx;
  274. margin: 5upx;
  275. }
  276. </style>