index.vue 9.2 KB

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