index.vue 8.4 KB

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