index.vue 9.7 KB

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