index.vue 9.6 KB

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