index.vue 11 KB

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