index.vue 9.3 KB

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