index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.good_name" @input="toInput" placeholder="搜索商品">
  5. </view>
  6. <view class="two">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  8. <view class="list-scroll-view">
  9. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  10. <view class="list_1">
  11. <text>
  12. <text class="iconfont icon-changshangguanli"></text>
  13. {{item.supplier_name}}
  14. </text>
  15. <text class="status">{{item.zhStatus}}</text>
  16. </view>
  17. <view class="list_2">
  18. <view class="left">
  19. <image v-if="item.spec_file" class="image" :src="item.spec_file?item.spec_file.url:''"
  20. mode="">
  21. </image>
  22. <image v-else class="image" :src="item.good_file?item.good_file.url:''" mode="">
  23. </image>
  24. </view>
  25. <view class="right">
  26. <view class="right_1">
  27. <view class="name textOver">
  28. <text>{{item.good_name||'暂无'}}</text>
  29. </view>
  30. <view class="num">
  31. <text>¥{{item.total_money||'0'}}</text>
  32. <text>×{{item.num||'0'}}</text>
  33. </view>
  34. </view>
  35. <view class="right_2">
  36. <view class="spec textOver">
  37. <text>规格:</text>
  38. <text>{{item.spec_name||'暂无'}}</text>
  39. </view>
  40. <view class="spec textOver">
  41. <text>购买用户:</text>
  42. <text>{{item.user_name||'暂无'}}</text>
  43. </view>
  44. <view class="spec textOver">
  45. <text>用户角色:</text>
  46. <text>{{item.zhRole||'暂无'}}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="bottom">
  52. <button size="mini" type="default" @tap.stop="toExam(item,'0')">审批通过</button>
  53. <button size="mini" type="warn" @tap.stop="toExam(item,'1')">审批拒绝</button>
  54. </view>
  55. </view>
  56. <view class="is_bottom" v-if="is_bottom">
  57. <text>{{config.bottom_title}}</text>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. // 系统设置
  69. config: {},
  70. user: {},
  71. searchInfo: {},
  72. list: [],
  73. total: 0,
  74. skip: 0,
  75. limit: 6,
  76. page: 0,
  77. // 数据是否触底
  78. is_bottom: false,
  79. scrollTop: 0,
  80. // 字典表
  81. statusList: [],
  82. roleList: []
  83. }
  84. },
  85. onLoad: function(e) {
  86. const that = this;
  87. that.searchConfig();
  88. },
  89. onShow: async function(e) {
  90. const that = this;
  91. await that.searchOther();
  92. that.searchToken();
  93. },
  94. onPullDownRefresh: async function() {
  95. const that = this;
  96. that.clearPage();
  97. await that.search();
  98. uni.stopPullDownRefresh();
  99. },
  100. methods: {
  101. searchConfig() {
  102. const that = this;
  103. try {
  104. const res = uni.getStorageSync('config');
  105. if (res) that.$set(that, `config`, res);
  106. } catch (e) {
  107. uni.showToast({
  108. title: err.errmsg,
  109. icon: 'error',
  110. duration: 2000
  111. });
  112. }
  113. },
  114. searchToken() {
  115. const that = this;
  116. try {
  117. const res = uni.getStorageSync('token');
  118. if (res) {
  119. that.$set(that, `user`, res);
  120. that.clearPage();
  121. that.search();
  122. }
  123. } catch (e) {
  124. uni.showToast({
  125. title: err.errmsg,
  126. icon: 'error',
  127. duration: 2000
  128. });
  129. }
  130. },
  131. async search() {
  132. const that = this;
  133. let user = that.user;
  134. let info = {
  135. skip: that.skip,
  136. limit: that.limit,
  137. user: user._id
  138. };
  139. let res;
  140. res = await that.$api(`/Upkeep`, 'GET', {
  141. ...info,
  142. ...that.searchInfo
  143. });
  144. if (res.errcode == '0') {
  145. let list = [...that.list, ...res.data];
  146. for (let val of list) {
  147. val.zhStatus = that.searchDict(val.status, 'status')
  148. }
  149. that.$set(that, `list`, list);
  150. that.$set(that, `total`, res.total)
  151. } else {
  152. uni.showToast({
  153. title: res.errmsg,
  154. icon: 'none'
  155. })
  156. }
  157. },
  158. // 查看详情
  159. toInfo(e) {
  160. uni.navigateTo({
  161. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  162. })
  163. },
  164. // 查询字典表
  165. searchDict(e, model) {
  166. const that = this;
  167. let data
  168. if (model == 'status') {
  169. data = that.statusList.find((i) => i.value == e);
  170. if (data) return data.label
  171. else return '暂无'
  172. }
  173. },
  174. // 分页
  175. toPage(e) {
  176. const that = this;
  177. let list = that.list;
  178. let limit = that.limit;
  179. if (that.total > list.length) {
  180. uni.showLoading({
  181. title: '加载中',
  182. mask: true
  183. })
  184. let page = that.page + 1;
  185. that.$set(that, `page`, page)
  186. let skip = page * limit;
  187. that.$set(that, `skip`, skip)
  188. that.search();
  189. uni.hideLoading();
  190. } else that.$set(that, `is_bottom`, true)
  191. },
  192. // 触底
  193. toScroll(e) {
  194. const that = this;
  195. let up = that.scrollTop;
  196. that.$set(that, `scrollTop`, e.detail.scrollTop);
  197. let num = Math.sign(up - e.detail.scrollTop);
  198. if (num == 1) that.$set(that, `is_bottom`, false);
  199. },
  200. // 输入框
  201. toInput(e) {
  202. const that = this;
  203. if (that.searchInfo.good_name) that.$set(that.searchInfo, `good_name`, e.detail.value)
  204. else that.$set(that, `searchInfo`, {})
  205. that.clearPage();
  206. that.search();
  207. },
  208. // 审批
  209. async toExam(item, type) {
  210. const that = this;
  211. let user = that.user;
  212. let obj = {};
  213. uni.showModal({
  214. title: '提示',
  215. content: '确定审批该订单吗?',
  216. success: async function(res) {
  217. if (res.confirm) {
  218. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  219. if (res.errcode == '0') {
  220. uni.showToast({
  221. title: '维护信息成功',
  222. icon: 'none'
  223. })
  224. that.clearPage()
  225. that.search()
  226. } else {
  227. uni.showToast({
  228. title: res.errmsg,
  229. icon: 'none'
  230. })
  231. }
  232. }
  233. }
  234. });
  235. },
  236. // 查询其他信息
  237. async searchOther() {
  238. const that = this;
  239. let res;
  240. // 查询状态
  241. res = await that.$api(`/DictData`, 'GET', {
  242. type: 'upkeep',
  243. is_use: '0'
  244. })
  245. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  246. },
  247. // 清空列表
  248. clearPage() {
  249. const that = this;
  250. that.$set(that, `list`, [])
  251. that.$set(that, `skip`, 0)
  252. that.$set(that, `limit`, 6)
  253. that.$set(that, `page`, 0)
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss">
  259. .content {
  260. display: flex;
  261. flex-direction: column;
  262. width: 100vw;
  263. height: 100vh;
  264. .one {
  265. padding: 2vw;
  266. input {
  267. padding: 2vw;
  268. background-color: var(--f1Color);
  269. font-size: var(--font14Size);
  270. border-radius: 5px;
  271. }
  272. }
  273. .two {
  274. position: relative;
  275. flex-grow: 1;
  276. background-color: var(--f9Color);
  277. .list {
  278. background-color: #fff;
  279. border: 1px solid var(--f5Color);
  280. padding: 2vw;
  281. margin: 2vw 2vw 0 2vw;
  282. border-radius: 5px;
  283. .list_1 {
  284. display: flex;
  285. justify-content: space-between;
  286. padding: 2vw 0;
  287. font-size: var(--font16Size);
  288. .status {
  289. font-size: var(--font14Size);
  290. color: var(--fF0Color);
  291. }
  292. }
  293. .list_2 {
  294. display: flex;
  295. .left {
  296. .image {
  297. width: 20vw;
  298. height: 20vw;
  299. border-radius: 5px;
  300. border: 1px solid var(--f9Color);
  301. }
  302. }
  303. .right {
  304. width: 70vw;
  305. margin: 0 0 0 2vw;
  306. .right_1 {
  307. display: flex;
  308. justify-content: space-between;
  309. margin: 2vw 0;
  310. .name {
  311. font-size: var(--font14Size);
  312. }
  313. .num {
  314. display: flex;
  315. flex-direction: column;
  316. align-items: flex-end;
  317. text:last-child {
  318. font-size: var(--font13Size);
  319. color: var(--f85Color);
  320. }
  321. }
  322. }
  323. .right_2 {
  324. font-size: var(--font12Size);
  325. .spec {
  326. text:first-child {
  327. color: var(--f85Color);
  328. }
  329. }
  330. }
  331. }
  332. }
  333. .bottom {
  334. text-align: center;
  335. padding: 1vw 0;
  336. button {
  337. margin: 0 5px 0 0;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. .scroll-view {
  344. position: absolute;
  345. top: 0;
  346. left: 0;
  347. right: 0;
  348. bottom: 0;
  349. .list-scroll-view {
  350. display: flex;
  351. flex-direction: column;
  352. }
  353. }
  354. .is_bottom {
  355. width: 100%;
  356. text-align: center;
  357. text {
  358. padding: 2vw 0;
  359. display: inline-block;
  360. color: var(--f85Color);
  361. font-size: var(--font14Size);
  362. }
  363. }
  364. </style>