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="scan-btn uni-row" style="min-height: 80rpx;" @click.stop="handleAddAuxilaryDaywork">新增辅助工序报工
  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.nickName }}</view>
  30. </view>
  31. <view class="info-row uni-row">
  32. <view class="label">产品描述:</view>
  33. <view class="value">{{ item.productDescription }}</view>
  34. </view>
  35. <view class="info-row uni-row">
  36. <view class="label">合格数量:</view>
  37. <view class="value">{{ item.qualifiedNum }}</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.processAlias }}</view>
  44. <view class="label">辅助工序:</view>
  45. <view class="value">{{ item.auxiliaryProcessAlias }}</view>
  46. </view>
  47. <view class="info-row uni-row" style="justify-content: space-between;">
  48. <view class="label">箱号:</view>
  49. <view class="value">{{ item.carrierName }}</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. getDayWorkList
  68. } from '@/api/business/auxiliaryDaywork.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: 3,
  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.userId = userId.value
  118. quer.value.isAuto = 0
  119. getDayWorkList(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 timeSizer() {
  156. // inspecionList.value = filterSameDayItems(original.value, startTime.value);
  157. getList()
  158. }
  159. // 筛选函数
  160. const filterSameDayItems = (inspectionList, startTime) => {
  161. // 使用filter方法筛选出与startTime同一天的元素
  162. const filteredList = inspectionList.filter(item => {
  163. // 将数组中每个元素的date属性转换为不包含时分秒的字符串
  164. const itemDateString = item.createTime.split(' ')[0];
  165. // 比较两个日期字符串是否相同
  166. return itemDateString === startTime;
  167. });
  168. return filteredList;
  169. };
  170. function isSameDate(date1, date2) {
  171. // 使用Date对象的toISOString()方法来格式化日期,并去除时分秒部分
  172. const formatDate = (date) => date.toISOString().split('T')[0];
  173. // 比较两个日期的年月日部分是否相同
  174. return formatDate(date1) === formatDate(date2);
  175. }
  176. //查看序捡详情
  177. function handleSelection(item) {
  178. store.auxiliaryDaywork = item;
  179. uni.navigateTo({
  180. url: '/pages/auxiliaryDaywork/form'
  181. })
  182. }
  183. //状态文本
  184. function selectText(item) {
  185. for (var i = 0; i < range.length; i++) {
  186. if (item.status == range[i].value) {
  187. return range[i].text
  188. }
  189. }
  190. }
  191. //状态样式
  192. function selectType(item) {
  193. for (var i = 0; i < range.length; i++) {
  194. if (item.status == range[i].value) {
  195. return range[i].type
  196. }
  197. }
  198. }
  199. const addProcessInspection = (data) => {
  200. const info = {
  201. title: data.title,
  202. standard: data.standard,
  203. result: '',
  204. number: 1
  205. }
  206. unfitInfos.value.push(info)
  207. }
  208. /***************************** 定义了一些事件 *****************************/
  209. // 新增辅助工序报工
  210. const handleAddAuxilaryDaywork = () => {
  211. uni.navigateTo({
  212. url: '/pages/auxiliaryDaywork/scan'
  213. })
  214. }
  215. // 修改信息
  216. const handleShowUnfit = () => {
  217. uni.navigateTo({
  218. url: '/pages/auxiliaryDaywork/form'
  219. })
  220. }
  221. const deleteItem = (item) => {
  222. // uni.showToast({
  223. // title: "删除方法未完成"
  224. // })
  225. uni.showModal({
  226. title: '确认',
  227. content: (item.rejectNum > 0 ? "已有外协检测信息,确认删除么?" : '确认删除该序检么?'),
  228. success: function(res) {
  229. if (res.confirm) {
  230. delProcessInspection(item.id).then(res => {
  231. if (res.code === 200) {
  232. console.log(res)
  233. getList()
  234. } else {
  235. uni.showToast({
  236. icon: 'none',
  237. title: res.msg
  238. })
  239. }
  240. })
  241. } else if (res.cancel) {
  242. uni.showToast({
  243. title: '已取消',
  244. icon: 'none'
  245. })
  246. }
  247. }
  248. })
  249. }
  250. const changeCheckCarrier = (item) => {
  251. // uni.showToast({
  252. // title: "检测载具方法未完成"
  253. // })
  254. // uni.$once('refreshProcessInspection', () => {
  255. // })
  256. const openItem = {
  257. dayworkId: item.dayworkId,
  258. processInspectionId: item.id,
  259. daywork: item.daywork
  260. }
  261. uni.navigateTo({
  262. url: "/pages/changeBox/index",
  263. success: function(res) {
  264. // 通过eventChannel向被打开页面传送数据
  265. res.eventChannel.emit('acceptDataFromOpenerPage', {
  266. data: openItem
  267. })
  268. }
  269. })
  270. }
  271. function delable(item) {
  272. if (store.userInfo.permissions.some(item => item === 'business:outsourcedInspection:remove') && item.status == 0) {
  273. return true
  274. }
  275. if (item.creatorId === userId.value && item.status == 0) {
  276. return true
  277. }
  278. return false
  279. }
  280. </script>
  281. <style lang="scss">
  282. .time-controls {
  283. .title {
  284. margin: 20% auto 40% auto;
  285. .first {
  286. font-size: 48rpx;
  287. margin: 0 auto;
  288. }
  289. .second {
  290. color: red;
  291. font-size: 24rpx;
  292. margin: 10rpx auto 0 auto;
  293. }
  294. }
  295. .sta {
  296. justify-content: center;
  297. align-items: center;
  298. input {
  299. border: 1rpx solid gray;
  300. border-radius: 8rpx;
  301. width: 400rpx;
  302. height: 64rpx;
  303. }
  304. }
  305. button {
  306. width: 78%;
  307. background-color: #1684fc;
  308. color: white;
  309. margin: 0 auto;
  310. }
  311. }
  312. .page-container {
  313. // height: 100%;
  314. background-color: #ececec;
  315. font-size: 28rpx;
  316. padding: 24rpx;
  317. box-sizing: border-box;
  318. }
  319. .search-container {
  320. border-radius: 12rpx;
  321. align-items: center;
  322. input {
  323. flex: 1;
  324. background-color: #ffffff;
  325. height: 64rpx;
  326. box-sizing: border-box;
  327. padding: 0 16rpx;
  328. }
  329. .btn {
  330. width: 120rpx;
  331. height: 64rpx;
  332. background-color: #1684FC;
  333. justify-content: center;
  334. font-size: 24rpx;
  335. color: #ffffff;
  336. justify-content: center;
  337. align-items: center;
  338. }
  339. }
  340. .scan-btn {
  341. height: 64rpx;
  342. margin: 32rpx 32rpx 0 32rpx;
  343. color: #ffffff;
  344. background-color: #f47c3c;
  345. align-items: center;
  346. justify-content: center;
  347. border-radius: 8rpx;
  348. }
  349. .daywork-item {
  350. padding: 24rpx;
  351. background-color: #ffffff;
  352. margin-top: 24rpx;
  353. border-radius: 8rpx;
  354. .lot-code {
  355. align-items: center;
  356. justify-content: space-between;
  357. font-weight: 700;
  358. }
  359. .info {
  360. font-size: 24rpx;
  361. color: #767676;
  362. .info-row {
  363. margin-top: 16rpx;
  364. .label {
  365. width: 120rpx;
  366. }
  367. .value {
  368. flex: 1;
  369. }
  370. }
  371. }
  372. }
  373. </style>