index.vue 9.8 KB

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