index.vue 10 KB

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