index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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. @listSubmit="listSubmit(item)" @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. import {
  39. processInstanceCreateAPI,
  40. processInstancePage
  41. } from '@/api/wt/index.js'
  42. export default {
  43. components: {
  44. myCard
  45. },
  46. data() {
  47. return {
  48. searchForm: {},
  49. emptyShow: false,
  50. searchShow: false,
  51. formItems: [{
  52. label: '编码:',
  53. prop: 'code',
  54. component: 'MyInput',
  55. props: {
  56. placeholder: '请输入内容'
  57. }
  58. },
  59. {
  60. label: '工单编码:',
  61. prop: 'workCode',
  62. component: 'MyInput',
  63. props: {
  64. placeholder: '请输入内容',
  65. }
  66. },
  67. {
  68. label: '领用人:',
  69. prop: 'recipientName',
  70. component: 'MyInput',
  71. props: {
  72. placeholder: '请输入内容',
  73. }
  74. },
  75. {
  76. label: '客户名称:',
  77. prop: 'contactName',
  78. component: 'MyInput',
  79. props: {
  80. placeholder: '请输入内容',
  81. }
  82. },
  83. {
  84. label: '设备名称:',
  85. prop: 'deviceName',
  86. component: 'MyInput',
  87. props: {
  88. placeholder: '请输入内容',
  89. }
  90. },
  91. {
  92. label: '物品名称:',
  93. prop: 'categoryName',
  94. component: 'MyInput',
  95. props: {
  96. placeholder: '请输入内容',
  97. }
  98. },
  99. {
  100. label: '创建时间:',
  101. prop: 'creatTime',
  102. component: 'MyDateRange',
  103. props: {
  104. type: 'daterange',
  105. }
  106. }
  107. ],
  108. columns: [
  109. [{
  110. label: '编号:',
  111. prop: 'code',
  112. type: 'title',
  113. className: 'perce100',
  114. }],
  115. [{
  116. label: '工单编码:',
  117. prop: 'orderCode'
  118. }],
  119. [{
  120. label: '物品分类:',
  121. prop: 'categoryLevelName',
  122. formatter: (row) => {
  123. if (!row.details) return '';
  124. let str = '';
  125. row.details.map((el, idx) => {
  126. if (idx + 1 == row.details.length) {
  127. str += el.categoryLevelName;
  128. } else {
  129. str = el.categoryLevelName ?
  130. str + '' + el.categoryLevelName + ',' :
  131. str + '';
  132. }
  133. });
  134. return str;
  135. }
  136. }],
  137. [{
  138. label: '物品名称:',
  139. prop: 'categoryName',
  140. formatter: (row) => {
  141. if (!row.details) return '';
  142. let str = '';
  143. row.details.map((el, idx) => {
  144. if (idx + 1 == row.details.length) {
  145. str += el.categoryName;
  146. } else {
  147. str = str + '' + el.categoryName + ',';
  148. }
  149. });
  150. return str;
  151. }
  152. }],
  153. [{
  154. label: '领用部门:',
  155. prop: 'receivingDeptName',
  156. }, {
  157. label: '领用人:',
  158. prop: 'recipientName',
  159. }],
  160. [{
  161. label: '客户名称:',
  162. prop: 'contactName'
  163. }],
  164. [{
  165. label: '设备名称:',
  166. prop: 'categoryName',
  167. formatter: (row) => {
  168. if (!row.deviceDetails) return '';
  169. let str = '';
  170. row.deviceDetails.map((el, idx) => {
  171. if (idx + 1 == row.deviceDetails.length) {
  172. str += el.categoryName;
  173. } else {
  174. str = str + '' + el.categoryName + ',';
  175. }
  176. });
  177. return str;
  178. }
  179. }],
  180. [{
  181. label: '状态:',
  182. prop: 'approvalStatus',
  183. formatter: (row) => {
  184. const reviewStatus = {
  185. 0: '未提交',
  186. 1: '审核中',
  187. 2: '已审核',
  188. 3: '审核不通过'
  189. }
  190. return reviewStatus[row.approvalStatus];
  191. }
  192. }],
  193. [{
  194. label: '创建时间:',
  195. prop: 'createTime'
  196. }, {
  197. label: '使用时间:',
  198. prop: 'usageTime',
  199. }],
  200. [{
  201. label: '操作:',
  202. prop: 'action',
  203. type: 'action',
  204. className: 'perce100',
  205. }],
  206. ],
  207. btnList: [{
  208. name: '详情',
  209. apiName: 'details',
  210. btnType: 'primary',
  211. type: '2',
  212. pageUrl: '',
  213. }, {
  214. name: '修改',
  215. apiName: 'edit',
  216. btnType: 'primary',
  217. type: '2',
  218. pageUrl: '',
  219. judge: [{
  220. authorities: '',
  221. }, {
  222. key: 'source',
  223. value: [0],
  224. }, {
  225. key: 'approvalStatus',
  226. value: [0, 3],
  227. }],
  228. },
  229. {
  230. name: '发起流程',
  231. apiName: 'listSubmit',
  232. btnType: 'primary',
  233. type: '2',
  234. pageUrl: '',
  235. judge: [{
  236. authorities: '',
  237. }, {
  238. key: 'approvalStatus',
  239. value: [0, 3],
  240. }],
  241. },
  242. {
  243. name: '删除',
  244. apiName: 'delete',
  245. btnType: 'primary',
  246. type: '2',
  247. pageUrl: '',
  248. judge: [{
  249. authorities: '',
  250. }, {
  251. key: 'source',
  252. value: [0],
  253. }, {
  254. key: 'approvalStatus',
  255. value: [0, 3],
  256. }],
  257. }
  258. ],
  259. page: 1,
  260. size: 10,
  261. isEnd: false,
  262. tableList: [],
  263. searchVal: '',
  264. }
  265. },
  266. onShow() {
  267. this.doSearch();
  268. },
  269. onReachBottom() {
  270. this.getList()
  271. },
  272. methods: {
  273. async listSubmit(data) {
  274. try {
  275. //后台不提供接口
  276. let list = await processInstancePage({
  277. pageNo: 1,
  278. pageSize: 1,
  279. reset: true,
  280. key: 'eom_sh_bpbj'
  281. })
  282. let params = {
  283. businessId: data.id,
  284. businessKey: 'eom_sh_bpbj',
  285. formCreateUserId: data.createUserId,
  286. processDefinitionId: list?.list[0]?.processDefinition.id,
  287. variables: {
  288. businessCode: data.code,
  289. businessName: data.name,
  290. businessType: '申请备品备件',
  291. },
  292. }
  293. await processInstanceCreateAPI(params)
  294. uni.showModal({
  295. title: `提交成功`,
  296. content: '',
  297. confirmText: '确认',
  298. showCancel: false, // 是否显示取消按钮,默认为 true
  299. success: () => {
  300. this.doSearch()
  301. }
  302. })
  303. } catch {
  304. }
  305. },
  306. doSearch() {
  307. this.isEnd = false;
  308. this.page = 1;
  309. this.getList();
  310. },
  311. //获取列表信息
  312. getList() {
  313. this.emptyShow = false
  314. if (this.isEnd) {
  315. this.$refs.uToast.show({
  316. message: "暂无更多数据",
  317. duration: 1000
  318. })
  319. return
  320. }
  321. uni.showLoading({
  322. title: '加载中'
  323. })
  324. let data = {
  325. pageNum: this.page,
  326. size: this.size,
  327. keyWord: this.searchVal,
  328. ...this.searchForm
  329. }
  330. accessoryPage(data).then(res => {
  331. if (this.page === 1) {
  332. this.tableList = res.list;
  333. if (this.tableList.length === 0) {
  334. this.emptyShow = true
  335. }
  336. } else {
  337. this.tableList.push(...res.list);
  338. }
  339. this.page += 1
  340. this.isEnd = this.tableList.length >= res.count;
  341. uni.hideLoading();
  342. }).catch((e) => {
  343. uni.hideLoading();
  344. })
  345. },
  346. scrolltolower() {
  347. if (this.isEnd) {
  348. return;
  349. }
  350. this.getList();
  351. },
  352. add(item, type) {
  353. uni.navigateTo({
  354. url: `/pages/salesServiceManagement/accessory/accessoryAdd?type=${type}&id=${item?item.id:''}`
  355. })
  356. },
  357. async deleteRow(row) {
  358. const res = await uni.showModal({
  359. title: '确认删除',
  360. content: '确定要删除该条数据吗?',
  361. confirmText: '删除',
  362. confirmColor: '#FF4D4F',
  363. });
  364. if (res[1].confirm) {
  365. const data = await accessoryDelete([row.id]);
  366. if (!data) return
  367. this.$refs.uToast.show({
  368. type: "success",
  369. message: "操作成功",
  370. })
  371. this.doSearch();
  372. } else if (res.cancel) {
  373. console.log('用户取消');
  374. }
  375. },
  376. clearSearch() {
  377. console.log('清空');
  378. this.searchVal = ''
  379. this.doSearch()
  380. },
  381. showSearch() {
  382. this.searchShow = true
  383. },
  384. confirmSearch(e) {
  385. console.log(e);
  386. let data = JSON.parse(JSON.stringify(e))
  387. if (data.creatTime) {
  388. var [startTime, endTime] = data.creatTime
  389. delete data.creatTime
  390. this.searchForm = {
  391. ...data,
  392. startTime,
  393. endTime
  394. }
  395. } else {
  396. this.searchForm = data
  397. }
  398. this.doSearch()
  399. }
  400. }
  401. }
  402. </script>
  403. <style scoped lang="scss">
  404. .top-wrapper {
  405. background-color: #fff;
  406. display: flex;
  407. width: 750rpx;
  408. height: 88rpx;
  409. padding: 16rpx 32rpx;
  410. align-items: center;
  411. gap: 16rpx;
  412. /deep/.uni-section {
  413. margin-top: 0px;
  414. }
  415. /deep/.uni-section-header {
  416. padding: 0px;
  417. }
  418. .search_btn {
  419. width: 120rpx;
  420. height: 70rpx;
  421. line-height: 70rpx;
  422. padding: 0 24rpx;
  423. background: $theme-color;
  424. font-size: 32rpx;
  425. color: #fff;
  426. margin: 0;
  427. margin-left: 26rpx;
  428. }
  429. .menu_icon {
  430. width: 44rpx;
  431. height: 44rpx;
  432. margin-left: 14rpx;
  433. }
  434. }
  435. .add {
  436. width: 96rpx;
  437. height: 96rpx;
  438. border-radius: 48rpx;
  439. background: #3c9cff;
  440. position: fixed;
  441. bottom: 100rpx;
  442. right: 24rpx;
  443. display: flex;
  444. align-items: center;
  445. justify-content: center;
  446. }
  447. /deep/ .u-empty {
  448. margin-top: 200px !important;
  449. }
  450. </style>