index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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="handleAddOutsourcedInspection">新增外协检查
  14. </view>
  15. <view class="daywork-item uni-column" v-for="(item, index) in inspecionList" :key="index"
  16. @click="handleSelection(item)">
  17. <view class="lot-code uni-row">
  18. <text>批次号:{{ item.lotCode }}</text>
  19. <text :style="selectType(item)">{{ selectText(item) }}</text>
  20. <!-- <uni-icons type="right" size="16" /> -->
  21. <!-- item.creatorId === userId && item.status == 0 -->
  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 class="label">废品量:</view>
  39. <view class="value">{{ item.rejectNum }}</view>
  40. </view>
  41. <view class="info-row uni-row">
  42. <view class="label">产品描述:</view>
  43. <view class="value">{{ item.productDescription }}</view>
  44. </view>
  45. <view class="info-row uni-row" style="justify-content: space-between;">
  46. <view class="label">检测载具:</view>
  47. <view class="value">{{ item.inspectionCarrierCode }}
  48. {{ item.isInspectionCarrierChanged == 1 ? '(已解绑)' : ''}}
  49. </view>
  50. <button class="reporting-tag" size="mini" type="primary"
  51. @click.stop="changeCheckCarrier(item)">检测载具</button>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script setup>
  58. import {
  59. ref
  60. } from 'vue'
  61. import {
  62. getOutsourcedInspection,
  63. getLotInfo,
  64. delProcessInspection
  65. } from '@/api/business/processInspection.js'
  66. import {
  67. timestampToTime,
  68. toHHmmss
  69. } from '@/utils/common.js'
  70. import {
  71. onLoad,
  72. onReady,
  73. onUnload,
  74. onShow
  75. } from '@dcloudio/uni-app'
  76. import {
  77. store
  78. } from '@/store/index.js'
  79. import {
  80. getToken
  81. } from '@/utils/auth'
  82. import path from '@/api/base/path.js'
  83. const keywords = ref('')
  84. const inspecionList = ref([]); //时间后筛选数组
  85. const original = ref([]); //原始数组
  86. const startTime = ref(new Date().toISOString().split('T')[0])
  87. const userId = ref(store.userInfo.userId)
  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. getP2();
  106. })
  107. /***************************** 定义了一些方法 *****************************/
  108. function getList() {
  109. uni.showLoading({
  110. title: '加载中'
  111. });
  112. // quer.value.userId = store.userInfo.userId;
  113. quer.value.startTime = startTime.value;
  114. quer.value.isAuto = 0
  115. quer.value.type = "outsourcedInspector"
  116. getOutsourcedInspection(quer.value).then(res => {
  117. console.log("res", res);
  118. if (res.code == 200) {
  119. original.value = res.rows;
  120. inspecionList.value = res.rows;
  121. // timeSizer();
  122. uni.hideLoading();
  123. // uni.hideLoading();
  124. }
  125. });
  126. }
  127. //查询P2中外协完成后需要检查的工序
  128. function getP2() {
  129. let token = 'Bearer ' + getToken();
  130. let header = {
  131. Authorization: token
  132. }
  133. uni.request({
  134. url: path.furnaceNoURL + '/business/sfc10300/getP2ProcessWrbz/' + "Y",
  135. method: 'GET',
  136. header,
  137. sslVerify: false,
  138. success: (res) => {
  139. console.log("P2查询", res);
  140. //将工序编码保存到store中
  141. if (res.data.code == 200) {
  142. store.outsourcedCode = res.data.rows.map(item => item.prcode.trim());
  143. // console.log("store", store.outsourcedCode);
  144. }
  145. },
  146. fail: (err) => {
  147. console.log(err)
  148. }
  149. })
  150. }
  151. //时间筛选
  152. function timeSizer() {
  153. // inspecionList.value = filterSameDayItems(original.value, startTime.value);
  154. getList()
  155. }
  156. // 筛选函数
  157. const filterSameDayItems = (inspectionList, startTime) => {
  158. // 使用filter方法筛选出与startTime同一天的元素
  159. const filteredList = inspectionList.filter(item => {
  160. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  161. const itemDateString = item.createTime.split(' ')[0];
  162. // 比较两个日期字符串是否相同
  163. return itemDateString === startTime;
  164. });
  165. return filteredList;
  166. };
  167. function isSameDate(date1, date2) {
  168. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  169. const formatDate = (date) => date.toISOString().split('T')[0];
  170. // 比较两个日期的年月日部分是否相同
  171. return formatDate(date1) === formatDate(date2);
  172. }
  173. //查看序捡详情
  174. function handleSelection(item) {
  175. store.processInspection = item;
  176. uni.navigateTo({
  177. url: '/pages/outsourcedInspection/form'
  178. })
  179. }
  180. //状态文本
  181. function selectText(item) {
  182. for (var i = 0; i < range.length; i++) {
  183. if (item.status == range[i].value) {
  184. return range[i].text
  185. }
  186. }
  187. }
  188. //状态样式
  189. function selectType(item) {
  190. for (var i = 0; i < range.length; i++) {
  191. if (item.status == range[i].value) {
  192. return range[i].type
  193. }
  194. }
  195. }
  196. const addProcessInspection = (data) => {
  197. const info = {
  198. title: data.title,
  199. standard: data.standard,
  200. result: '',
  201. number: 1
  202. }
  203. unfitInfos.value.push(info)
  204. }
  205. /***************************** 定义了一些事件 *****************************/
  206. // 新增序检
  207. const handleAddOutsourcedInspection = () => {
  208. uni.navigateTo({
  209. url: '/pages/outsourcedInspection/scan'
  210. })
  211. }
  212. // 添加不合格信息
  213. const handleShowUnfit = () => {
  214. uni.navigateTo({
  215. url: '/pages/outsourcedInspection/form'
  216. })
  217. }
  218. const deleteItem = (item) => {
  219. // uni.showToast({
  220. // title: "删除方法未完成"
  221. // })
  222. uni.showModal({
  223. title: '确认',
  224. content: (item.rejectNum > 0 ? "已有外协检测信息,确认删除么?" : '确认删除该序检么?'),
  225. success: function(res) {
  226. if (res.confirm) {
  227. delProcessInspection(item.id).then(res => {
  228. if (res.code === 200) {
  229. console.log(res)
  230. getList()
  231. } else {
  232. uni.showToast({
  233. icon: 'none',
  234. title: res.msg
  235. })
  236. }
  237. })
  238. } else if (res.cancel) {
  239. uni.showToast({
  240. title: '已取消',
  241. icon: 'none'
  242. })
  243. }
  244. }
  245. })
  246. }
  247. const changeCheckCarrier = (item) => {
  248. // uni.showToast({
  249. // title: "检测载具方法未完成"
  250. // })
  251. // uni.$once('refreshProcessInspection', () => {
  252. // })
  253. const openItem = {
  254. dayworkId: item.dayworkId,
  255. processInspectionId: item.id,
  256. daywork: item
  257. }
  258. uni.navigateTo({
  259. url: "/pages/changeInspectionBox/index",
  260. success: function(res) {
  261. // 通过eventChannel向被打开页面传送数据
  262. res.eventChannel.emit('outsourceFromOpenerPage', {
  263. data: openItem
  264. })
  265. }
  266. })
  267. }
  268. function delable(item) {
  269. if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:remove') && item.status == 0) {
  270. return true
  271. }
  272. if (item.creatorId === userId.value && item.status == 0) {
  273. return true
  274. }
  275. return false
  276. }
  277. </script>
  278. <style lang="scss">
  279. .time-controls {
  280. .title {
  281. margin: 20% auto 40% auto;
  282. .first {
  283. font-size: 48rpx;
  284. margin: 0 auto;
  285. }
  286. .second {
  287. color: red;
  288. font-size: 24rpx;
  289. margin: 10rpx auto 0 auto;
  290. }
  291. }
  292. .sta {
  293. justify-content: center;
  294. align-items: center;
  295. input {
  296. border: 1rpx solid gray;
  297. border-radius: 8rpx;
  298. width: 400rpx;
  299. height: 64rpx;
  300. }
  301. }
  302. button {
  303. width: 78%;
  304. background-color: #1684fc;
  305. color: white;
  306. margin: 0 auto;
  307. }
  308. }
  309. .page-container {
  310. // height: 100%;
  311. background-color: #ececec;
  312. font-size: 28rpx;
  313. padding: 24rpx;
  314. box-sizing: border-box;
  315. }
  316. .search-container {
  317. border-radius: 12rpx;
  318. align-items: center;
  319. input {
  320. flex: 1;
  321. background-color: #ffffff;
  322. height: 64rpx;
  323. box-sizing: border-box;
  324. padding: 0 16rpx;
  325. }
  326. .btn {
  327. width: 120rpx;
  328. height: 64rpx;
  329. background-color: #1684FC;
  330. justify-content: center;
  331. font-size: 24rpx;
  332. color: #ffffff;
  333. justify-content: center;
  334. align-items: center;
  335. }
  336. }
  337. .scan-btn {
  338. height: 64rpx;
  339. margin: 32rpx 32rpx 0 32rpx;
  340. color: #ffffff;
  341. background-color: #f47c3c;
  342. align-items: center;
  343. justify-content: center;
  344. border-radius: 8rpx;
  345. }
  346. .daywork-item {
  347. padding: 24rpx;
  348. background-color: #ffffff;
  349. margin-top: 24rpx;
  350. border-radius: 8rpx;
  351. .lot-code {
  352. align-items: center;
  353. justify-content: space-between;
  354. font-weight: 700;
  355. }
  356. .info {
  357. font-size: 24rpx;
  358. color: #767676;
  359. .info-row {
  360. margin-top: 16rpx;
  361. .label {
  362. width: 120rpx;
  363. }
  364. .value {
  365. flex: 1;
  366. }
  367. }
  368. }
  369. }
  370. </style>