index.vue 7.7 KB

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