index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="质检报告" @clickLeft="back">
  4. </uni-nav-bar>
  5. <!-- 搜索栏 -->
  6. <view class="top-wrapper">
  7. <uni-section>
  8. <uni-easyinput
  9. prefixIcon="search"
  10. style="width: 420rpx"
  11. v-model="searchForm.reportNumber"
  12. placeholder="请输入报告编号"
  13. @confirm="doSearch"
  14. >
  15. </uni-easyinput>
  16. </uni-section>
  17. <button class="search_btn filter_btn" @click="filterVisible = true">筛选</button>
  18. <button class="search_btn" @click="doSearch">搜索</button>
  19. </view>
  20. <view class="list-content">
  21. <u-list @scrolltolower="scrolltolower" class="listContent">
  22. <view v-for="(item, idx) in tableList" :key="item.id" class="card-wrapper">
  23. <myCard
  24. :item="item"
  25. :index="idx + 1"
  26. :btnList="getBtnList(item)"
  27. :columns="cardColumns"
  28. :title="item.reportNumber || item.code"
  29. :status="statusText(item.reportApprovalStatus)"
  30. @goDetail="openDetail"
  31. @edit="openEdit(item)"
  32. @delete="deleteReportBtn(item)"
  33. />
  34. </view>
  35. <view style="width: 100%; height: 40rpx"></view>
  36. <u-loadmore :status="loadStatus" />
  37. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  38. <u-empty iconSize="150" textSize="32" text="暂无数据" />
  39. </view>
  40. </u-list>
  41. </view>
  42. <!-- 筛选弹窗 -->
  43. <u-popup :show="filterVisible" mode="bottom" :round="20" closeable @close="filterVisible = false" bgColor="#fff">
  44. <view class="search_wrap">
  45. <view class="title">筛选</view>
  46. <view class="form_item">
  47. <view class="label">工单编号</view>
  48. <u-input v-model="filterForm.code" placeholder="请输入"></u-input>
  49. </view>
  50. <view class="form_item">
  51. <view class="label">产品编码</view>
  52. <u-input v-model="filterForm.productCode" placeholder="请输入"></u-input>
  53. </view>
  54. <view class="form_item">
  55. <view class="label">产品名称</view>
  56. <u-input v-model="filterForm.productName" placeholder="请输入"></u-input>
  57. </view>
  58. <view class="form_item">
  59. <view class="label">型号</view>
  60. <u-input v-model="filterForm.modelType" placeholder="请输入"></u-input>
  61. </view>
  62. <view class="form_item">
  63. <view class="label">规格</view>
  64. <u-input v-model="filterForm.specification" placeholder="请输入"></u-input>
  65. </view>
  66. <view class="form_item">
  67. <view class="label">审批状态</view>
  68. <u-radio-group class="radio-group" v-model="filterForm.reportApprovalStatus" placement="row" iconSize="32" labelSize="28">
  69. <u-radio v-for="(it, idx) in statusList" :key="idx" :customStyle="{ marginRight: '20rpx' }" :label="it.label" :name="it.value"></u-radio>
  70. </u-radio-group>
  71. </view>
  72. <view class="form_item">
  73. <view class="label">记录方法</view>
  74. <u-radio-group class="radio-group" v-model="filterForm.recordingMethod" placement="row" iconSize="32" labelSize="28">
  75. <u-radio v-for="(it, idx) in recordingMethodList" :key="idx" :customStyle="{ marginRight: '20rpx' }" :label="it.label" :name="it.value"></u-radio>
  76. </u-radio-group>
  77. </view>
  78. <view class="btns">
  79. <button class="btn reset" @click="resetFilter">重置</button>
  80. <button class="btn confirm" @click="confirmFilter">确定</button>
  81. </view>
  82. </view>
  83. </u-popup>
  84. <u-toast ref="uToast" />
  85. </view>
  86. </template>
  87. <script>
  88. import myCard from "@/components/myCard.vue";
  89. import { getReportList, deleteReport } from "@/api/inspectionReport/index.js";
  90. import { recordingMethodList } from "@/utils/utils.js";
  91. const statusList = [
  92. { value: 0, label: "未提交" },
  93. { value: 1, label: "审核中" },
  94. { value: 2, label: "已审核" },
  95. { value: 3, label: "审核不通过" },
  96. { value: 7, label: "作废" }
  97. ];
  98. export default {
  99. components: { myCard },
  100. data() {
  101. return {
  102. statusList,
  103. recordingMethodList,
  104. tableList: [],
  105. page: 1,
  106. size: 10,
  107. isEnd: false,
  108. loadStatus: "loadmore",
  109. filterVisible: false,
  110. searchForm: {
  111. reportNumber: ""
  112. },
  113. filterForm: {
  114. code: "",
  115. productCode: "",
  116. productName: "",
  117. modelType: "",
  118. specification: "",
  119. reportApprovalStatus: "",
  120. recordingMethod: ""
  121. },
  122. cardColumns: [
  123. [{ prop: "code", label: "工单编号", className: "perce100" }],
  124. [
  125. {
  126. prop: "productName",
  127. label: "产品",
  128. className: "perce100",
  129. formatter: (item) =>
  130. (item.productName || "") + "(" + (item.productCode || "") + ")"
  131. }
  132. ],
  133. [
  134. {
  135. prop: "specification",
  136. label: "规格型号",
  137. className: "perce50",
  138. formatter: (item) =>
  139. (item.specification || "") + "/" + (item.modelType || "")
  140. },
  141. {
  142. prop: "recordingMethod",
  143. label: "记录方法",
  144. className: "perce50",
  145. formatter: (item) => this.recordingMethodText(item.recordingMethod)
  146. }
  147. ],
  148. [
  149. {
  150. prop: "total",
  151. label: "数量",
  152. className: "perce50",
  153. formatter: (item) =>
  154. item.total ? item.total + (item.sampleMeasureUnit || "") : ""
  155. },
  156. { prop: "reportDate", label: "报告日期", className: "perce50" }
  157. ],
  158. [
  159. {
  160. prop: "reportTemplateCreateUserName",
  161. label: "创建人",
  162. className: "perce50"
  163. },
  164. {
  165. prop: "reportApprovalTime",
  166. label: "审批时间",
  167. className: "perce50",
  168. formatter: (item) =>
  169. (item.reportApprovalTime || "") +
  170. (item.reportApprovalUserName ? " " + item.reportApprovalUserName : "")
  171. }
  172. ],
  173. [{ label: "操作", prop: "action", type: "action", className: "perce100" }]
  174. ]
  175. };
  176. },
  177. onLoad() {
  178. this.getList();
  179. },
  180. onShow() {
  181. uni.$on("inspectionReportRefresh", this.doSearch);
  182. },
  183. onUnload() {
  184. uni.$off("inspectionReportRefresh", this.doSearch);
  185. },
  186. methods: {
  187. getList() {
  188. uni.showLoading({ title: "加载中", mask: true });
  189. const params = {
  190. pageNum: this.page,
  191. size: this.size
  192. };
  193. const fields = {
  194. reportNumber: this.searchForm.reportNumber,
  195. code: this.filterForm.code,
  196. productCode: this.filterForm.productCode,
  197. productName: this.filterForm.productName,
  198. modelType: this.filterForm.modelType,
  199. specification: this.filterForm.specification
  200. };
  201. Object.keys(fields).forEach((key) => {
  202. const val = fields[key];
  203. if (val !== "" && val !== undefined && val !== null) {
  204. params[key] = val;
  205. }
  206. });
  207. const statusVal = this.filterForm.reportApprovalStatus;
  208. if (statusVal !== "" && statusVal !== undefined && statusVal !== null) {
  209. params.reportApprovalStatus = statusVal;
  210. }
  211. const methodVal = this.filterForm.recordingMethod;
  212. if (methodVal !== "" && methodVal !== undefined && methodVal !== null) {
  213. params.recordingMethod = methodVal;
  214. }
  215. getReportList(params)
  216. .then((res) => {
  217. uni.hideLoading();
  218. const list = res.list || res.records || [];
  219. if (this.page === 1) {
  220. this.tableList = list;
  221. } else {
  222. this.tableList.push(...list);
  223. }
  224. this.isEnd = this.tableList.length >= (res.count || res.total || 0);
  225. this.loadStatus = this.isEnd ? "nomore" : "loadmore";
  226. this.page += 1;
  227. })
  228. .catch(() => {
  229. uni.hideLoading();
  230. });
  231. },
  232. doSearch() {
  233. this.page = 1;
  234. this.getList();
  235. },
  236. scrolltolower() {
  237. if (this.isEnd) {
  238. return;
  239. }
  240. this.getList();
  241. },
  242. confirmFilter() {
  243. this.filterVisible = false;
  244. this.page = 1;
  245. this.getList();
  246. },
  247. resetFilter() {
  248. this.filterForm = {
  249. code: "",
  250. productCode: "",
  251. productName: "",
  252. modelType: "",
  253. specification: "",
  254. reportApprovalStatus: "",
  255. recordingMethod: ""
  256. };
  257. this.filterVisible = false;
  258. this.page = 1;
  259. this.getList();
  260. },
  261. getBtnList(item) {
  262. const btns = [];
  263. if (item.reportApprovalStatus == 0 || item.reportApprovalStatus == 3) {
  264. btns.push({ name: "编辑", apiName: "edit", btnType: "warning" });
  265. btns.push({ name: "删除", apiName: "delete", btnType: "danger" });
  266. }
  267. return btns;
  268. },
  269. statusText(status) {
  270. return (statusList.find((it) => it.value == status) || {}).label || "";
  271. },
  272. recordingMethodText(method) {
  273. return (recordingMethodList.find((it) => it.value == method) || {}).label || "";
  274. },
  275. openDetail(row) {
  276. uni.setStorageSync("inspectionReportRow", row);
  277. uni.navigateTo({
  278. url: "/pages/qms/inspectionReport/detail?id=" + row.id
  279. });
  280. },
  281. openEdit(row) {
  282. uni.setStorageSync("inspectionReportRow", row);
  283. uni.navigateTo({
  284. url: "/pages/qms/inspectionReport/detail?id=" + row.id + "&edit=1"
  285. });
  286. },
  287. deleteReportBtn(row) {
  288. uni.showModal({
  289. title: "提示",
  290. content: "确定要删除该检测报告吗?",
  291. success: (res) => {
  292. if (res.confirm) {
  293. deleteReport(row.id)
  294. .then(() => {
  295. this.$refs.uToast.show({
  296. type: "success",
  297. icon: false,
  298. message: "删除成功"
  299. });
  300. this.page = 1;
  301. this.getList();
  302. })
  303. .catch((err) => {
  304. this.$refs.uToast.show({
  305. type: "error",
  306. icon: false,
  307. message: err.message || "删除失败"
  308. });
  309. });
  310. }
  311. }
  312. });
  313. }
  314. }
  315. };
  316. </script>
  317. <style lang="scss" scoped>
  318. .mainBox {
  319. background-color: #f3f8fb;
  320. height: 100vh;
  321. font-size: 27rpx;
  322. overflow-y: auto;
  323. }
  324. .top-wrapper {
  325. background-color: #fff;
  326. display: flex;
  327. width: 750rpx;
  328. height: 88rpx;
  329. padding: 16rpx 32rpx;
  330. align-items: center;
  331. position: absolute;
  332. z-index: 999;
  333. /deep/.uni-section {
  334. margin-top: 0px;
  335. }
  336. /deep/.uni-section-header {
  337. padding: 0px;
  338. }
  339. .search_btn {
  340. width: 110rpx;
  341. height: 70rpx;
  342. line-height: 70rpx;
  343. padding: 0 24rpx;
  344. background: $theme-color;
  345. font-size: 28rpx;
  346. color: #fff;
  347. margin: 0;
  348. margin-left: 16rpx;
  349. }
  350. .filter_btn {
  351. background: #fff;
  352. color: $theme-color;
  353. border: 1rpx solid $theme-color;
  354. }
  355. }
  356. .list-content {
  357. padding-top: 120rpx;
  358. }
  359. .card-wrapper {
  360. width: 720rpx;
  361. margin: 0 auto;
  362. }
  363. .search_wrap {
  364. padding: 30rpx 30rpx 60rpx;
  365. max-height: 70vh;
  366. overflow-y: auto;
  367. .title {
  368. font-size: 32rpx;
  369. font-weight: 600;
  370. text-align: center;
  371. margin-bottom: 20rpx;
  372. }
  373. .form_item {
  374. margin-bottom: 24rpx;
  375. .label {
  376. font-size: 26rpx;
  377. color: #333;
  378. margin-bottom: 10rpx;
  379. }
  380. }
  381. /deep/ .radio-group {
  382. flex-wrap: wrap;
  383. .u-radio__text {
  384. font-size: 28rpx !important;
  385. }
  386. .u-radio__icon-wrap {
  387. width: 32rpx !important;
  388. height: 32rpx !important;
  389. }
  390. }
  391. .btns {
  392. display: flex;
  393. gap: 20rpx;
  394. margin-top: 30rpx;
  395. .btn {
  396. flex: 1;
  397. height: 72rpx;
  398. line-height: 72rpx;
  399. border-radius: 8rpx;
  400. font-size: 28rpx;
  401. }
  402. .reset {
  403. background: #f5f5f5;
  404. color: #333;
  405. }
  406. .confirm {
  407. background: $theme-color;
  408. color: #fff;
  409. }
  410. }
  411. }
  412. </style>