index.vue 9.8 KB

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