index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. title="配件申请记录" @clickLeft="back">
  5. </uni-nav-bar>
  6. <view class="top-wrapper">
  7. <uni-section>
  8. <uni-easyinput @clear="clearSearch" prefixIcon="search" style="width: 460rpx" v-model="searchVal"
  9. placeholder="名称">
  10. </uni-easyinput>
  11. </uni-section>
  12. <button class="search_btn" @click="doSearch">搜索</button>
  13. <image class="menu_icon" src="~@/static/pda/menu.svg" @click="showSearch"></image>
  14. </view>
  15. <view class="wrapper">
  16. <u-list @scrolltolower="scrolltolower" class="listContent" style="height: auto;">
  17. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  18. <myCard :columns="columns" :btnList="btnList" :item="item" @details="add(item,'view')"
  19. @edit="add(item,'edit')" @delete="deleteRow(item)">
  20. </myCard>
  21. </view>
  22. <u-empty v-show="emptyShow && tableList.length==0" width="300" height="300" textSize="30"></u-empty>
  23. </u-list>
  24. </view>
  25. <view class="add" @click="add('','add')">
  26. <u-icon name="plus" color="#fff"></u-icon>
  27. </view>
  28. <u-toast ref="uToast"></u-toast>
  29. <MySearch :show.sync="searchShow" :formItems="formItems" @search="confirmSearch"></MySearch>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. accessoryPage,
  35. accessoryDelete
  36. } from '@/api/salesServiceManagement/accessory/index.js';
  37. import myCard from '@/pages/saleManage/components/myCard.vue';
  38. export default {
  39. components: {
  40. myCard
  41. },
  42. data() {
  43. return {
  44. searchForm: {},
  45. emptyShow: false,
  46. searchShow: false,
  47. formItems: [{
  48. label: '编码:',
  49. prop: 'code',
  50. component: 'MyInput',
  51. props: {
  52. placeholder: '请输入内容'
  53. }
  54. },
  55. {
  56. label: '工单编码:',
  57. prop: 'workCode',
  58. component: 'MyInput',
  59. props: {
  60. placeholder: '请输入内容',
  61. }
  62. },
  63. {
  64. label: '领用人:',
  65. prop: 'recipientName',
  66. component: 'MyInput',
  67. props: {
  68. placeholder: '请输入内容',
  69. }
  70. },
  71. {
  72. label: '客户名称:',
  73. prop: 'contactName',
  74. component: 'MyInput',
  75. props: {
  76. placeholder: '请输入内容',
  77. }
  78. },
  79. {
  80. label: '设备名称:',
  81. prop: 'deviceName',
  82. component: 'MyInput',
  83. props: {
  84. placeholder: '请输入内容',
  85. }
  86. },
  87. {
  88. label: '物品名称:',
  89. prop: 'categoryName',
  90. component: 'MyInput',
  91. props: {
  92. placeholder: '请输入内容',
  93. }
  94. },
  95. {
  96. label: '创建时间:',
  97. prop: 'creatTime',
  98. component: 'MyDateRange',
  99. props: {
  100. type: 'daterange',
  101. }
  102. }
  103. ],
  104. columns: [
  105. [{
  106. label: '编号:',
  107. prop: 'code',
  108. type: 'title',
  109. className: 'perce100',
  110. }],
  111. [{
  112. label: '工单编码:',
  113. prop: 'orderCode'
  114. }],
  115. [{
  116. label: '物品分类:',
  117. prop: 'categoryLevelName',
  118. formatter: (row) => {
  119. if (!row.details) return '';
  120. let str = '';
  121. row.details.map((el, idx) => {
  122. if (idx + 1 == row.details.length) {
  123. str += el.categoryLevelName;
  124. } else {
  125. str = el.categoryLevelName ?
  126. str + '' + el.categoryLevelName + ',' :
  127. str + '';
  128. }
  129. });
  130. return str;
  131. }
  132. }],
  133. [{
  134. label: '物品名称:',
  135. prop: 'categoryName',
  136. formatter: (row) => {
  137. if (!row.details) return '';
  138. let str = '';
  139. row.details.map((el, idx) => {
  140. if (idx + 1 == row.details.length) {
  141. str += el.categoryName;
  142. } else {
  143. str = str + '' + el.categoryName + ',';
  144. }
  145. });
  146. return str;
  147. }
  148. }],
  149. [{
  150. label: '领用部门:',
  151. prop: 'receivingDeptName',
  152. }, {
  153. label: '领用人:',
  154. prop: 'recipientName',
  155. }],
  156. [{
  157. label: '客户名称:',
  158. prop: 'contactName'
  159. }],
  160. [{
  161. label: '设备名称:',
  162. prop: 'categoryName',
  163. formatter: (row) => {
  164. if (!row.deviceDetails) return '';
  165. let str = '';
  166. row.deviceDetails.map((el, idx) => {
  167. if (idx + 1 == row.deviceDetails.length) {
  168. str += el.categoryName;
  169. } else {
  170. str = str + '' + el.categoryName + ',';
  171. }
  172. });
  173. return str;
  174. }
  175. }],
  176. [{
  177. label: '创建时间:',
  178. prop: 'createTime'
  179. }, {
  180. label: '使用时间:',
  181. prop: 'usageTime',
  182. }],
  183. [{
  184. label: '操作:',
  185. prop: 'action',
  186. type: 'action',
  187. className: 'perce100',
  188. }],
  189. ],
  190. btnList: [{
  191. name: '详情',
  192. apiName: 'details',
  193. btnType: 'primary',
  194. type: '2',
  195. pageUrl: '',
  196. }, {
  197. name: '修改',
  198. apiName: 'edit',
  199. btnType: 'primary',
  200. type: '2',
  201. pageUrl: '',
  202. judge: [{
  203. authorities: '',
  204. }, {
  205. key: 'source',
  206. value: [0],
  207. }],
  208. }, {
  209. name: '删除',
  210. apiName: 'delete',
  211. btnType: 'primary',
  212. type: '2',
  213. pageUrl: '',
  214. judge: [{
  215. authorities: '',
  216. }, {
  217. key: 'source',
  218. value: [0],
  219. }],
  220. }],
  221. page: 1,
  222. size: 10,
  223. isEnd: false,
  224. tableList: [],
  225. searchVal: '',
  226. }
  227. },
  228. onShow() {
  229. this.doSearch();
  230. },
  231. onReachBottom() {
  232. this.getList()
  233. },
  234. methods: {
  235. doSearch() {
  236. this.isEnd = false;
  237. this.page = 1;
  238. this.getList();
  239. },
  240. //获取列表信息
  241. getList() {
  242. this.emptyShow = false
  243. if (this.isEnd) {
  244. this.$refs.uToast.show({
  245. message: "暂无更多数据",
  246. duration: 1000
  247. })
  248. return
  249. }
  250. uni.showLoading({
  251. title: '加载中'
  252. })
  253. let data = {
  254. pageNum: this.page,
  255. size: this.size,
  256. keyWord: this.searchVal,
  257. ...this.searchForm
  258. }
  259. accessoryPage(data).then(res => {
  260. if (this.page === 1) {
  261. this.tableList = res.list;
  262. if (this.tableList.length === 0) {
  263. this.emptyShow = true
  264. }
  265. } else {
  266. this.tableList.push(...res.list);
  267. }
  268. this.page += 1
  269. this.isEnd = this.tableList.length >= res.count;
  270. uni.hideLoading();
  271. }).catch((e) => {
  272. uni.hideLoading();
  273. })
  274. },
  275. scrolltolower() {
  276. if (this.isEnd) {
  277. return;
  278. }
  279. this.getList();
  280. },
  281. add(item, type) {
  282. uni.navigateTo({
  283. url: `/pages/salesServiceManagement/accessory/accessoryAdd?type=${type}&id=${item?item.id:''}`
  284. })
  285. },
  286. async deleteRow(row) {
  287. const res = await uni.showModal({
  288. title: '确认删除',
  289. content: '确定要删除该条数据吗?',
  290. confirmText: '删除',
  291. confirmColor: '#FF4D4F',
  292. });
  293. if (res[1].confirm) {
  294. const data = await accessoryDelete([row.id]);
  295. if (!data) return
  296. this.$refs.uToast.show({
  297. type: "success",
  298. message: "操作成功",
  299. })
  300. this.doSearch();
  301. } else if (res.cancel) {
  302. console.log('用户取消');
  303. }
  304. },
  305. clearSearch() {
  306. console.log('清空');
  307. this.searchVal = ''
  308. this.doSearch()
  309. },
  310. showSearch() {
  311. this.searchShow = true
  312. },
  313. confirmSearch(e) {
  314. console.log(e);
  315. let data = JSON.parse(JSON.stringify(e))
  316. if (data.creatTime) {
  317. var [startTime, endTime] = data.creatTime
  318. delete data.creatTime
  319. this.searchForm = {
  320. ...data,
  321. startTime,
  322. endTime
  323. }
  324. } else {
  325. this.searchForm = data
  326. }
  327. this.doSearch()
  328. }
  329. }
  330. }
  331. </script>
  332. <style scoped lang="scss">
  333. .top-wrapper {
  334. background-color: #fff;
  335. display: flex;
  336. width: 750rpx;
  337. height: 88rpx;
  338. padding: 16rpx 32rpx;
  339. align-items: center;
  340. gap: 16rpx;
  341. /deep/.uni-section {
  342. margin-top: 0px;
  343. }
  344. /deep/.uni-section-header {
  345. padding: 0px;
  346. }
  347. .search_btn {
  348. width: 120rpx;
  349. height: 70rpx;
  350. line-height: 70rpx;
  351. padding: 0 24rpx;
  352. background: $theme-color;
  353. font-size: 32rpx;
  354. color: #fff;
  355. margin: 0;
  356. margin-left: 26rpx;
  357. }
  358. .menu_icon {
  359. width: 44rpx;
  360. height: 44rpx;
  361. margin-left: 14rpx;
  362. }
  363. }
  364. .add {
  365. width: 96rpx;
  366. height: 96rpx;
  367. border-radius: 48rpx;
  368. background: #3c9cff;
  369. position: fixed;
  370. bottom: 100rpx;
  371. right: 24rpx;
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. }
  376. /deep/ .u-empty {
  377. margin-top: 200px !important;
  378. }
  379. </style>