index.vue 9.4 KB

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