applyNew.uvue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885
  1. <template>
  2. <uni-navbar-lite :showRight=false title="物料申请"></uni-navbar-lite>
  3. <view class="page-container">
  4. <scroll-view class="page-content">
  5. <view class="section">
  6. <view class="search-bar">
  7. <view class="search-box">
  8. <image class="search-icon" src="/static/images/workbench/list/1.png" mode="aspectFit"></image>
  9. <input class="search-input" type="text" placeholder="请输入关键字查询" v-model="keyword" @input="handleSearch" />
  10. <view v-if="keyword.length > 0" class="clear-btn" @tap="clearKeyword">
  11. <text class="clear-btn-text">×</text>
  12. </view>
  13. <view class="search-btn" @tap="handleSearch">
  14. <text class="search-btn-text">搜索</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="status-tabs">
  19. <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false">
  20. <view
  21. v-for="(cat, idx) in categories"
  22. :key="idx"
  23. class="status-tab"
  24. :class="{ 'active': currentStatus === cat.id }"
  25. @click="switchStatus(cat.id)"
  26. >
  27. <text class="status-tab-text" :class="{ 'active-text': currentStatus === cat.id }">{{ cat.name }}</text>
  28. </view>
  29. </scroll-view>
  30. </view>
  31. </view>
  32. <view class="section">
  33. <view class="section-header">
  34. <view class="section-header-left">
  35. <view class="section-indicator"></view>
  36. <text class="section-title">物料列表</text>
  37. </view>
  38. <view class="add-material-btn" @click="showAddMaterialModal = true">
  39. <text class="add-material-text">新物料</text>
  40. </view>
  41. </view>
  42. <view class="material-list">
  43. <view
  44. v-for="(item, index) in dataList"
  45. :key="item.itemId + '_' + page"
  46. class="list-item"
  47. @click="handleItemClick(item, index)"
  48. >
  49. <view class="item-header">
  50. <view class="item-info">
  51. <view class="item-name-row">
  52. <text class="item-name" :class="{'status-0': getAuditStatus(item) == 0, 'status-2': getAuditStatus(item) == 3}">{{ getItemName(item) }}</text>
  53. </view>
  54. <view class="item-sub-row">
  55. <text class="item-sub-title">{{ getItemTypeName(item) }}</text>
  56. <text class="item-stock">库存: {{ getStockNum(item) }} {{ getMeasureName(item) }}</text>
  57. </view>
  58. </view>
  59. <view class="item-actions">
  60. <view v-if="getAuditStatus(item) == 0 && !item.isSelected! && canDeleteMaterial(item)" class="material-delete-btn" @click.stop="handleDeleteMaterial(item)">
  61. <text class="delete-icon">×</text>
  62. </view>
  63. <view v-if="item.isSelected" class="added-btn">
  64. <text class="added-icon">已选</text>
  65. </view>
  66. <view v-else-if="isItemDisabled(item)" class="add-btn disabled">
  67. <text class="add-icon">+</text>
  68. </view>
  69. <view v-else class="add-btn" @click.stop="addToSelected(item)">
  70. <text class="add-icon">+</text>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 手动分页 -->
  77. <view class="pagination">
  78. <view class="page-btn" :class="{disabled: page <= 1}" @click="prevPage">
  79. <text class="page-btn-text"><</text>
  80. </view>
  81. <text class="page-info">第{{ page }}页 / 共{{ totalPages }}页</text>
  82. <view class="page-btn" :class="{disabled: page >= totalPages}" @click="nextPage">
  83. <text class="page-btn-text">></text>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="section">
  88. <view class="section-header">
  89. <view class="section-header-left">
  90. <view class="section-indicator"></view>
  91. <text class="section-title">已选列表</text>
  92. </view>
  93. </view>
  94. <view class="selected-list">
  95. <view v-if="selectedItems.length === 0" class="empty-tip">
  96. <text class="empty-tip-text">请选择物料</text>
  97. </view>
  98. <view
  99. v-else
  100. v-for="(selItem, selIndex) in selectedItems"
  101. :key="selIndex"
  102. class="selected-item"
  103. >
  104. <view class="selected-item-row1">
  105. <text class="selected-item-name">{{ selItem.itemName }}</text>
  106. </view>
  107. <view class="selected-item-body">
  108. <view class="selected-item-content">
  109. <view class="selected-item-row1-extra">
  110. <view class="quantity-control">
  111. <view class="qty-btn" @click="decreaseQty(selIndex)">
  112. <text class="qty-btn-text">-</text>
  113. </view>
  114. <input
  115. class="quantity-input"
  116. type="digit"
  117. v-model="selItem.qty"
  118. placeholder="数量"
  119. />
  120. <view class="qty-btn" @click="increaseQty(selIndex)">
  121. <text class="qty-btn-text">+</text>
  122. </view>
  123. </view>
  124. <text class="selected-item-measure">{{ selItem.measureName }}</text>
  125. </view>
  126. <view class="selected-item-row2">
  127. <input
  128. class="selected-item-remark"
  129. type="text"
  130. v-model="selItem.remark"
  131. placeholder="备注"
  132. :maxlength="200"
  133. />
  134. </view>
  135. </view>
  136. <view class="selected-delete-btn" @click="removeSelected(selIndex)">
  137. <text class="delete-icon">×</text>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. <view class="section">
  144. <view class="section-header">
  145. <view class="section-header-left">
  146. <view class="section-indicator"></view>
  147. <text class="section-title">备注/用途</text>
  148. </view>
  149. </view>
  150. <view class="remark-section">
  151. <textarea
  152. class="remark-input"
  153. v-model="remark"
  154. placeholder="请输入备注/用途"
  155. :maxlength="500"
  156. ></textarea>
  157. <text class="remark-count">{{ remark.length }}/500</text>
  158. </view>
  159. </view>
  160. </scroll-view>
  161. <!-- 底部按钮 -->
  162. <view class="bottom-buttons">
  163. <view class="btn-row">
  164. <button class="save-btn" @click="saveApplication">保存</button>
  165. <button class="confirm-btn" @click="confirmApplication">确认申请</button>
  166. </view>
  167. </view>
  168. <!-- 新增物料弹窗 -->
  169. <view v-if="showAddMaterialModal" class="picker-modal">
  170. <view class="modal-mask" @click="closeAddMaterialModal()"></view>
  171. <view class="modal-content">
  172. <view class="modal-header">
  173. <text class="modal-title">{{ materialModalTitle }}</text>
  174. <text class="modal-close" @click="closeAddMaterialModal()">取消</text>
  175. </view>
  176. <view v-if="addMaterialError.length > 0" class="error-tip">
  177. <text class="error-tip-text">{{ addMaterialError }}</text>
  178. <text class="error-tip-close" @click="addMaterialError = ''">×</text>
  179. </view>
  180. <view class="form-item-input">
  181. <text class="label-picker">物料名称</text>
  182. <view class="view-textarea-picker">
  183. <textarea class="textarea-picker" placeholder="请输入物料名称" v-model="newMaterial.itemName" maxlength="100" :auto-height="true" />
  184. </view>
  185. </view>
  186. <view class="form-item-input">
  187. <text class="label-picker">规格型号</text>
  188. <view class="view-textarea-picker">
  189. <textarea class="textarea-picker" placeholder="请输入规格型号" v-model="newMaterial.specification" maxlength="100" :auto-height="true" />
  190. </view>
  191. </view>
  192. <view class="form-item-input">
  193. <text class="label-picker">单位</text>
  194. <view class="view-input-picker measure-input-row">
  195. <input class="input-picker" type="text" placeholder="请输入或选择单位" v-model="newMaterial.measureName" />
  196. <view class="pick-btn" @click="showMeasurePicker = true">
  197. <text class="pick-btn-text">选择</text>
  198. </view>
  199. </view>
  200. </view>
  201. <view class="form-item-input">
  202. <text class="label-picker">产品链接</text>
  203. <view class="view-input-picker">
  204. <input class="input-picker" type="url" placeholder="请输入产品链接" v-model="newMaterial.productUrl" />
  205. </view>
  206. </view>
  207. <view class="form-item-input">
  208. <text class="label-picker">图片(最多3张)</text>
  209. <view class="upload-wrapper">
  210. <UploadImage
  211. :maxCount="3"
  212. :modelValue="newMaterial.imageUrls"
  213. businessType="material"
  214. @update:modelValue="handleImageUpdate"
  215. @delete="handleImageDelete"
  216. @preview="handleImagePreview"
  217. />
  218. </view>
  219. </view>
  220. <view class="form-item-btn">
  221. <button class="btn-primary" @click="handleAddMaterial">
  222. 保存
  223. </button>
  224. </view>
  225. </view>
  226. </view>
  227. <!-- 单位选择弹窗 -->
  228. <view v-if="showMeasurePicker" class="picker-modal">
  229. <view class="modal-mask" @click="showMeasurePicker = false"></view>
  230. <view class="modal-content">
  231. <view class="modal-header">
  232. <text class="modal-title">选择单位</text>
  233. <text class="modal-close" @click="showMeasurePicker = false">取消</text>
  234. </view>
  235. <scroll-view class="measure-list" :scroll-y="true">
  236. <view
  237. v-for="(item, index) in measureList"
  238. :key="index"
  239. class="measure-item"
  240. @click="selectMeasure(item)"
  241. >
  242. <text class="measure-name">{{ item['measureName'] }}</text>
  243. </view>
  244. <view v-if="measureList.length === 0" class="empty-tip">
  245. <text class="empty-tip-text">暂无单位数据</text>
  246. </view>
  247. </scroll-view>
  248. </view>
  249. </view>
  250. <!-- 删除确认弹窗 -->
  251. <view v-if="showDeleteConfirm" class="delete-confirm-modal">
  252. <view class="delete-confirm-mask" @click="showDeleteConfirm = false"></view>
  253. <view class="delete-confirm-content">
  254. <text class="delete-confirm-title">确认删除</text>
  255. <text class="delete-confirm-text">确定要删除这张图片吗?</text>
  256. <view class="delete-confirm-btns">
  257. <view class="delete-confirm-cancel" @click="showDeleteConfirm = false">
  258. <text class="delete-confirm-cancel-text">取消</text>
  259. </view>
  260. <view class="delete-confirm-ok" @click="confirmDeleteImage">
  261. <text class="delete-confirm-ok-text">确定</text>
  262. </view>
  263. </view>
  264. </view>
  265. </view>
  266. <!-- 图片预览弹窗 -->
  267. <view v-if="showImagePreview" class="image-preview-modal" @click="showImagePreview = false">
  268. <swiper class="preview-swiper" :current="previewIndex" @change="handlePreviewChange">
  269. <swiper-item v-for="(url, idx) in previewUrls" :key="idx">
  270. <image class="preview-image" :src="url" mode="aspectFit" @click.stop></image>
  271. </swiper-item>
  272. </swiper>
  273. <view class="preview-close" @click="showImagePreview = false">
  274. <text class="preview-close-text">×</text>
  275. </view>
  276. <view class="preview-indicator">
  277. <text class="preview-indicator-text">{{ previewIndex + 1 }} / {{ previewUrls.length }}</text>
  278. </view>
  279. </view>
  280. </view>
  281. </template>
  282. <script setup lang="uts">
  283. import { ref, computed, onBeforeUnmount, onMounted } from 'vue'
  284. import { getItemTypeListByParentId, getItemList, savePurchaseApply, confirmPurchaseApply, addMaterial, getMeasureList, deleteMaterial, updateMaterial } from '../../api/apply/index'
  285. import { getUserInfo } from '../../utils/storage'
  286. import UploadImage from '../../components/upload-image/upload-image.uvue'
  287. import type { UploadResponse } from '../../types/workbench'
  288. import { getBaseUrl } from '../../utils/request'
  289. let searchTimer: number | null = null
  290. type CategoryItem = { id: string; name: string; code: string }
  291. type Item = {
  292. itemId: string;
  293. itemName: string;
  294. itemCode: string;
  295. itemTypeName: string;
  296. measureName: string;
  297. specification: string;
  298. imageUrls: string;
  299. productUrl: string;
  300. auditStatus: number;
  301. stockNum: number;
  302. createBy: string;
  303. isSelected?: boolean;
  304. }
  305. type SelectedItem = { itemId: string; itemName: string; itemTypeName: string; measureName: string; qty: string; remark: string }
  306. const keyword = ref<string>("")
  307. const dataList = ref<Item[]>([])
  308. const selectedItems = ref<SelectedItem[]>([])
  309. const remark = ref<string>("")
  310. const page = ref<number>(1)
  311. const pageSize: number = 10
  312. const total = ref<number>(0)
  313. const totalPages = computed((): number => {
  314. if (total.value <= 0) return 1
  315. return Math.ceil(total.value / pageSize)
  316. })
  317. const hasMore = ref<boolean>(true)
  318. const loading = ref<boolean>(false)
  319. const refreshing = ref<boolean>(false)
  320. const categories = ref<CategoryItem[]>([])
  321. const dealLoad = ref<boolean>(false)
  322. let currentStatus = ref<string>('')
  323. const isSearching = ref<boolean>(false)
  324. // 当前登录用户
  325. const currentUserName = ref<string>('')
  326. // 新增物料相关
  327. const showAddMaterialModal = ref<boolean>(false)
  328. const addMaterialError = ref<string>('')
  329. const showMeasurePicker = ref<boolean>(false)
  330. const measureList = ref<UTSJSONObject[]>([])
  331. const showDeleteConfirm = ref<boolean>(false)
  332. const deleteImageIndex = ref<number>(0)
  333. const showImagePreview = ref<boolean>(false)
  334. const previewUrls = ref<string[]>([])
  335. const previewIndex = ref<number>(0)
  336. // 编辑物料相关
  337. const editingMaterialItem = ref<Item | null>(null)
  338. // 弹窗标题
  339. const materialModalTitle = computed<string>(() => {
  340. return editingMaterialItem.value != null ? '修改物料' : '新增物料'
  341. })
  342. type NewMaterial = {
  343. itemName: string
  344. specification: string
  345. measureName: string
  346. imageUrls: UploadResponse[]
  347. productUrl: string
  348. }
  349. const newMaterial = ref<NewMaterial>({
  350. itemName: '',
  351. specification: '',
  352. measureName: '',
  353. imageUrls: [],
  354. productUrl: ''
  355. })
  356. const getImageUrl = (filename: string): string => {
  357. if (filename == null || filename.length === 0) {
  358. return ''
  359. }
  360. // 如果已经是完整URL,直接返回
  361. if (filename.startsWith('http://') || filename.startsWith('https://')) {
  362. return filename
  363. }
  364. // 添加服务器地址和资源路径前缀
  365. const baseUrl = getBaseUrl()
  366. // baseUrl已经是 http://192.168.189.43:83,添加prod-api/resource/
  367. return baseUrl + filename
  368. }
  369. // 加载单位列表
  370. const loadMeasureList = (): void => {
  371. getMeasureList().then((res: any) => {
  372. const data = res as UTSJSONObject
  373. const list = data['data']
  374. if (list != null) {
  375. measureList.value = list as UTSJSONObject[]
  376. }
  377. }).catch(() => {
  378. measureList.value = []
  379. })
  380. }
  381. // 选择单位
  382. const selectMeasure = (item: UTSJSONObject): void => {
  383. const measureName = item['measureName'] != null ? item['measureName'].toString() : ''
  384. newMaterial.value.measureName = measureName
  385. showMeasurePicker.value = false
  386. }
  387. // 获取当前选中的分类code
  388. const getCurrentCategoryCode = (): string => {
  389. const currentCat = categories.value.find((c: CategoryItem) => c.id === currentStatus.value)
  390. return currentCat != null ? currentCat.code : ''
  391. }
  392. // 加载物料列表
  393. const loadItems = (): void => {
  394. loading.value = true
  395. const itemTypeCode = getCurrentCategoryCode()
  396. getItemList(itemTypeCode, page.value, pageSize, keyword.value).then((res: any) => {
  397. const data = res as UTSJSONObject
  398. const rows = data['rows']
  399. const totalNum = data['total']
  400. if (totalNum != null) {
  401. total.value = totalNum as number
  402. }
  403. if (rows != null) {
  404. const listData = rows as UTSJSONObject[]
  405. if (listData.length > 0) {
  406. const arr: Item[] = []
  407. const selectedIds = selectedItems.value.map((s: SelectedItem) => s.itemId)
  408. listData.forEach((item: UTSJSONObject) => {
  409. const itemId = item['itemId'] != null ? item['itemId'].toString() : ''
  410. let auditStatus = -1
  411. const auditStatusVal = item['auditStatus']
  412. if (auditStatusVal != null) {
  413. if (typeof auditStatusVal === 'number') {
  414. auditStatus = auditStatusVal as number
  415. } else {
  416. auditStatus = parseInt(auditStatusVal.toString())
  417. }
  418. }
  419. let stockNum = 0
  420. const stockNumVal = item['stockNum']
  421. if (stockNumVal != null) {
  422. if (typeof stockNumVal === 'number') {
  423. stockNum = stockNumVal as number
  424. } else {
  425. stockNum = parseFloat(stockNumVal.toString())
  426. }
  427. }
  428. const it: Item = {
  429. itemId: itemId,
  430. itemName: item['itemName'] != null ? item['itemName'].toString() : '',
  431. itemCode: item['itemCode'] != null ? item['itemCode'].toString() : '',
  432. itemTypeName: item['itemTypeName'] != null ? item['itemTypeName'].toString() : '',
  433. measureName: item['measureName'] != null ? item['measureName'].toString() : '',
  434. specification: item['specification'] != null ? item['specification'].toString() : '',
  435. imageUrls: item['imageUrls'] != null ? item['imageUrls'].toString() : '',
  436. productUrl: item['productUrl'] != null ? item['productUrl'].toString() : '',
  437. isSelected: selectedIds.includes(itemId),
  438. auditStatus: auditStatus,
  439. stockNum: stockNum,
  440. createBy: item['createBy'] != null ? item['createBy'].toString() : ''
  441. }
  442. arr.push(it)
  443. })
  444. dataList.value = arr
  445. loading.value = false
  446. return
  447. }
  448. }
  449. dataList.value = []
  450. loading.value = false
  451. }).catch(() => {
  452. dataList.value = []
  453. loading.value = false
  454. })
  455. }
  456. // 上一页
  457. const prevPage = (): void => {
  458. if (page.value > 1) {
  459. page.value--
  460. loadItems()
  461. }
  462. }
  463. // 下一页
  464. const nextPage = (): void => {
  465. if (page.value < totalPages.value) {
  466. page.value++
  467. loadItems()
  468. }
  469. }
  470. const loadCategories = (): void => {
  471. getItemTypeListByParentId(200).then((res: any) => {
  472. const data = res as UTSJSONObject
  473. const list = data['data']
  474. if (list != null) {
  475. const listData = list as UTSJSONObject[]
  476. if (listData.length > 0) {
  477. const arr: CategoryItem[] = []
  478. listData.forEach((item: UTSJSONObject) => {
  479. const idVal = item['itemTypeId']
  480. const nameVal = item['itemTypeName']
  481. const codeVal = item['itemTypeCode']
  482. const cat: CategoryItem = {
  483. id: idVal != null ? idVal.toString() : '',
  484. name: nameVal != null ? nameVal.toString() : '',
  485. code: codeVal != null ? codeVal.toString() : ''
  486. }
  487. arr.push(cat)
  488. })
  489. const allItem: CategoryItem = {id: '', name: '全部', code: ''}
  490. arr.unshift(allItem)
  491. categories.value = arr
  492. // 加载第一个分类的物料
  493. if (arr.length > 0) {
  494. currentStatus.value = arr[0].id
  495. loadItems()
  496. }
  497. return
  498. }
  499. }
  500. const defaultArr: CategoryItem[] = []
  501. const defaultItem: CategoryItem = {id: '', name: '全部', code: ''}
  502. defaultArr.push(defaultItem)
  503. categories.value = defaultArr
  504. }).catch(() => {
  505. const defaultArr: CategoryItem[] = []
  506. const defaultItem: CategoryItem = {id: '', name: '全部', code: ''}
  507. defaultArr.push(defaultItem)
  508. categories.value = defaultArr
  509. })
  510. }
  511. // 添加到已选列表
  512. const addToSelected = (item: any | null): void => {
  513. if (item == null) return
  514. const mdItem = item as Item
  515. // 检查审核状态
  516. if (mdItem.auditStatus != null && mdItem.auditStatus === 2) {
  517. uni.showToast({ title: '该物料已禁用,无法添加', icon: 'none'})
  518. return
  519. }
  520. // 检查是否已存在
  521. const exists = selectedItems.value.find((s: SelectedItem) => s.itemId === mdItem.itemId)
  522. if (exists != null) {
  523. uni.showToast({ title: '该物料已在选择列表中', icon: 'none'})
  524. return
  525. }
  526. const selItem: SelectedItem = {
  527. itemId: mdItem.itemId,
  528. itemName: mdItem.itemName,
  529. itemTypeName: mdItem.itemTypeName,
  530. measureName: mdItem.measureName,
  531. qty: '1',
  532. remark: ''
  533. }
  534. selectedItems.value.push(selItem)
  535. // 更新 dataList 中的选中状态
  536. const idx = dataList.value.findIndex((d: Item) => d.itemId === mdItem.itemId)
  537. if (idx >= 0) {
  538. dataList.value[idx].isSelected = true
  539. }
  540. }
  541. // 删除已选
  542. const removeSelected = (index: number): void => {
  543. const removedItem = selectedItems.value[index]
  544. selectedItems.value.splice(index, 1)
  545. // 重新加载当前页数据以更新选中状态
  546. loadItems()
  547. }
  548. // 增加数量
  549. const increaseQty = (index: number): void => {
  550. const currentQty = parseInt(selectedItems.value[index].qty)
  551. selectedItems.value[index].qty = (currentQty + 1).toString()
  552. }
  553. // 减少数量
  554. const decreaseQty = (index: number): void => {
  555. const currentQty = parseInt(selectedItems.value[index].qty)
  556. if (currentQty > 1) {
  557. selectedItems.value[index].qty = (currentQty - 1).toString()
  558. }
  559. }
  560. const handleItemClick = (item: any | null, index: number): void => {
  561. if (item == null) return
  562. const mdItem = item as Item
  563. // 判断是否满足编辑条件
  564. if (getAuditStatus(mdItem) == 0 && !mdItem.isSelected && canDeleteMaterial(mdItem)) {
  565. // 满足编辑条件,弹出编辑窗口
  566. editingMaterialItem.value = mdItem
  567. let imageUrls: UploadResponse[] = []
  568. if (mdItem.imageUrls && mdItem.imageUrls.length > 0) {
  569. const fileNames = mdItem.imageUrls.split(',')
  570. imageUrls = fileNames.map((fileName: string, index: number) => {
  571. const fullUrl = getImageUrl(fileName)
  572. return {
  573. fileId: 'edit_' + Date.now() + '_' + index,
  574. fileName: fileName,
  575. url: fullUrl,
  576. filePath: '',
  577. fileSize: 0,
  578. fileExt: fileName.includes('.') ? fileName.split('.').pop() || '' : '',
  579. businessType: 'material'
  580. } as UploadResponse
  581. })
  582. }
  583. let itemName = mdItem.itemName
  584. if (mdItem.specification && mdItem.itemName.endsWith('(' + mdItem.specification + ')')) {
  585. itemName = mdItem.itemName.substring(0, mdItem.itemName.length - ('(' + mdItem.specification + ')').length)
  586. }
  587. newMaterial.value = {
  588. itemName: itemName,
  589. specification: mdItem.specification || '',
  590. measureName: mdItem.measureName || '',
  591. imageUrls: imageUrls,
  592. productUrl: mdItem.productUrl || ''
  593. } as NewMaterial
  594. showAddMaterialModal.value = true
  595. } else {
  596. // 不满足编辑条件,跳转到详情页
  597. uni.navigateTo({
  598. url: `/pages/item/detail?id=${mdItem.itemId}`
  599. })
  600. }
  601. }
  602. const getItemName = (item: any | null): string => {
  603. if (item == null) return ''
  604. const mdItem = item as Item
  605. return mdItem.itemName
  606. }
  607. const getItemTypeName = (item: any | null): string => {
  608. if (item == null) return ''
  609. const mdItem = item as Item
  610. return mdItem.itemTypeName
  611. }
  612. const getMeasureName = (item: any | null): string => {
  613. if (item == null) return ''
  614. const mdItem = item as Item
  615. if (mdItem.measureName != null) return mdItem.measureName
  616. return mdItem.unitOfMeasure != null ? mdItem.unitOfMeasure : ''
  617. }
  618. const getStockNum = (item: any | null): string => {
  619. if (item == null) return '0'
  620. const mdItem = item as Item
  621. const stock = mdItem.stockNum != null ? mdItem.stockNum : 0
  622. return stock.toString()
  623. }
  624. const getAuditStatus = (item: any | null): number => {
  625. if (item == null) return -1
  626. const mdItem = item as Item
  627. return mdItem.auditStatus != null ? mdItem.auditStatus : -1
  628. }
  629. const isItemDisabled = (item: any | null): boolean => {
  630. if (item == null) return false
  631. const mdItem = item as Item
  632. const status = mdItem.auditStatus != null ? mdItem.auditStatus : -1
  633. return status == 3
  634. }
  635. // 判断物料是否可删除(创建人是当前用户)
  636. const canDeleteMaterial = (item: any | null): boolean => {
  637. if (item == null) return false
  638. const mdItem = item as Item
  639. const createBy = mdItem.createBy != null ? mdItem.createBy : ''
  640. return createBy === currentUserName.value
  641. }
  642. // 检查物料是否已被选择
  643. const isItemSelected = (item: any | null): boolean => {
  644. if (item == null) return false
  645. const mdItem = item as Item
  646. return selectedItems.value.find((s: SelectedItem) => s.itemId === mdItem.itemId) != null
  647. }
  648. const handleSearch = (): void => {
  649. const timer = searchTimer
  650. if (timer != null) {
  651. clearTimeout(timer)
  652. }
  653. searchTimer = setTimeout(() => {
  654. page.value = 1
  655. loadItems()
  656. }, 300)
  657. }
  658. const clearKeyword = (): void => {
  659. keyword.value = ''
  660. page.value = 1
  661. loadItems()
  662. }
  663. const switchStatus = (status: string): void => {
  664. if (loading.value) {
  665. return;
  666. }
  667. if (isSearching.value) {
  668. return
  669. }
  670. isSearching.value = true
  671. currentStatus.value = status
  672. page.value = 1
  673. loadItems()
  674. setTimeout(() => {
  675. isSearching.value = false
  676. }, 100)
  677. }
  678. // 构建申请单数据
  679. const buildApplyData = (status: string): UTSJSONObject => {
  680. const applyLines: UTSJSONObject[] = []
  681. selectedItems.value.forEach((item: SelectedItem) => {
  682. const lineObj = new UTSJSONObject()
  683. lineObj['itemId'] = parseInt(item.itemId)
  684. lineObj['itemCode'] = ''
  685. lineObj['itemName'] = item.itemName
  686. lineObj['specification'] = ''
  687. lineObj['unitOfMeasure'] = ''
  688. lineObj['quantityApply'] = parseInt(item.qty)
  689. lineObj['remark'] = item.remark || ''
  690. applyLines.push(lineObj)
  691. })
  692. const result = new UTSJSONObject()
  693. result['applyCode'] = ''
  694. result['applyName'] = '物料申请'
  695. result['status'] = status
  696. result['remark'] = remark.value
  697. result['wmPurchaseApplyLineList'] = applyLines
  698. return result
  699. }
  700. // 来源页面
  701. const fromIndexPage = ref<boolean>(false)
  702. // 保存申请
  703. const saveApplication = (): void => {
  704. if (selectedItems.value.length === 0) {
  705. uni.showToast({ title: '请选择物料', icon: 'none'})
  706. return
  707. }
  708. // 构建申请单数据
  709. const applyData = buildApplyData('PREPARE')
  710. if (applyData['remark'].length === 0) {
  711. uni.showToast({ title: '请输入用途', icon: 'none'})
  712. return
  713. }
  714. savePurchaseApply(applyData).then((res: any) => {
  715. uni.showToast({ title: '保存成功', icon: 'success'})
  716. // 清空已选列表
  717. selectedItems.value = []
  718. loadItems()
  719. // 如果从index.uvue跳转过来,返回index.uvue
  720. if (fromIndexPage.value) {
  721. setTimeout(() => {
  722. uni.navigateBack()
  723. }, 1000)
  724. }else{
  725. uni.navigateTo({
  726. url: `/pages/apply/index?from=new`
  727. })
  728. }
  729. }).catch((e) => {
  730. const error = e as UTSError
  731. const errMsg = error?.message
  732. uni.showModal({
  733. title: '提示',
  734. content: errMsg.toString(),
  735. showCancel: false,
  736. confirmText: '确定'
  737. })
  738. })
  739. }
  740. // 确认申请
  741. const confirmApplication = (): void => {
  742. if (selectedItems.value.length === 0) {
  743. uni.showToast({ title: '请选择物料', icon: 'none'})
  744. return
  745. }
  746. // 验证所有数量都大于0
  747. for (let i = 0; i < selectedItems.value.length; i++) {
  748. const qty = parseFloat(selectedItems.value[i].qty)
  749. if (qty <= 0) {
  750. uni.showToast({ title: '所有物料数量必须大于0', icon: 'none'})
  751. return
  752. }
  753. }
  754. // 构建申请单数据
  755. const applyData = buildApplyData('CONFIRMED')
  756. if (applyData['remark'].length === 0) {
  757. uni.showToast({ title: '请输入用途', icon: 'none'})
  758. return
  759. }
  760. savePurchaseApply(applyData).then((res: any) => {
  761. uni.showToast({ title: '确认申请成功', icon: 'success'})
  762. // 清空已选列表
  763. selectedItems.value = []
  764. loadItems()
  765. // 如果从index.uvue跳转过来,返回index.uvue
  766. if (fromIndexPage.value) {
  767. setTimeout(() => {
  768. uni.navigateBack()
  769. }, 1000)
  770. }else{
  771. uni.navigateTo({
  772. url: `/pages/apply/index?from=new`
  773. })
  774. }
  775. }).catch((e) => {
  776. const error = e as UTSError
  777. const errMsg = error?.message
  778. uni.showModal({
  779. title: '提示',
  780. content: errMsg.toString(),
  781. showCancel: false,
  782. confirmText: '确定'
  783. })
  784. })
  785. }
  786. // 处理图片更新
  787. const handleImageUpdate = (value: UploadResponse[]): void => {
  788. newMaterial.value.imageUrls = value
  789. }
  790. // 处理图片删除
  791. const handleImageDelete = (index: number, currentList: UploadResponse[]): void => {
  792. deleteImageIndex.value = index
  793. showDeleteConfirm.value = true
  794. }
  795. const confirmDeleteImage = (): void => {
  796. newMaterial.value.imageUrls.splice(deleteImageIndex.value, 1)
  797. showDeleteConfirm.value = false
  798. }
  799. // 处理图片预览
  800. const handleImagePreview = (index: number, urls: string[]): void => {
  801. previewUrls.value = urls
  802. previewIndex.value = index
  803. showImagePreview.value = true
  804. }
  805. const handlePreviewChange = (e: any): void => {
  806. previewIndex.value = e.detail.current
  807. }
  808. // 关闭新增物料弹窗
  809. const closeAddMaterialModal = (): void => {
  810. showAddMaterialModal.value = false
  811. addMaterialError.value = ''
  812. }
  813. // 处理新增/编辑物料
  814. const handleAddMaterial = async (): Promise<void> => {
  815. // 清除之前的错误提示
  816. addMaterialError.value = ''
  817. // 验证输入
  818. if (newMaterial.value.itemName.length == 0) {
  819. uni.showToast({ title: '请输入物料名称', icon: 'none'})
  820. return
  821. }
  822. if (newMaterial.value.measureName.length == 0) {
  823. uni.showToast({ title: '请输入单位', icon: 'none'})
  824. return
  825. }
  826. try {
  827. // 构建物料数据
  828. const materialData = new UTSJSONObject()
  829. materialData['itemShortName'] = newMaterial.value.itemName
  830. materialData['itemName'] = newMaterial.value.itemName + "("+newMaterial.value.specification+")"
  831. materialData['specification'] = newMaterial.value.specification
  832. materialData['measureName'] = newMaterial.value.measureName
  833. materialData['auditStatus'] = 0 // 审核状态为0
  834. // 从 UploadResponse 数组中提取 fileName 并拼接成逗号分隔的字符串
  835. const imageFileNames = newMaterial.value.imageUrls.map((item: UploadResponse) => item.fileName).join(',')
  836. materialData['imageUrls'] = imageFileNames
  837. materialData['productUrl'] = newMaterial.value.productUrl
  838. // 判断是新增还是编辑
  839. if (editingMaterialItem.value != null) {
  840. // 编辑模式
  841. await updateMaterial(editingMaterialItem.value.itemId, materialData)
  842. uni.showToast({ title: '物料修改成功', icon: 'success'})
  843. } else {
  844. // 新增模式
  845. await addMaterial(materialData)
  846. uni.showToast({ title: '物料新增成功', icon: 'success'})
  847. }
  848. // 关闭弹窗
  849. showAddMaterialModal.value = false
  850. // 清空表单
  851. editingMaterialItem.value = null
  852. newMaterial.value = {
  853. itemName: '',
  854. specification: '',
  855. measureName: '',
  856. imageUrls: [],
  857. productUrl: ''
  858. } as NewMaterial
  859. // 重新加载物料列表
  860. loadItems()
  861. } catch (e) {
  862. const error = e as UTSError
  863. const errMsg = error?.message
  864. // 显示错误提示
  865. addMaterialError.value = errMsg.toString()
  866. }
  867. }
  868. const handleDeleteMaterial = (item: Item): void => {
  869. uni.showModal({
  870. title: '确认删除',
  871. content: `确定要删除物料「${item.itemName}」吗?`,
  872. success: (res) => {
  873. if (res.confirm) {
  874. deleteMaterial(item.itemId).then(() => {
  875. uni.showToast({
  876. title: '删除成功',
  877. icon: 'success',
  878. })
  879. loadItems()
  880. }).catch((e) => {
  881. const error = e as UTSError
  882. const errMsg = error?.message
  883. uni.showModal({
  884. title: '删除失败',
  885. content: errMsg.toString(),
  886. showCancel: false,
  887. confirmText: '确定'
  888. })
  889. })
  890. }
  891. }
  892. })
  893. }
  894. onMounted(() => {
  895. loadCategories()
  896. loadMeasureList()
  897. // 获取当前登录用户信息
  898. const userInfo = getUserInfo()
  899. if (userInfo != null) {
  900. currentUserName.value = userInfo['userName'] != null ? userInfo['userName'].toString() : ''
  901. }
  902. // 获取页面参数,判断是否从index.uvue跳转过来
  903. const pages = getCurrentPages()
  904. const currentPage = pages[pages.length - 1]
  905. const options = currentPage.options
  906. if (options != null && options.from == 'index') {
  907. fromIndexPage.value = true
  908. }
  909. })
  910. </script>
  911. <style lang="scss">
  912. .page-container {
  913. flex: 1;
  914. background-color: #f5f8fe;
  915. padding-top: env(safe-area-inset-top);
  916. background-color: #e8f0f9;
  917. padding: 0rpx 20rpx 0rpx 20rpx;
  918. }
  919. .page-content {
  920. flex: 1;
  921. padding: 0rpx;
  922. padding-bottom: 150rpx;
  923. box-sizing: border-box;
  924. }
  925. .section {
  926. margin-top: 10rpx;
  927. padding: 0 10rpx 10rpx;
  928. background: #ffffff;
  929. border-radius: 16rpx;
  930. .section-header {
  931. flex-direction: row;
  932. align-items: center;
  933. justify-content: space-between;
  934. padding: 30rpx 10rpx 20rpx;
  935. }
  936. .section-header-left {
  937. flex-direction: row;
  938. align-items: center;
  939. }
  940. .add-material-btn {
  941. padding: 8rpx 16rpx;
  942. background-color: #007aff;
  943. border-radius: 8rpx;
  944. }
  945. .add-material-text {
  946. color: #ffffff;
  947. font-size: 24rpx;
  948. font-weight: bold;
  949. }
  950. &-indicator {
  951. width: 6rpx;
  952. height: 32rpx;
  953. background-color: #007aff;
  954. border-radius: 3rpx;
  955. margin-right: 12rpx;
  956. }
  957. &-title {
  958. font-size: 36rpx;
  959. color: #333333;
  960. font-weight: bold;
  961. }
  962. }
  963. .search-bar {
  964. padding: 10rpx 3rpx;
  965. }
  966. .search-box {
  967. flex-direction: row;
  968. align-items: center;
  969. height: 72rpx;
  970. padding: 0 24rpx;
  971. background-color: #f5f5f5;
  972. border-radius: 16rpx;
  973. .search-icon {
  974. width: 32rpx;
  975. height: 32rpx;
  976. margin-right: 12rpx;
  977. }
  978. .search-input {
  979. flex: 1;
  980. font-size: 28rpx;
  981. color: #333333;
  982. }
  983. .search-btn {
  984. padding: 10rpx 20rpx;
  985. background-color: #007aff;
  986. border-radius: 8rpx;
  987. margin-left: 10rpx;
  988. }
  989. .search-btn-text {
  990. color: #ffffff;
  991. font-size: 24rpx;
  992. }
  993. .clear-btn {
  994. width: 36rpx;
  995. height: 36rpx;
  996. border-radius: 18rpx;
  997. background-color: #cccccc;
  998. align-items: center;
  999. justify-content: center;
  1000. margin-left: 10rpx;
  1001. }
  1002. .clear-btn-text {
  1003. color: #ffffff;
  1004. font-size: 24rpx;
  1005. font-weight: bold;
  1006. }
  1007. }
  1008. .status-tabs {
  1009. padding: 20rpx 30rpx;
  1010. background-color: #ffffff;
  1011. border-bottom: 1rpx solid #eeeeee;
  1012. }
  1013. .scroll-view_H {
  1014. width: 100%;
  1015. flex-direction: row;
  1016. }
  1017. .status-tab {
  1018. padding: 16rpx 24rpx;
  1019. text-align: center;
  1020. margin-right: 16rpx;
  1021. border-radius: 8rpx;
  1022. background-color: #f5f5f5;
  1023. flex-shrink: 0;
  1024. &:last-child {
  1025. margin-right: 0;
  1026. }
  1027. &.active {
  1028. background-color: #007aff;
  1029. }
  1030. .status-tab-text {
  1031. font-size: 26rpx;
  1032. color: #666666;
  1033. &.active-text {
  1034. color: #ffffff;
  1035. font-weight: bold;
  1036. }
  1037. }
  1038. }
  1039. .list-item {
  1040. margin: 3rpx;
  1041. padding: 10rpx 10rpx 0rpx 10rpx;
  1042. border-bottom: 1px solid #f9f9f9;
  1043. }
  1044. .item-header {
  1045. display: flex;
  1046. flex-direction: row;
  1047. align-items: flex-start;
  1048. margin-bottom: 10rpx;
  1049. }
  1050. .item-info {
  1051. flex: 1;
  1052. min-width: 0;
  1053. }
  1054. .item-actions {
  1055. flex-shrink: 0;
  1056. display: flex;
  1057. align-items: center;
  1058. gap: 10rpx;
  1059. margin-left: 20rpx;
  1060. }
  1061. .item-title {
  1062. flex: 1;
  1063. }
  1064. .item-name {
  1065. font-size: 28rpx;
  1066. color: #333333;
  1067. font-weight: bold;
  1068. word-break: break-all;
  1069. overflow: hidden;
  1070. text-overflow: ellipsis;
  1071. display: -webkit-box;
  1072. -webkit-line-clamp: 2;
  1073. -webkit-box-orient: vertical;
  1074. &.status-0 {
  1075. color: #ff4d4f;
  1076. }
  1077. &.status-2 {
  1078. color: #999999;
  1079. }
  1080. }
  1081. .item-name-row {
  1082. display: flex;
  1083. flex-wrap: wrap;
  1084. align-items: flex-start;
  1085. }
  1086. .item-measure {
  1087. font-size: 24rpx;
  1088. color: #999999;
  1089. margin-left: 10rpx;
  1090. }
  1091. .item-sub-title {
  1092. flex: 1;
  1093. font-size: 23rpx;
  1094. color: #797979;
  1095. margin-left: 10rpx;
  1096. }
  1097. .item-sub-row {
  1098. flex-direction: row;
  1099. align-items: center;
  1100. }
  1101. .item-stock {
  1102. font-size: 23rpx;
  1103. color: #52c41a;
  1104. margin-left: 20rpx;
  1105. }
  1106. .item-measure {
  1107. font-size: 23rpx;
  1108. color: #999999;
  1109. margin-left: 10rpx;
  1110. }
  1111. .add-btn {
  1112. width: 44rpx;
  1113. height: 44rpx;
  1114. border-radius: 22rpx;
  1115. background-color: #165DFF;
  1116. color: #FFFFFF;
  1117. align-items: center;
  1118. justify-content: center;
  1119. }
  1120. .add-btn.disabled {
  1121. background-color: #cccccc;
  1122. }
  1123. .added-btn {
  1124. padding: 8rpx 16rpx;
  1125. border-radius: 8rpx;
  1126. align-items: center;
  1127. justify-content: center;
  1128. }
  1129. .added-icon {
  1130. color: #ff4d4f;
  1131. font-size: 24rpx;
  1132. }
  1133. .detail-link {
  1134. font-size: 21rpx;
  1135. color: #999999;
  1136. }
  1137. .material-list {
  1138. }
  1139. .pagination {
  1140. flex-direction: row;
  1141. display: flex;
  1142. align-items: center;
  1143. justify-content: center;
  1144. padding: 20rpx;
  1145. gap: 30rpx;
  1146. }
  1147. .page-btn {
  1148. padding: 10rpx 20rpx;
  1149. margin: 5px;
  1150. background-color: #165DFF;
  1151. border-radius: 8rpx;
  1152. }
  1153. .page-btn.disabled {
  1154. background-color: #cccccc;
  1155. }
  1156. .page-btn-text {
  1157. color: #FFFFFF;
  1158. font-size: 26rpx;
  1159. }
  1160. .page-info {
  1161. font-size: 26rpx;
  1162. color: #666666;
  1163. }
  1164. .selected-list {
  1165. padding: 20rpx;
  1166. background-color: #ffffff;
  1167. min-height: 150rpx;
  1168. display: flex;
  1169. flex-direction: column;
  1170. gap: 15rpx;
  1171. }
  1172. .empty-tip {
  1173. display: flex;
  1174. align-items: center;
  1175. justify-content: center;
  1176. padding: 40rpx;
  1177. }
  1178. .empty-tip-text {
  1179. color: #999999;
  1180. font-size: 28rpx;
  1181. }
  1182. .selected-item {
  1183. display: flex;
  1184. flex-direction: column;
  1185. background-color: #ffffff;
  1186. border-radius: 10rpx;
  1187. padding: 16rpx 20rpx;
  1188. border: 1rpx solid #e5e5e5;
  1189. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.05);
  1190. margin-bottom: 12rpx;
  1191. }
  1192. .selected-item-row1 {
  1193. margin-bottom: 8rpx;
  1194. }
  1195. .selected-item-row1-extra {
  1196. display: flex;
  1197. flex-direction: row;
  1198. align-items: center;
  1199. }
  1200. .selected-item-body {
  1201. display: flex;
  1202. flex-direction: row;
  1203. }
  1204. .selected-item-content {
  1205. flex: 1;
  1206. }
  1207. .selected-item-row2 {
  1208. margin-top: 10rpx;
  1209. }
  1210. .selected-item-name {
  1211. font-size: 26rpx;
  1212. color: #333333;
  1213. font-weight: 500;
  1214. word-break: break-all;
  1215. }
  1216. .selected-item-remark-row {
  1217. margin-top: 10rpx;
  1218. }
  1219. .selected-item-remark {
  1220. width: 100%;
  1221. height: 56rpx;
  1222. padding: 0 16rpx;
  1223. background-color: #f5f5f5;
  1224. border-radius: 6rpx;
  1225. font-size: 24rpx;
  1226. color: #333333;
  1227. border: 1rpx solid #e5e5e5;
  1228. }
  1229. .selected-item-measure {
  1230. font-size: 24rpx;
  1231. color: #999999;
  1232. margin-right: 20rpx;
  1233. flex-shrink: 0;
  1234. }
  1235. .quantity-control {
  1236. display: flex;
  1237. flex-direction: row;
  1238. align-items: center;
  1239. margin-right: auto;
  1240. flex-shrink: 0;
  1241. }
  1242. .qty-btn {
  1243. width: 44rpx;
  1244. height: 44rpx;
  1245. background-color: #f5f5f5;
  1246. border-radius: 6rpx;
  1247. align-items: center;
  1248. justify-content: center;
  1249. border: 1rpx solid #e5e5e5;
  1250. }
  1251. .qty-btn-text {
  1252. color: #333333;
  1253. font-size: 28rpx;
  1254. font-weight: bold;
  1255. }
  1256. .quantity-input {
  1257. width: 220rpx;
  1258. height: 44rpx;
  1259. background-color: #f5f5f5;
  1260. border-radius: 6rpx;
  1261. font-size: 24rpx;
  1262. padding: 0 10rpx;
  1263. border: 1rpx solid #e5e5e5;
  1264. text-align: center;
  1265. margin: 0 10rpx;
  1266. }
  1267. .quantity-input:focus {
  1268. outline: none;
  1269. border-color: #007aff;
  1270. background-color: #ffffff;
  1271. }
  1272. /* 物料列表的删除按钮 */
  1273. .material-delete-btn {
  1274. width: 44rpx;
  1275. height: 44rpx;
  1276. border-radius: 22rpx;
  1277. background-color: #ff4d4f;
  1278. color: #FFFFFF;
  1279. align-items: center;
  1280. justify-content: center;
  1281. display: flex;
  1282. flex-shrink: 0;
  1283. }
  1284. /* 选中物料列表的删除按钮 */
  1285. .selected-delete-btn {
  1286. width: 44rpx;
  1287. height: 44rpx;
  1288. border-radius: 50%;
  1289. background-color: #ff4d4f;
  1290. align-items: center;
  1291. justify-content: center;
  1292. display: flex;
  1293. flex-shrink: 0;
  1294. margin-left: 16rpx;
  1295. align-self: center;
  1296. }
  1297. .delete-icon {
  1298. color: #ffffff;
  1299. font-size: 30rpx;
  1300. font-weight: bold;
  1301. }
  1302. /* 底部按钮 */
  1303. .bottom-buttons {
  1304. padding: 20rpx;
  1305. background-color: #ffffff;
  1306. border-top: 1rpx solid #e5e5e5;
  1307. position: fixed;
  1308. bottom: 0;
  1309. left: 0;
  1310. right: 0;
  1311. z-index: 100;
  1312. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  1313. }
  1314. .btn-row {
  1315. flex-direction: row;
  1316. display: flex;
  1317. gap: 20rpx;
  1318. }
  1319. .save-btn {
  1320. width: 180rpx;
  1321. height: 80rpx;
  1322. background-color: #f5f5f5;
  1323. color: #333333;
  1324. font-size: 28rpx;
  1325. font-weight: 500;
  1326. border-radius: 20rpx;
  1327. border: 1rpx solid #e5e5e5;
  1328. }
  1329. .confirm-btn {
  1330. flex: 1;
  1331. height: 80rpx;
  1332. background-color: #007aff;
  1333. color: #ffffff;
  1334. font-size: 28rpx;
  1335. font-weight: 600;
  1336. border-radius: 20rpx;
  1337. margin-left: 10rpx;
  1338. border: none;
  1339. box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
  1340. }
  1341. /* 新增物料弹窗样式 */
  1342. .picker-modal {
  1343. position: fixed;
  1344. top: 0;
  1345. left: 0;
  1346. right: 0;
  1347. bottom: 0;
  1348. z-index: 1000;
  1349. display: flex;
  1350. align-items: center;
  1351. justify-content: center;
  1352. }
  1353. .modal-mask {
  1354. position: absolute;
  1355. top: 0;
  1356. left: 0;
  1357. right: 0;
  1358. bottom: 0;
  1359. background-color: rgba(0, 0, 0, 0.5);
  1360. }
  1361. .modal-content {
  1362. position: relative;
  1363. width: 90%;
  1364. // max-width: 500rpx;
  1365. background-color: #ffffff;
  1366. border-radius: 16rpx;
  1367. padding: 30rpx;
  1368. box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
  1369. }
  1370. .modal-header {
  1371. display: flex;
  1372. flex-direction: row;
  1373. justify-content: space-between;
  1374. align-items: center;
  1375. margin-bottom: 30rpx;
  1376. padding-bottom: 20rpx;
  1377. border-bottom: 1rpx solid #e5e5e5;
  1378. }
  1379. .modal-title {
  1380. font-size: 32rpx;
  1381. font-weight: bold;
  1382. color: #333333;
  1383. }
  1384. .modal-close {
  1385. font-size: 28rpx;
  1386. color: #999999;
  1387. padding: 8rpx 16rpx;
  1388. border-radius: 8rpx;
  1389. background-color: #f5f5f5;
  1390. }
  1391. .form-item-input {
  1392. display: flex;
  1393. flex-direction: column;
  1394. margin-bottom: 24rpx;
  1395. }
  1396. .label-picker {
  1397. font-size: 28rpx;
  1398. color: #333333;
  1399. margin-bottom: 12rpx;
  1400. font-weight: 500;
  1401. }
  1402. .view-input-picker {
  1403. position: relative;
  1404. width: 100%;
  1405. }
  1406. .input-picker {
  1407. width: 100%;
  1408. height: 80rpx;
  1409. padding: 0 24rpx;
  1410. background-color: #f5f5f5;
  1411. border-radius: 12rpx;
  1412. font-size: 28rpx;
  1413. color: #333333;
  1414. border: 1rpx solid #e5e5e5;
  1415. }
  1416. .input-picker:focus {
  1417. outline: none;
  1418. border-color: #007aff;
  1419. background-color: #ffffff;
  1420. }
  1421. .view-textarea-picker {
  1422. position: relative;
  1423. width: 100%;
  1424. }
  1425. .textarea-picker {
  1426. width: 100%;
  1427. min-height: 120rpx;
  1428. padding: 20rpx 24rpx;
  1429. background-color: #f5f5f5;
  1430. border-radius: 12rpx;
  1431. font-size: 28rpx;
  1432. color: #333333;
  1433. border: 1rpx solid #e5e5e5;
  1434. box-sizing: border-box;
  1435. }
  1436. .textarea-picker:focus {
  1437. outline: none;
  1438. border-color: #007aff;
  1439. background-color: #ffffff;
  1440. }
  1441. .form-item-btn {
  1442. margin-top: 30rpx;
  1443. display: flex;
  1444. justify-content: center;
  1445. }
  1446. .error-tip {
  1447. display: flex;
  1448. flex-direction: row;
  1449. align-items: center;
  1450. justify-content: space-between;
  1451. margin: 20rpx;
  1452. padding: 16rpx 20rpx;
  1453. background-color: #fff2f0;
  1454. border: 1rpx solid #ffccc7;
  1455. border-radius: 8rpx;
  1456. }
  1457. .error-tip-text {
  1458. flex: 1;
  1459. font-size: 26rpx;
  1460. color: #ff4d4f;
  1461. }
  1462. .error-tip-close {
  1463. margin-left: 16rpx;
  1464. font-size: 32rpx;
  1465. color: #999999;
  1466. font-weight: bold;
  1467. }
  1468. .btn-primary {
  1469. width: 100%;
  1470. height: 80rpx;
  1471. background-color: #007aff;
  1472. color: #ffffff;
  1473. font-size: 28rpx;
  1474. font-weight: 600;
  1475. border-radius: 12rpx;
  1476. border: none;
  1477. box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
  1478. }
  1479. .add-icon{
  1480. color: #ffffff;
  1481. }
  1482. .measure-list {
  1483. max-height: 500rpx;
  1484. overflow-y: auto;
  1485. }
  1486. .measure-item {
  1487. padding: 24rpx;
  1488. border-bottom: 1rpx solid #f0f0f0;
  1489. }
  1490. .measure-name {
  1491. font-size: 28rpx;
  1492. color: #333333;
  1493. }
  1494. .measure-input-row {
  1495. flex-direction: row;
  1496. align-items: center;
  1497. }
  1498. .measure-input-row .input-picker {
  1499. flex: 1;
  1500. margin-right: 16rpx;
  1501. }
  1502. .pick-btn {
  1503. padding: 16rpx 24rpx;
  1504. background-color: #007aff;
  1505. border-radius: 8rpx;
  1506. }
  1507. .pick-btn-text {
  1508. color: #ffffff;
  1509. font-size: 26rpx;
  1510. }
  1511. /* 备注输入框样式 */
  1512. .remark-section {
  1513. padding: 20rpx;
  1514. background-color: #ffffff;
  1515. }
  1516. .remark-input {
  1517. width: 100%;
  1518. min-height: 200rpx;
  1519. padding: 20rpx;
  1520. background-color: #f5f5f5;
  1521. border-radius: 12rpx;
  1522. font-size: 28rpx;
  1523. color: #333333;
  1524. border: 1rpx solid #e5e5e5;
  1525. resize: none;
  1526. box-sizing: border-box;
  1527. }
  1528. .remark-input:focus {
  1529. outline: none;
  1530. border-color: #007aff;
  1531. background-color: #ffffff;
  1532. }
  1533. .remark-count {
  1534. display: block;
  1535. text-align: right;
  1536. margin-top: 10rpx;
  1537. font-size: 24rpx;
  1538. color: #999999;
  1539. }
  1540. /* 图片上传样式 */
  1541. .image-upload-container {
  1542. display: flex;
  1543. flex-direction: row;
  1544. flex-wrap: wrap;
  1545. gap: 16rpx;
  1546. margin-top: 12rpx;
  1547. }
  1548. .uploaded-image {
  1549. position: relative;
  1550. width: 160rpx;
  1551. height: 160rpx;
  1552. border-radius: 8rpx;
  1553. overflow: hidden;
  1554. border: 1rpx solid #e5e5e5;
  1555. }
  1556. .uploaded-image-item {
  1557. width: 100%;
  1558. height: 100%;
  1559. }
  1560. .image-delete-btn {
  1561. position: absolute;
  1562. top: 8rpx;
  1563. right: 8rpx;
  1564. width: 36rpx;
  1565. height: 36rpx;
  1566. border-radius: 18rpx;
  1567. background-color: rgba(0, 0, 0, 0.6);
  1568. display: flex;
  1569. align-items: center;
  1570. justify-content: center;
  1571. }
  1572. .image-delete-icon {
  1573. color: #ffffff;
  1574. font-size: 28rpx;
  1575. font-weight: bold;
  1576. }
  1577. .upload-btn {
  1578. width: 160rpx;
  1579. height: 160rpx;
  1580. border-radius: 8rpx;
  1581. border: 2rpx dashed #e5e5e5;
  1582. display: flex;
  1583. flex-direction: column;
  1584. align-items: center;
  1585. justify-content: center;
  1586. background-color: #fafafa;
  1587. }
  1588. .upload-btn-icon {
  1589. font-size: 48rpx;
  1590. color: #999999;
  1591. margin-bottom: 8rpx;
  1592. }
  1593. .upload-btn-text {
  1594. font-size: 24rpx;
  1595. color: #999999;
  1596. }
  1597. /* 删除确认弹窗样式 */
  1598. .delete-confirm-modal {
  1599. position: fixed;
  1600. top: 0;
  1601. left: 0;
  1602. right: 0;
  1603. bottom: 0;
  1604. z-index: 10000;
  1605. display: flex;
  1606. align-items: center;
  1607. justify-content: center;
  1608. }
  1609. .delete-confirm-mask {
  1610. position: absolute;
  1611. top: 0;
  1612. left: 0;
  1613. right: 0;
  1614. bottom: 0;
  1615. background-color: rgba(0, 0, 0, 0.5);
  1616. }
  1617. .delete-confirm-content {
  1618. position: relative;
  1619. width: 600rpx;
  1620. background-color: #ffffff;
  1621. border-radius: 16rpx;
  1622. padding: 40rpx;
  1623. display: flex;
  1624. flex-direction: column;
  1625. align-items: center;
  1626. }
  1627. .delete-confirm-title {
  1628. font-size: 32rpx;
  1629. font-weight: bold;
  1630. color: #333333;
  1631. margin-bottom: 20rpx;
  1632. }
  1633. .delete-confirm-text {
  1634. font-size: 28rpx;
  1635. color: #666666;
  1636. margin-bottom: 40rpx;
  1637. }
  1638. .delete-confirm-btns {
  1639. display: flex;
  1640. flex-direction: row;
  1641. gap: 40rpx;
  1642. }
  1643. .delete-confirm-cancel {
  1644. padding: 20rpx 60rpx;
  1645. background-color: #f5f5f5;
  1646. border-radius: 12rpx;
  1647. }
  1648. .delete-confirm-cancel-text {
  1649. font-size: 28rpx;
  1650. color: #666666;
  1651. }
  1652. .delete-confirm-ok {
  1653. padding: 20rpx 60rpx;
  1654. background-color: #ff4d4f;
  1655. border-radius: 12rpx;
  1656. }
  1657. .delete-confirm-ok-text {
  1658. font-size: 28rpx;
  1659. color: #ffffff;
  1660. }
  1661. /* 图片预览弹窗样式 */
  1662. .image-preview-modal {
  1663. position: fixed;
  1664. top: 0;
  1665. left: 0;
  1666. right: 0;
  1667. bottom: 0;
  1668. background-color: #000000;
  1669. z-index: 10000;
  1670. display: flex;
  1671. align-items: center;
  1672. justify-content: center;
  1673. }
  1674. .preview-swiper {
  1675. width: 100%;
  1676. height: 80%;
  1677. }
  1678. .preview-image {
  1679. width: 100%;
  1680. height: 100%;
  1681. }
  1682. .preview-close {
  1683. position: absolute;
  1684. top: 80rpx;
  1685. right: 30rpx;
  1686. width: 60rpx;
  1687. height: 60rpx;
  1688. border-radius: 30rpx;
  1689. background-color: rgba(255, 255, 255, 0.3);
  1690. display: flex;
  1691. align-items: center;
  1692. justify-content: center;
  1693. }
  1694. .preview-close-text {
  1695. font-size: 40rpx;
  1696. color: #ffffff;
  1697. }
  1698. .preview-indicator {
  1699. position: absolute;
  1700. bottom: 100rpx;
  1701. left: 50%;
  1702. transform: translateX(-50%);
  1703. padding: 10rpx 30rpx;
  1704. background-color: rgba(0, 0, 0, 0.5);
  1705. border-radius: 20rpx;
  1706. }
  1707. .preview-indicator-text {
  1708. font-size: 28rpx;
  1709. color: #ffffff;
  1710. }
  1711. </style>