index.vue 9.5 KB

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