index.vue 9.8 KB

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