index.vue 9.5 KB

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