moldAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <gui-page :custom-header="true" :header-class="['gui-theme-background-color']">
  3. <template #gHeader>
  4. <view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  5. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <text
  7. style="font-size:44rpx;"
  8. class="gui-header-leader-btns gui-color-white font-icons"
  9. @tap="goBack"
  10. >&#xe6c5;</text>
  11. <!-- 导航文本此处也可以是其他自定义内容 -->
  12. <text
  13. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text"
  14. >模具保养(新增)</text>
  15. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  16. <!-- 实际宽度请根据自己情况设置 -->
  17. <view style="width:40px;" />
  18. <!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
  19. </view>
  20. </template>
  21. <template #gBody>
  22. <view class="list-content">
  23. <view class="card-list-flexbox">
  24. <!-- <view class="card-list-item">
  25. <text class="text-1">保养日期</text>
  26. <view class="text-2">
  27. <picker mode="date"
  28. style="width: 100%;min-width: 85px;height: 40px;display: flex;justify-content: flex-end;align-items: center;"
  29. :value="form.maintainDate" @change="bindTimeChange($event)">
  30. {{ form.maintainDate }}
  31. </picker>
  32. </view>
  33. </view> -->
  34. <view class="card-list-item">
  35. <text class="text-1">保养人</text>
  36. <view class="text-2">
  37. {{ form.username }}
  38. <!-- <uni-data-select v-model="form.maintainUserid" :localdata="selectList" @change="search">
  39. </uni-data-select> -->
  40. </view>
  41. </view>
  42. <view class="card-list-item-checkbox">
  43. <text class="checkbox-label">导柱导套无松动</text>
  44. <view class="checkbox-check">
  45. <checkbox
  46. value="true"
  47. :checked="form.guidePillar"
  48. color="#FFCC33"
  49. style="transform:scale(0.7)"
  50. @click="handleChecked('guidePillar')"
  51. />
  52. </view>
  53. </view>
  54. <view class="card-list-item-checkbox">
  55. <text class="checkbox-label">定位销无松动</text>
  56. <view class="checkbox-check">
  57. <checkbox
  58. value="true"
  59. :checked="form.orientation"
  60. color="#FFCC33"
  61. style="transform:scale(0.7)"
  62. @click="handleChecked('orientation')"
  63. />
  64. </view>
  65. </view>
  66. <view class="card-list-item-checkbox">
  67. <text class="checkbox-label">模板无变形,磨损</text>
  68. <view class="checkbox-check">
  69. <checkbox
  70. value="true"
  71. :checked="form.template"
  72. color="#FFCC33"
  73. style="transform:scale(0.7)"
  74. @click="handleChecked('template')"
  75. />
  76. </view>
  77. </view>
  78. <view class="card-list-item-checkbox">
  79. <text class="checkbox-label">刀锋无缺口</text>
  80. <view class="checkbox-check">
  81. <checkbox
  82. value="true"
  83. :checked="form.gap"
  84. color="#FFCC33"
  85. style="transform:scale(0.7)"
  86. @click="handleChecked('gap')"
  87. />
  88. </view>
  89. </view>
  90. <view class="card-list-item-checkbox">
  91. <text class="checkbox-label">刀锋无钝化</text>
  92. <view class="checkbox-check">
  93. <checkbox
  94. value="true"
  95. :checked="form.passivation"
  96. color="#FFCC33"
  97. style="transform:scale(0.7)"
  98. @click="handleChecked('passivation')"
  99. />
  100. </view>
  101. </view>
  102. <view class="card-list-item-checkbox">
  103. <text class="checkbox-label">模具表面清洁整理</text>
  104. <view class="checkbox-check">
  105. <checkbox
  106. value="true"
  107. :checked="form.clean"
  108. color="#FFCC33"
  109. style="transform:scale(0.7)"
  110. @click="handleChecked('clean')"
  111. />
  112. </view>
  113. </view>
  114. <view class="card-list-item-checkbox">
  115. <text class="checkbox-label">模具无生锈且添加防锈油</text>
  116. <view class="checkbox-check">
  117. <checkbox
  118. value="true"
  119. :checked="form.rust"
  120. color="#FFCC33"
  121. style="transform:scale(0.7)"
  122. @click="handleChecked('rust')"
  123. />
  124. </view>
  125. </view>
  126. <view class="card-list-item-checkbox">
  127. <text class="checkbox-label">寿命类型</text>
  128. <view class="custom-select">
  129. <uni-data-select v-model="form.countFormat" :localdata="selectList" />
  130. </view>
  131. </view>
  132. <view class="card-list-item-checkbox">
  133. <text class="checkbox-label">寿命</text>
  134. <view class="custom-select">
  135. <uni-easyinput
  136. v-model="form.addCount"
  137. :clearable="false"
  138. type="number"
  139. min="0"
  140. focus
  141. @focus="handleInputFocus"
  142. placeholder="请填写寿命"
  143. />
  144. </view>
  145. </view>
  146. <view class="card-list-item-checkbox">
  147. <text class="checkbox-label">备注</text>
  148. </view>
  149. <view class="card-list-item-remark">
  150. <textarea
  151. v-model="form.remark"
  152. maxlength="-1"
  153. confirm-type="done"
  154. placeholder="请填写备注"
  155. />
  156. </view>
  157. </view>
  158. </view>
  159. <gui-right-menus>
  160. <!-- 扩展按钮 -->
  161. <template #menus-more>
  162. <view
  163. hover-class="gui-tap"
  164. class="menu-items gui-bg-green gui-flex gui-columns gui-justify-content-center"
  165. @click="handleSavePreveser"
  166. >
  167. <text class="menu-text gui-block gui-text-center gui-color-white">保存</text>
  168. </view>
  169. </template>
  170. <!-- 核心按钮 -->
  171. <template #menus-primary>
  172. <view class="menu-items gui-bg-primary gui-flex gui-columns gui-justify-content-center">
  173. <text class="menu-icon gui-color-white gui-block gui-text-center gui-icons">&#xe614;</text>
  174. <text class="menu-text gui-color-white gui-block gui-text-center">操作</text>
  175. </view>
  176. </template>
  177. </gui-right-menus>
  178. </template>
  179. </gui-page>
  180. </template>
  181. <script>
  182. import {
  183. ref,
  184. onMounted,
  185. defineComponent
  186. } from 'vue'
  187. export default defineComponent({
  188. setup() {
  189. const form = ref({
  190. toolingId: uni.getStorageSync('toolingId') ?? '', // 模具ID
  191. maintainUserid: '',
  192. maintainDate: '',
  193. username: '',
  194. guidePillar: false,
  195. orientation: false,
  196. template: false,
  197. gap: false,
  198. passivation: false,
  199. clean: false,
  200. rust: false,
  201. countFormat: '',
  202. addCount: 0,
  203. remark: ''
  204. })
  205. onMounted(() => {
  206. const userInfo = JSON.parse(uni.getStorageSync('user') ?? {})
  207. form.value.maintainUserid = userInfo?.id
  208. form.value.username = userInfo?.nickname
  209. })
  210. const goBack = function() {
  211. uni.$goBack('/pages/workbranch/ETM/moldPreserve/moldDetails')
  212. }
  213. const bindTimeChange = function(ev) {
  214. form.value.maintainDate = ev.detail.value
  215. }
  216. const handleChecked = function(key) {
  217. form.value[key] = !form.value[key]
  218. }
  219. // 保存
  220. const handleSavePreveser = function() {
  221. const datetime = new Date()
  222. const year = datetime.getFullYear()
  223. const month = datetime.getMonth() + 1
  224. const day = datetime.getDate() < 10 ? '0' + datetime.getDate() : datetime.getDate()
  225. const params = {
  226. ...form.value,
  227. maintainUserid: form.value.maintainUserid + '',
  228. maintainDate: year + '-' + month + '-' + day,
  229. clean: form.value.clean ? '1' : '0',
  230. gap: form.value.gap ? '1' : '0',
  231. guidePillar: form.value.guidePillar ? '1' : '0',
  232. orientation: form.value.orientation ? '1' : '0',
  233. passivation: form.value.passivation ? '1' : '0',
  234. rust: form.value.rust ? '1' : '0',
  235. template: form.value.template ? '1' : '0',
  236. addCount: form.value.addCount ?? 0,
  237. countFormat: form.value.countFormat ?? '1'
  238. }
  239. uni.$reqPost('moldCreate', params)
  240. .then(({
  241. code,
  242. data,
  243. msg
  244. }) => {
  245. if (code === 0) {
  246. uni.showToast({
  247. title: '保存成功',
  248. icon: 'none',
  249. duration: 1000
  250. })
  251. setTimeout(() => {
  252. goBack()
  253. }, 1000)
  254. } else {
  255. uni.showToast({
  256. title: msg,
  257. icon: 'none',
  258. duration: 2000
  259. })
  260. }
  261. })
  262. }
  263. // 禁用软键盘
  264. const handleInputFocus = function() {
  265. setTimeout(() => {
  266. uni.hideKeyboard()
  267. }, 100)
  268. }
  269. return {
  270. selectList: [{ text: '数值', value: '1' }, { text: '百分比', value: '2' }],
  271. form,
  272. goBack,
  273. handleInputFocus,
  274. handleChecked,
  275. bindTimeChange,
  276. handleSavePreveser
  277. }
  278. }
  279. })
  280. </script>
  281. <style lang="scss" scoped>
  282. .gui-header-leader-btns {
  283. color: black;
  284. font-size: 24px !important;
  285. margin-left: 24rpx;
  286. }
  287. .list-content {
  288. margin-top: 80px;
  289. background-color: #edeeee;
  290. }
  291. .card-list-flexbox {
  292. display: flex;
  293. flex-direction: row;
  294. align-items: center;
  295. flex-wrap: wrap;
  296. margin: 3px 2px;
  297. .card-list-item {
  298. width: 750rpx;
  299. height: 45px;
  300. margin: 2rpx 0;
  301. display: grid;
  302. grid-template-rows: 1fr;
  303. grid-template-columns: 1fr 3fr;
  304. align-items: center;
  305. background-color: #fff;
  306. uni-text {
  307. font-size: 14px;
  308. height: 50rpx;
  309. text-align: left;
  310. padding: 0 12px;
  311. display: flex;
  312. flex-direction: row;
  313. align-items: center;
  314. color: #191919;
  315. }
  316. .text-1 {
  317. width: calc(100% - 24px);
  318. height: 40px;
  319. padding: 2px 12px;
  320. }
  321. .text-2 {
  322. width: calc(100% - 24px);
  323. min-width: 120px;
  324. height: 40px;
  325. display: flex;
  326. align-items: center;
  327. justify-content: flex-end;
  328. margin-right: 4px;
  329. padding: 2px 12px;
  330. }
  331. }
  332. .card-list-item-checkbox {
  333. width: 750rpx;
  334. height: 40px;
  335. margin: 2rpx 0;
  336. display: grid;
  337. grid-template-rows: 1fr;
  338. grid-template-columns: 3fr 1fr;
  339. align-items: center;
  340. background-color: #fff;
  341. .checkbox-label {
  342. width: calc(100% - 24px);
  343. min-width: 120px;
  344. height: 40px;
  345. line-height: 40px;
  346. font-size: 14px;
  347. margin-right: 4px;
  348. padding: 2px 12px;
  349. }
  350. .checkbox-check {
  351. height: 40px;
  352. line-height: 40px;
  353. width: calc(100% - 24px);
  354. padding: 2px 12px;
  355. text-align: right;
  356. }
  357. }
  358. .card-list-item-remark {
  359. width: 750rpx;
  360. padding: 2px 12px;
  361. background-color: #fff;
  362. textarea {
  363. width: 100%;
  364. min-height: 80px;
  365. height: 25vh;
  366. }
  367. }
  368. }
  369. .font-icons {
  370. width: 40px;
  371. font-size: 20px;
  372. }
  373. .scan {
  374. height: 45px;
  375. width: calc(100% - 48px);
  376. margin: 12px;
  377. padding: 0 12px;
  378. display: flex;
  379. justify-content: space-between;
  380. align-items: center;
  381. border-radius: 6px;
  382. background-color: white;
  383. .scan-card {
  384. width: 100%;
  385. display: grid;
  386. grid-template-rows: 1fr;
  387. grid-template-columns: 7fr 2fr;
  388. align-items: center;
  389. input {
  390. height: 35px;
  391. line-height: 35px;
  392. }
  393. text {
  394. width: 100%;
  395. text-align: right;
  396. }
  397. }
  398. }
  399. .search {
  400. height: 45px;
  401. width: calc(100% - 48px);
  402. margin: 12px;
  403. padding: 0 12px;
  404. display: flex;
  405. justify-content: space-between;
  406. align-items: center;
  407. border-radius: 6px;
  408. background-color: white;
  409. .search-card {
  410. width: 100%;
  411. display: grid;
  412. grid-template-rows: 1fr;
  413. grid-template-columns: 3fr 7fr;
  414. align-items: center;
  415. }
  416. }
  417. .custom-select {
  418. width: 100%;
  419. height: 100%;
  420. padding: 0;
  421. }
  422. </style>