index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="search-container uni-row">
  4. <input type="text" v-model="quer.keyword" placeholder="请输入关键字" />
  5. <view class="btn uni-row" @click="getList">搜索</view>
  6. <!-- <uni-icons type="scan" size="24" /> -->
  7. </view>
  8. <view class="time-controls" style="margin-top: 10rpx;">
  9. <uni-section title="检查日期:" type="square" class="uni-row sta">
  10. <input v-model="startTime" type="date" @input="timeSizer" />
  11. </uni-section>
  12. </view>
  13. <view class="daywork-item uni-column" v-for="(item, index) in inspecionList" :key="index"
  14. @click="handleSelection(item)">
  15. <view class="lot-code uni-row">
  16. <text>批次号:{{ item.lotCode }}</text>
  17. <text :style="selectType(item)">{{ selectText(item) }}</text>
  18. <text v-if="delable(item)" class="fa fa-trash" style="font-size: 16; color: red;"
  19. @click.stop="deleteItem(item)"></text>
  20. <text v-else class="fa fa-trash" style="font-size: 16; color: white;"></text>
  21. </view>
  22. <view class="info">
  23. <view class="info-row uni-row">
  24. <view class="label">巡检箱号:</view>
  25. <view class="value">{{ item.carrierCode }}</view>
  26. <view class="label">检察员:</view>
  27. <view class="value">{{ item.technicianName }}</view>
  28. </view>
  29. <view class="info-row uni-row">
  30. <view class="label">检查数量:</view>
  31. <view class="value">{{ item.examiningNum }}</view>
  32. <view class="label">不良品量:</view>
  33. <view class="value">{{ item.disqualificationNum }}</view>
  34. </view>
  35. <view class="info-row uni-row">
  36. <view class="label">产品描述:</view>
  37. <view class="value">{{ item.productDescription }}</view>
  38. </view>
  39. <view class="info-row uni-row">
  40. <view class="label">检测载具:</view>
  41. <view class="value">{{ item.inspectionCarrierCode }}
  42. {{ item.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  43. </view>
  44. <button class="reporting-tag" size="mini" type="primary"
  45. @click.stop="changeCheckCarrier(item)">检测载具</button>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script setup>
  52. import {
  53. ref
  54. } from 'vue'
  55. import {
  56. getProcessInspecionList,
  57. getLotInfo,
  58. delProcessInspection
  59. } from '@/api/business/processInspection.js'
  60. import {
  61. timestampToTime,
  62. toHHmmss
  63. } from '@/utils/common.js'
  64. import {
  65. onLoad,
  66. onReady,
  67. onUnload,
  68. onShow
  69. } from '@dcloudio/uni-app'
  70. import {
  71. store
  72. } from '@/store/index.js'
  73. const keyword = ref('')
  74. const inspecionList = ref([]); //时间后筛选数组
  75. const original = ref([]); //原始数组
  76. const startTime = ref(new Date().toISOString().split("T")[0])
  77. const range = [{
  78. value: 0,
  79. text: "待确认",
  80. type: "color: #fcab53"
  81. }, {
  82. value: 1,
  83. text: "合格",
  84. type: "color: #55ff7f"
  85. }, {
  86. value: 2,
  87. text: "不合格",
  88. type: "color: #ff0c2c"
  89. }]
  90. const quer = ref({}) //用于查询
  91. /***************************** 页面生命周期函数 *****************************/
  92. onShow(() => {
  93. getList()
  94. // uni.showLoading({
  95. // title: '加载中'
  96. // });
  97. // quer.value.userId = store.userInfo.userId;
  98. // quer.value.startTime = startTime.value;
  99. // getProcessInspecionList(quer.value).then(res => {
  100. // console.log("res", res);
  101. // if (res.code == 200) {
  102. // original.value = res.rows;
  103. // // timeSizer();
  104. // uni.hideLoading();
  105. // // uni.hideLoading();
  106. // }
  107. // });
  108. })
  109. /***************************** 定义了一些方法 *****************************/
  110. function getList() {
  111. uni.showLoading({
  112. title: '加载中'
  113. });
  114. //quer.value.creatorId = store.userInfo.userId;
  115. quer.value.startTime = startTime.value;
  116. quer.value.type = "firstArticleInspection"
  117. getProcessInspecionList(quer.value).then(res => {
  118. console.log("res", res);
  119. if (res.code == 200) {
  120. original.value = res.rows;
  121. inspecionList.value = res.rows;
  122. uni.hideLoading();
  123. }
  124. });
  125. }
  126. function delable(item) {
  127. if (item.creatorId === store.userInfo.userId) {
  128. return true
  129. }
  130. return false
  131. }
  132. const changeCheckCarrier = (item) => {
  133. const openItem = {
  134. dayworkId: item.dayworkId,
  135. processInspectionId: item.id,
  136. daywork: item
  137. }
  138. uni.navigateTo({
  139. url: "/pages/changeInspectionBox/index",
  140. success: function(res) {
  141. // 通过eventChannel向被打开页面传送数据
  142. res.eventChannel.emit('outsourceFromOpenerPage', {
  143. data: openItem
  144. })
  145. }
  146. })
  147. }
  148. const deleteItem = (item) => {
  149. uni.showModal({
  150. title: '确认',
  151. content: '确认删除该首件检么?',
  152. success: function(res) {
  153. if (res.confirm) {
  154. delProcessInspection(item.id).then(res => {
  155. if (res.code === 200) {
  156. console.log(res)
  157. getList()
  158. } else {
  159. uni.showToast({
  160. icon: 'none',
  161. title: res.msg
  162. })
  163. }
  164. })
  165. } else if (res.cancel) {
  166. uni.showToast({
  167. title: '已取消',
  168. icon: 'none'
  169. })
  170. }
  171. }
  172. })
  173. }
  174. //时间筛选,暂时注释,使用搜索向
  175. function timeSizer() {}
  176. // 筛选函数
  177. const filterSameDayItems = (inspectionList, startTime) => {
  178. // 使用filter方法筛选出与startTime同一天的元素
  179. const filteredList = inspectionList.filter(item => {
  180. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  181. const itemDateString = item.createTime.split(' ')[0];
  182. // 比较两个日期字符串是否相同
  183. return itemDateString === startTime;
  184. });
  185. return filteredList;
  186. };
  187. function isSameDate(date1, date2) {
  188. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  189. const formatDate = (date) => date.toISOString().split('T')[0];
  190. // 比较两个日期的年月日部分是否相同
  191. return formatDate(date1) === formatDate(date2);
  192. }
  193. //查看序捡详情
  194. function handleSelection(item) {
  195. store.processInspection = item;
  196. uni.navigateTo({
  197. url: '/pages/firstInspection/form'
  198. })
  199. }
  200. //状态文本
  201. function selectText(item) {
  202. for (var i = 0; i < range.length; i++) {
  203. if (item.status == range[i].value) {
  204. return range[i].text
  205. }
  206. }
  207. }
  208. //状态样式
  209. function selectType(item) {
  210. for (var i = 0; i < range.length; i++) {
  211. if (item.status == range[i].value) {
  212. return range[i].type
  213. }
  214. }
  215. }
  216. const addProcessInspection = (data) => {
  217. const info = {
  218. title: data.title,
  219. standard: data.standard,
  220. result: '',
  221. number: 1
  222. }
  223. unfitInfos.value.push(info)
  224. }
  225. </script>
  226. <style lang="scss">
  227. .time-controls {
  228. .title {
  229. margin: 20% auto 40% auto;
  230. .first {
  231. font-size: 48rpx;
  232. margin: 0 auto;
  233. }
  234. .second {
  235. color: red;
  236. font-size: 24rpx;
  237. margin: 10rpx auto 0 auto;
  238. }
  239. }
  240. .sta {
  241. justify-content: center;
  242. align-items: center;
  243. input {
  244. border: 1rpx solid gray;
  245. border-radius: 8rpx;
  246. width: 400rpx;
  247. height: 64rpx;
  248. }
  249. }
  250. button {
  251. width: 78%;
  252. background-color: #1684fc;
  253. color: white;
  254. margin: 0 auto;
  255. }
  256. }
  257. .page-container {
  258. height: 100%;
  259. background-color: #ececec;
  260. font-size: 28rpx;
  261. padding: 24rpx;
  262. box-sizing: border-box;
  263. }
  264. .search-container {
  265. border-radius: 12rpx;
  266. align-items: center;
  267. input {
  268. flex: 1;
  269. background-color: #ffffff;
  270. height: 64rpx;
  271. box-sizing: border-box;
  272. padding: 0 16rpx;
  273. }
  274. .btn {
  275. width: 120rpx;
  276. height: 64rpx;
  277. background-color: #1684FC;
  278. justify-content: center;
  279. font-size: 24rpx;
  280. color: #ffffff;
  281. justify-content: center;
  282. align-items: center;
  283. }
  284. }
  285. .scan-btn {
  286. height: 64rpx;
  287. margin: 32rpx 32rpx 0 32rpx;
  288. color: #ffffff;
  289. background-color: #f47c3c;
  290. align-items: center;
  291. justify-content: center;
  292. border-radius: 8rpx;
  293. }
  294. .daywork-item {
  295. padding: 24rpx;
  296. background-color: #ffffff;
  297. margin-top: 24rpx;
  298. border-radius: 8rpx;
  299. .lot-code {
  300. align-items: center;
  301. justify-content: space-between;
  302. font-weight: 700;
  303. }
  304. .info {
  305. font-size: 24rpx;
  306. color: #767676;
  307. .info-row {
  308. margin-top: 16rpx;
  309. .label {
  310. width: 120rpx;
  311. }
  312. .value {
  313. flex: 1;
  314. }
  315. }
  316. }
  317. }
  318. </style>