index.vue 9.5 KB

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