applyNew.uvue 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884
  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. return mdItem.measureName
  616. }
  617. const getStockNum = (item: any | null): string => {
  618. if (item == null) return '0'
  619. const mdItem = item as Item
  620. const stock = mdItem.stockNum != null ? mdItem.stockNum : 0
  621. return stock.toString()
  622. }
  623. const getAuditStatus = (item: any | null): number => {
  624. if (item == null) return -1
  625. const mdItem = item as Item
  626. return mdItem.auditStatus != null ? mdItem.auditStatus : -1
  627. }
  628. const isItemDisabled = (item: any | null): boolean => {
  629. if (item == null) return false
  630. const mdItem = item as Item
  631. const status = mdItem.auditStatus != null ? mdItem.auditStatus : -1
  632. return status == 3
  633. }
  634. // 判断物料是否可删除(创建人是当前用户)
  635. const canDeleteMaterial = (item: any | null): boolean => {
  636. if (item == null) return false
  637. const mdItem = item as Item
  638. const createBy = mdItem.createBy != null ? mdItem.createBy : ''
  639. return createBy === currentUserName.value
  640. }
  641. // 检查物料是否已被选择
  642. const isItemSelected = (item: any | null): boolean => {
  643. if (item == null) return false
  644. const mdItem = item as Item
  645. return selectedItems.value.find((s: SelectedItem) => s.itemId === mdItem.itemId) != null
  646. }
  647. const handleSearch = (): void => {
  648. const timer = searchTimer
  649. if (timer != null) {
  650. clearTimeout(timer)
  651. }
  652. searchTimer = setTimeout(() => {
  653. page.value = 1
  654. loadItems()
  655. }, 300)
  656. }
  657. const clearKeyword = (): void => {
  658. keyword.value = ''
  659. page.value = 1
  660. loadItems()
  661. }
  662. const switchStatus = (status: string): void => {
  663. if (loading.value) {
  664. return;
  665. }
  666. if (isSearching.value) {
  667. return
  668. }
  669. isSearching.value = true
  670. currentStatus.value = status
  671. page.value = 1
  672. loadItems()
  673. setTimeout(() => {
  674. isSearching.value = false
  675. }, 100)
  676. }
  677. // 构建申请单数据
  678. const buildApplyData = (status: string): UTSJSONObject => {
  679. const applyLines: UTSJSONObject[] = []
  680. selectedItems.value.forEach((item: SelectedItem) => {
  681. const lineObj = new UTSJSONObject()
  682. lineObj['itemId'] = parseInt(item.itemId)
  683. lineObj['itemCode'] = ''
  684. lineObj['itemName'] = item.itemName
  685. lineObj['specification'] = ''
  686. lineObj['unitOfMeasure'] = ''
  687. lineObj['quantityApply'] = parseInt(item.qty)
  688. lineObj['remark'] = item.remark || ''
  689. applyLines.push(lineObj)
  690. })
  691. const result = new UTSJSONObject()
  692. result['applyCode'] = ''
  693. result['applyName'] = '物料申请'
  694. result['status'] = status
  695. result['remark'] = remark.value
  696. result['wmPurchaseApplyLineList'] = applyLines
  697. return result
  698. }
  699. // 来源页面
  700. const fromIndexPage = ref<boolean>(false)
  701. // 保存申请
  702. const saveApplication = (): void => {
  703. if (selectedItems.value.length === 0) {
  704. uni.showToast({ title: '请选择物料', icon: 'none'})
  705. return
  706. }
  707. // 构建申请单数据
  708. const applyData = buildApplyData('PREPARE')
  709. if (applyData['remark'].length === 0) {
  710. uni.showToast({ title: '请输入用途', icon: 'none'})
  711. return
  712. }
  713. savePurchaseApply(applyData).then((res: any) => {
  714. uni.showToast({ title: '保存成功', icon: 'success'})
  715. // 清空已选列表
  716. selectedItems.value = []
  717. loadItems()
  718. // 如果从index.uvue跳转过来,返回index.uvue
  719. if (fromIndexPage.value) {
  720. setTimeout(() => {
  721. uni.navigateBack()
  722. }, 1000)
  723. }else{
  724. uni.navigateTo({
  725. url: `/pages/apply/index?from=new`
  726. })
  727. }
  728. }).catch((e) => {
  729. const error = e as UTSError
  730. const errMsg = error?.message
  731. uni.showModal({
  732. title: '提示',
  733. content: errMsg.toString(),
  734. showCancel: false,
  735. confirmText: '确定'
  736. })
  737. })
  738. }
  739. // 确认申请
  740. const confirmApplication = (): void => {
  741. if (selectedItems.value.length === 0) {
  742. uni.showToast({ title: '请选择物料', icon: 'none'})
  743. return
  744. }
  745. // 验证所有数量都大于0
  746. for (let i = 0; i < selectedItems.value.length; i++) {
  747. const qty = parseFloat(selectedItems.value[i].qty)
  748. if (qty <= 0) {
  749. uni.showToast({ title: '所有物料数量必须大于0', icon: 'none'})
  750. return
  751. }
  752. }
  753. // 构建申请单数据
  754. const applyData = buildApplyData('CONFIRMED')
  755. if (applyData['remark'].length === 0) {
  756. uni.showToast({ title: '请输入用途', icon: 'none'})
  757. return
  758. }
  759. savePurchaseApply(applyData).then((res: any) => {
  760. uni.showToast({ title: '确认申请成功', icon: 'success'})
  761. // 清空已选列表
  762. selectedItems.value = []
  763. loadItems()
  764. // 如果从index.uvue跳转过来,返回index.uvue
  765. if (fromIndexPage.value) {
  766. setTimeout(() => {
  767. uni.navigateBack()
  768. }, 1000)
  769. }else{
  770. uni.navigateTo({
  771. url: `/pages/apply/index?from=new`
  772. })
  773. }
  774. }).catch((e) => {
  775. const error = e as UTSError
  776. const errMsg = error?.message
  777. uni.showModal({
  778. title: '提示',
  779. content: errMsg.toString(),
  780. showCancel: false,
  781. confirmText: '确定'
  782. })
  783. })
  784. }
  785. // 处理图片更新
  786. const handleImageUpdate = (value: UploadResponse[]): void => {
  787. newMaterial.value.imageUrls = value
  788. }
  789. // 处理图片删除
  790. const handleImageDelete = (index: number, currentList: UploadResponse[]): void => {
  791. deleteImageIndex.value = index
  792. showDeleteConfirm.value = true
  793. }
  794. const confirmDeleteImage = (): void => {
  795. newMaterial.value.imageUrls.splice(deleteImageIndex.value, 1)
  796. showDeleteConfirm.value = false
  797. }
  798. // 处理图片预览
  799. const handleImagePreview = (index: number, urls: string[]): void => {
  800. previewUrls.value = urls
  801. previewIndex.value = index
  802. showImagePreview.value = true
  803. }
  804. const handlePreviewChange = (e: any): void => {
  805. previewIndex.value = e.detail.current
  806. }
  807. // 关闭新增物料弹窗
  808. const closeAddMaterialModal = (): void => {
  809. showAddMaterialModal.value = false
  810. addMaterialError.value = ''
  811. }
  812. // 处理新增/编辑物料
  813. const handleAddMaterial = async (): Promise<void> => {
  814. // 清除之前的错误提示
  815. addMaterialError.value = ''
  816. // 验证输入
  817. if (newMaterial.value.itemName.length == 0) {
  818. uni.showToast({ title: '请输入物料名称', icon: 'none'})
  819. return
  820. }
  821. if (newMaterial.value.measureName.length == 0) {
  822. uni.showToast({ title: '请输入单位', icon: 'none'})
  823. return
  824. }
  825. try {
  826. // 构建物料数据
  827. const materialData = new UTSJSONObject()
  828. materialData['itemShortName'] = newMaterial.value.itemName
  829. materialData['itemName'] = newMaterial.value.itemName + "("+newMaterial.value.specification+")"
  830. materialData['specification'] = newMaterial.value.specification
  831. materialData['measureName'] = newMaterial.value.measureName
  832. materialData['auditStatus'] = 0 // 审核状态为0
  833. // 从 UploadResponse 数组中提取 fileName 并拼接成逗号分隔的字符串
  834. const imageFileNames = newMaterial.value.imageUrls.map((item: UploadResponse) => item.fileName).join(',')
  835. materialData['imageUrls'] = imageFileNames
  836. materialData['productUrl'] = newMaterial.value.productUrl
  837. // 判断是新增还是编辑
  838. if (editingMaterialItem.value != null) {
  839. // 编辑模式
  840. await updateMaterial(editingMaterialItem.value.itemId, materialData)
  841. uni.showToast({ title: '物料修改成功', icon: 'success'})
  842. } else {
  843. // 新增模式
  844. await addMaterial(materialData)
  845. uni.showToast({ title: '物料新增成功', icon: 'success'})
  846. }
  847. // 关闭弹窗
  848. showAddMaterialModal.value = false
  849. // 清空表单
  850. editingMaterialItem.value = null
  851. newMaterial.value = {
  852. itemName: '',
  853. specification: '',
  854. measureName: '',
  855. imageUrls: [],
  856. productUrl: ''
  857. } as NewMaterial
  858. // 重新加载物料列表
  859. loadItems()
  860. } catch (e) {
  861. const error = e as UTSError
  862. const errMsg = error?.message
  863. // 显示错误提示
  864. addMaterialError.value = errMsg.toString()
  865. }
  866. }
  867. const handleDeleteMaterial = (item: Item): void => {
  868. uni.showModal({
  869. title: '确认删除',
  870. content: `确定要删除物料「${item.itemName}」吗?`,
  871. success: (res) => {
  872. if (res.confirm) {
  873. deleteMaterial(item.itemId).then(() => {
  874. uni.showToast({
  875. title: '删除成功',
  876. icon: 'success',
  877. })
  878. loadItems()
  879. }).catch((e) => {
  880. const error = e as UTSError
  881. const errMsg = error?.message
  882. uni.showModal({
  883. title: '删除失败',
  884. content: errMsg.toString(),
  885. showCancel: false,
  886. confirmText: '确定'
  887. })
  888. })
  889. }
  890. }
  891. })
  892. }
  893. onMounted(() => {
  894. loadCategories()
  895. loadMeasureList()
  896. // 获取当前登录用户信息
  897. const userInfo = getUserInfo()
  898. if (userInfo != null) {
  899. currentUserName.value = userInfo['userName'] != null ? userInfo['userName'].toString() : ''
  900. }
  901. // 获取页面参数,判断是否从index.uvue跳转过来
  902. const pages = getCurrentPages()
  903. const currentPage = pages[pages.length - 1]
  904. const options = currentPage.options
  905. if (options != null && options.from == 'index') {
  906. fromIndexPage.value = true
  907. }
  908. })
  909. </script>
  910. <style lang="scss">
  911. .page-container {
  912. flex: 1;
  913. background-color: #f5f8fe;
  914. padding-top: env(safe-area-inset-top);
  915. background-color: #e8f0f9;
  916. padding: 0rpx 20rpx 0rpx 20rpx;
  917. }
  918. .page-content {
  919. flex: 1;
  920. padding: 0rpx;
  921. padding-bottom: 150rpx;
  922. box-sizing: border-box;
  923. }
  924. .section {
  925. margin-top: 10rpx;
  926. padding: 0 10rpx 10rpx;
  927. background: #ffffff;
  928. border-radius: 16rpx;
  929. .section-header {
  930. flex-direction: row;
  931. align-items: center;
  932. justify-content: space-between;
  933. padding: 30rpx 10rpx 20rpx;
  934. }
  935. .section-header-left {
  936. flex-direction: row;
  937. align-items: center;
  938. }
  939. .add-material-btn {
  940. padding: 8rpx 16rpx;
  941. background-color: #007aff;
  942. border-radius: 8rpx;
  943. }
  944. .add-material-text {
  945. color: #ffffff;
  946. font-size: 24rpx;
  947. font-weight: bold;
  948. }
  949. &-indicator {
  950. width: 6rpx;
  951. height: 32rpx;
  952. background-color: #007aff;
  953. border-radius: 3rpx;
  954. margin-right: 12rpx;
  955. }
  956. &-title {
  957. font-size: 36rpx;
  958. color: #333333;
  959. font-weight: bold;
  960. }
  961. }
  962. .search-bar {
  963. padding: 10rpx 3rpx;
  964. }
  965. .search-box {
  966. flex-direction: row;
  967. align-items: center;
  968. height: 72rpx;
  969. padding: 0 24rpx;
  970. background-color: #f5f5f5;
  971. border-radius: 16rpx;
  972. .search-icon {
  973. width: 32rpx;
  974. height: 32rpx;
  975. margin-right: 12rpx;
  976. }
  977. .search-input {
  978. flex: 1;
  979. font-size: 28rpx;
  980. color: #333333;
  981. }
  982. .search-btn {
  983. padding: 10rpx 20rpx;
  984. background-color: #007aff;
  985. border-radius: 8rpx;
  986. margin-left: 10rpx;
  987. }
  988. .search-btn-text {
  989. color: #ffffff;
  990. font-size: 24rpx;
  991. }
  992. .clear-btn {
  993. width: 36rpx;
  994. height: 36rpx;
  995. border-radius: 18rpx;
  996. background-color: #cccccc;
  997. align-items: center;
  998. justify-content: center;
  999. margin-left: 10rpx;
  1000. }
  1001. .clear-btn-text {
  1002. color: #ffffff;
  1003. font-size: 24rpx;
  1004. font-weight: bold;
  1005. }
  1006. }
  1007. .status-tabs {
  1008. padding: 20rpx 30rpx;
  1009. background-color: #ffffff;
  1010. border-bottom: 1rpx solid #eeeeee;
  1011. }
  1012. .scroll-view_H {
  1013. width: 100%;
  1014. flex-direction: row;
  1015. }
  1016. .status-tab {
  1017. padding: 16rpx 24rpx;
  1018. text-align: center;
  1019. margin-right: 16rpx;
  1020. border-radius: 8rpx;
  1021. background-color: #f5f5f5;
  1022. flex-shrink: 0;
  1023. &:last-child {
  1024. margin-right: 0;
  1025. }
  1026. &.active {
  1027. background-color: #007aff;
  1028. }
  1029. .status-tab-text {
  1030. font-size: 26rpx;
  1031. color: #666666;
  1032. &.active-text {
  1033. color: #ffffff;
  1034. font-weight: bold;
  1035. }
  1036. }
  1037. }
  1038. .list-item {
  1039. margin: 3rpx;
  1040. padding: 10rpx 10rpx 0rpx 10rpx;
  1041. border-bottom: 1px solid #f9f9f9;
  1042. }
  1043. .item-header {
  1044. display: flex;
  1045. flex-direction: row;
  1046. align-items: flex-start;
  1047. margin-bottom: 10rpx;
  1048. }
  1049. .item-info {
  1050. flex: 1;
  1051. min-width: 0;
  1052. }
  1053. .item-actions {
  1054. flex-shrink: 0;
  1055. display: flex;
  1056. align-items: center;
  1057. gap: 10rpx;
  1058. margin-left: 20rpx;
  1059. }
  1060. .item-title {
  1061. flex: 1;
  1062. }
  1063. .item-name {
  1064. font-size: 28rpx;
  1065. color: #333333;
  1066. font-weight: bold;
  1067. word-break: break-all;
  1068. overflow: hidden;
  1069. text-overflow: ellipsis;
  1070. display: -webkit-box;
  1071. -webkit-line-clamp: 2;
  1072. -webkit-box-orient: vertical;
  1073. &.status-0 {
  1074. color: #ff4d4f;
  1075. }
  1076. &.status-2 {
  1077. color: #999999;
  1078. }
  1079. }
  1080. .item-name-row {
  1081. display: flex;
  1082. flex-wrap: wrap;
  1083. align-items: flex-start;
  1084. }
  1085. .item-measure {
  1086. font-size: 24rpx;
  1087. color: #999999;
  1088. margin-left: 10rpx;
  1089. }
  1090. .item-sub-title {
  1091. flex: 1;
  1092. font-size: 23rpx;
  1093. color: #797979;
  1094. margin-left: 10rpx;
  1095. }
  1096. .item-sub-row {
  1097. flex-direction: row;
  1098. align-items: center;
  1099. }
  1100. .item-stock {
  1101. font-size: 23rpx;
  1102. color: #52c41a;
  1103. margin-left: 20rpx;
  1104. }
  1105. .item-measure {
  1106. font-size: 23rpx;
  1107. color: #999999;
  1108. margin-left: 10rpx;
  1109. }
  1110. .add-btn {
  1111. width: 44rpx;
  1112. height: 44rpx;
  1113. border-radius: 22rpx;
  1114. background-color: #165DFF;
  1115. color: #FFFFFF;
  1116. align-items: center;
  1117. justify-content: center;
  1118. }
  1119. .add-btn.disabled {
  1120. background-color: #cccccc;
  1121. }
  1122. .added-btn {
  1123. padding: 8rpx 16rpx;
  1124. border-radius: 8rpx;
  1125. align-items: center;
  1126. justify-content: center;
  1127. }
  1128. .added-icon {
  1129. color: #ff4d4f;
  1130. font-size: 24rpx;
  1131. }
  1132. .detail-link {
  1133. font-size: 21rpx;
  1134. color: #999999;
  1135. }
  1136. .material-list {
  1137. }
  1138. .pagination {
  1139. flex-direction: row;
  1140. display: flex;
  1141. align-items: center;
  1142. justify-content: center;
  1143. padding: 20rpx;
  1144. gap: 30rpx;
  1145. }
  1146. .page-btn {
  1147. padding: 10rpx 20rpx;
  1148. margin: 5px;
  1149. background-color: #165DFF;
  1150. border-radius: 8rpx;
  1151. }
  1152. .page-btn.disabled {
  1153. background-color: #cccccc;
  1154. }
  1155. .page-btn-text {
  1156. color: #FFFFFF;
  1157. font-size: 26rpx;
  1158. }
  1159. .page-info {
  1160. font-size: 26rpx;
  1161. color: #666666;
  1162. }
  1163. .selected-list {
  1164. padding: 20rpx;
  1165. background-color: #ffffff;
  1166. min-height: 150rpx;
  1167. display: flex;
  1168. flex-direction: column;
  1169. gap: 15rpx;
  1170. }
  1171. .empty-tip {
  1172. display: flex;
  1173. align-items: center;
  1174. justify-content: center;
  1175. padding: 40rpx;
  1176. }
  1177. .empty-tip-text {
  1178. color: #999999;
  1179. font-size: 28rpx;
  1180. }
  1181. .selected-item {
  1182. display: flex;
  1183. flex-direction: column;
  1184. background-color: #ffffff;
  1185. border-radius: 10rpx;
  1186. padding: 16rpx 20rpx;
  1187. border: 1rpx solid #e5e5e5;
  1188. box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.05);
  1189. margin-bottom: 12rpx;
  1190. }
  1191. .selected-item-row1 {
  1192. margin-bottom: 8rpx;
  1193. }
  1194. .selected-item-row1-extra {
  1195. display: flex;
  1196. flex-direction: row;
  1197. align-items: center;
  1198. }
  1199. .selected-item-body {
  1200. display: flex;
  1201. flex-direction: row;
  1202. }
  1203. .selected-item-content {
  1204. flex: 1;
  1205. }
  1206. .selected-item-row2 {
  1207. margin-top: 10rpx;
  1208. }
  1209. .selected-item-name {
  1210. font-size: 26rpx;
  1211. color: #333333;
  1212. font-weight: 500;
  1213. word-break: break-all;
  1214. }
  1215. .selected-item-remark-row {
  1216. margin-top: 10rpx;
  1217. }
  1218. .selected-item-remark {
  1219. width: 100%;
  1220. height: 56rpx;
  1221. padding: 0 16rpx;
  1222. background-color: #f5f5f5;
  1223. border-radius: 6rpx;
  1224. font-size: 24rpx;
  1225. color: #333333;
  1226. border: 1rpx solid #e5e5e5;
  1227. }
  1228. .selected-item-measure {
  1229. font-size: 24rpx;
  1230. color: #999999;
  1231. margin-right: 20rpx;
  1232. flex-shrink: 0;
  1233. }
  1234. .quantity-control {
  1235. display: flex;
  1236. flex-direction: row;
  1237. align-items: center;
  1238. margin-right: auto;
  1239. flex-shrink: 0;
  1240. }
  1241. .qty-btn {
  1242. width: 44rpx;
  1243. height: 44rpx;
  1244. background-color: #f5f5f5;
  1245. border-radius: 6rpx;
  1246. align-items: center;
  1247. justify-content: center;
  1248. border: 1rpx solid #e5e5e5;
  1249. }
  1250. .qty-btn-text {
  1251. color: #333333;
  1252. font-size: 28rpx;
  1253. font-weight: bold;
  1254. }
  1255. .quantity-input {
  1256. width: 220rpx;
  1257. height: 44rpx;
  1258. background-color: #f5f5f5;
  1259. border-radius: 6rpx;
  1260. font-size: 24rpx;
  1261. padding: 0 10rpx;
  1262. border: 1rpx solid #e5e5e5;
  1263. text-align: center;
  1264. margin: 0 10rpx;
  1265. }
  1266. .quantity-input:focus {
  1267. outline: none;
  1268. border-color: #007aff;
  1269. background-color: #ffffff;
  1270. }
  1271. /* 物料列表的删除按钮 */
  1272. .material-delete-btn {
  1273. width: 44rpx;
  1274. height: 44rpx;
  1275. border-radius: 22rpx;
  1276. background-color: #ff4d4f;
  1277. color: #FFFFFF;
  1278. align-items: center;
  1279. justify-content: center;
  1280. display: flex;
  1281. flex-shrink: 0;
  1282. }
  1283. /* 选中物料列表的删除按钮 */
  1284. .selected-delete-btn {
  1285. width: 44rpx;
  1286. height: 44rpx;
  1287. border-radius: 50%;
  1288. background-color: #ff4d4f;
  1289. align-items: center;
  1290. justify-content: center;
  1291. display: flex;
  1292. flex-shrink: 0;
  1293. margin-left: 16rpx;
  1294. align-self: center;
  1295. }
  1296. .delete-icon {
  1297. color: #ffffff;
  1298. font-size: 30rpx;
  1299. font-weight: bold;
  1300. }
  1301. /* 底部按钮 */
  1302. .bottom-buttons {
  1303. padding: 20rpx;
  1304. background-color: #ffffff;
  1305. border-top: 1rpx solid #e5e5e5;
  1306. position: fixed;
  1307. bottom: 0;
  1308. left: 0;
  1309. right: 0;
  1310. z-index: 100;
  1311. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  1312. }
  1313. .btn-row {
  1314. flex-direction: row;
  1315. display: flex;
  1316. gap: 20rpx;
  1317. }
  1318. .save-btn {
  1319. width: 180rpx;
  1320. height: 80rpx;
  1321. background-color: #f5f5f5;
  1322. color: #333333;
  1323. font-size: 28rpx;
  1324. font-weight: 500;
  1325. border-radius: 20rpx;
  1326. border: 1rpx solid #e5e5e5;
  1327. }
  1328. .confirm-btn {
  1329. flex: 1;
  1330. height: 80rpx;
  1331. background-color: #007aff;
  1332. color: #ffffff;
  1333. font-size: 28rpx;
  1334. font-weight: 600;
  1335. border-radius: 20rpx;
  1336. margin-left: 10rpx;
  1337. border: none;
  1338. box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
  1339. }
  1340. /* 新增物料弹窗样式 */
  1341. .picker-modal {
  1342. position: fixed;
  1343. top: 0;
  1344. left: 0;
  1345. right: 0;
  1346. bottom: 0;
  1347. z-index: 1000;
  1348. display: flex;
  1349. align-items: center;
  1350. justify-content: center;
  1351. }
  1352. .modal-mask {
  1353. position: absolute;
  1354. top: 0;
  1355. left: 0;
  1356. right: 0;
  1357. bottom: 0;
  1358. background-color: rgba(0, 0, 0, 0.5);
  1359. }
  1360. .modal-content {
  1361. position: relative;
  1362. width: 90%;
  1363. // max-width: 500rpx;
  1364. background-color: #ffffff;
  1365. border-radius: 16rpx;
  1366. padding: 30rpx;
  1367. box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
  1368. }
  1369. .modal-header {
  1370. display: flex;
  1371. flex-direction: row;
  1372. justify-content: space-between;
  1373. align-items: center;
  1374. margin-bottom: 30rpx;
  1375. padding-bottom: 20rpx;
  1376. border-bottom: 1rpx solid #e5e5e5;
  1377. }
  1378. .modal-title {
  1379. font-size: 32rpx;
  1380. font-weight: bold;
  1381. color: #333333;
  1382. }
  1383. .modal-close {
  1384. font-size: 28rpx;
  1385. color: #999999;
  1386. padding: 8rpx 16rpx;
  1387. border-radius: 8rpx;
  1388. background-color: #f5f5f5;
  1389. }
  1390. .form-item-input {
  1391. display: flex;
  1392. flex-direction: column;
  1393. margin-bottom: 24rpx;
  1394. }
  1395. .label-picker {
  1396. font-size: 28rpx;
  1397. color: #333333;
  1398. margin-bottom: 12rpx;
  1399. font-weight: 500;
  1400. }
  1401. .view-input-picker {
  1402. position: relative;
  1403. width: 100%;
  1404. }
  1405. .input-picker {
  1406. width: 100%;
  1407. height: 80rpx;
  1408. padding: 0 24rpx;
  1409. background-color: #f5f5f5;
  1410. border-radius: 12rpx;
  1411. font-size: 28rpx;
  1412. color: #333333;
  1413. border: 1rpx solid #e5e5e5;
  1414. }
  1415. .input-picker:focus {
  1416. outline: none;
  1417. border-color: #007aff;
  1418. background-color: #ffffff;
  1419. }
  1420. .view-textarea-picker {
  1421. position: relative;
  1422. width: 100%;
  1423. }
  1424. .textarea-picker {
  1425. width: 100%;
  1426. min-height: 120rpx;
  1427. padding: 20rpx 24rpx;
  1428. background-color: #f5f5f5;
  1429. border-radius: 12rpx;
  1430. font-size: 28rpx;
  1431. color: #333333;
  1432. border: 1rpx solid #e5e5e5;
  1433. box-sizing: border-box;
  1434. }
  1435. .textarea-picker:focus {
  1436. outline: none;
  1437. border-color: #007aff;
  1438. background-color: #ffffff;
  1439. }
  1440. .form-item-btn {
  1441. margin-top: 30rpx;
  1442. display: flex;
  1443. justify-content: center;
  1444. }
  1445. .error-tip {
  1446. display: flex;
  1447. flex-direction: row;
  1448. align-items: center;
  1449. justify-content: space-between;
  1450. margin: 20rpx;
  1451. padding: 16rpx 20rpx;
  1452. background-color: #fff2f0;
  1453. border: 1rpx solid #ffccc7;
  1454. border-radius: 8rpx;
  1455. }
  1456. .error-tip-text {
  1457. flex: 1;
  1458. font-size: 26rpx;
  1459. color: #ff4d4f;
  1460. }
  1461. .error-tip-close {
  1462. margin-left: 16rpx;
  1463. font-size: 32rpx;
  1464. color: #999999;
  1465. font-weight: bold;
  1466. }
  1467. .btn-primary {
  1468. width: 100%;
  1469. height: 80rpx;
  1470. background-color: #007aff;
  1471. color: #ffffff;
  1472. font-size: 28rpx;
  1473. font-weight: 600;
  1474. border-radius: 12rpx;
  1475. border: none;
  1476. box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
  1477. }
  1478. .add-icon{
  1479. color: #ffffff;
  1480. }
  1481. .measure-list {
  1482. max-height: 500rpx;
  1483. overflow-y: auto;
  1484. }
  1485. .measure-item {
  1486. padding: 24rpx;
  1487. border-bottom: 1rpx solid #f0f0f0;
  1488. }
  1489. .measure-name {
  1490. font-size: 28rpx;
  1491. color: #333333;
  1492. }
  1493. .measure-input-row {
  1494. flex-direction: row;
  1495. align-items: center;
  1496. }
  1497. .measure-input-row .input-picker {
  1498. flex: 1;
  1499. margin-right: 16rpx;
  1500. }
  1501. .pick-btn {
  1502. padding: 16rpx 24rpx;
  1503. background-color: #007aff;
  1504. border-radius: 8rpx;
  1505. }
  1506. .pick-btn-text {
  1507. color: #ffffff;
  1508. font-size: 26rpx;
  1509. }
  1510. /* 备注输入框样式 */
  1511. .remark-section {
  1512. padding: 20rpx;
  1513. background-color: #ffffff;
  1514. }
  1515. .remark-input {
  1516. width: 100%;
  1517. min-height: 200rpx;
  1518. padding: 20rpx;
  1519. background-color: #f5f5f5;
  1520. border-radius: 12rpx;
  1521. font-size: 28rpx;
  1522. color: #333333;
  1523. border: 1rpx solid #e5e5e5;
  1524. resize: none;
  1525. box-sizing: border-box;
  1526. }
  1527. .remark-input:focus {
  1528. outline: none;
  1529. border-color: #007aff;
  1530. background-color: #ffffff;
  1531. }
  1532. .remark-count {
  1533. display: block;
  1534. text-align: right;
  1535. margin-top: 10rpx;
  1536. font-size: 24rpx;
  1537. color: #999999;
  1538. }
  1539. /* 图片上传样式 */
  1540. .image-upload-container {
  1541. display: flex;
  1542. flex-direction: row;
  1543. flex-wrap: wrap;
  1544. gap: 16rpx;
  1545. margin-top: 12rpx;
  1546. }
  1547. .uploaded-image {
  1548. position: relative;
  1549. width: 160rpx;
  1550. height: 160rpx;
  1551. border-radius: 8rpx;
  1552. overflow: hidden;
  1553. border: 1rpx solid #e5e5e5;
  1554. }
  1555. .uploaded-image-item {
  1556. width: 100%;
  1557. height: 100%;
  1558. }
  1559. .image-delete-btn {
  1560. position: absolute;
  1561. top: 8rpx;
  1562. right: 8rpx;
  1563. width: 36rpx;
  1564. height: 36rpx;
  1565. border-radius: 18rpx;
  1566. background-color: rgba(0, 0, 0, 0.6);
  1567. display: flex;
  1568. align-items: center;
  1569. justify-content: center;
  1570. }
  1571. .image-delete-icon {
  1572. color: #ffffff;
  1573. font-size: 28rpx;
  1574. font-weight: bold;
  1575. }
  1576. .upload-btn {
  1577. width: 160rpx;
  1578. height: 160rpx;
  1579. border-radius: 8rpx;
  1580. border: 2rpx dashed #e5e5e5;
  1581. display: flex;
  1582. flex-direction: column;
  1583. align-items: center;
  1584. justify-content: center;
  1585. background-color: #fafafa;
  1586. }
  1587. .upload-btn-icon {
  1588. font-size: 48rpx;
  1589. color: #999999;
  1590. margin-bottom: 8rpx;
  1591. }
  1592. .upload-btn-text {
  1593. font-size: 24rpx;
  1594. color: #999999;
  1595. }
  1596. /* 删除确认弹窗样式 */
  1597. .delete-confirm-modal {
  1598. position: fixed;
  1599. top: 0;
  1600. left: 0;
  1601. right: 0;
  1602. bottom: 0;
  1603. z-index: 10000;
  1604. display: flex;
  1605. align-items: center;
  1606. justify-content: center;
  1607. }
  1608. .delete-confirm-mask {
  1609. position: absolute;
  1610. top: 0;
  1611. left: 0;
  1612. right: 0;
  1613. bottom: 0;
  1614. background-color: rgba(0, 0, 0, 0.5);
  1615. }
  1616. .delete-confirm-content {
  1617. position: relative;
  1618. width: 600rpx;
  1619. background-color: #ffffff;
  1620. border-radius: 16rpx;
  1621. padding: 40rpx;
  1622. display: flex;
  1623. flex-direction: column;
  1624. align-items: center;
  1625. }
  1626. .delete-confirm-title {
  1627. font-size: 32rpx;
  1628. font-weight: bold;
  1629. color: #333333;
  1630. margin-bottom: 20rpx;
  1631. }
  1632. .delete-confirm-text {
  1633. font-size: 28rpx;
  1634. color: #666666;
  1635. margin-bottom: 40rpx;
  1636. }
  1637. .delete-confirm-btns {
  1638. display: flex;
  1639. flex-direction: row;
  1640. gap: 40rpx;
  1641. }
  1642. .delete-confirm-cancel {
  1643. padding: 20rpx 60rpx;
  1644. background-color: #f5f5f5;
  1645. border-radius: 12rpx;
  1646. }
  1647. .delete-confirm-cancel-text {
  1648. font-size: 28rpx;
  1649. color: #666666;
  1650. }
  1651. .delete-confirm-ok {
  1652. padding: 20rpx 60rpx;
  1653. background-color: #ff4d4f;
  1654. border-radius: 12rpx;
  1655. }
  1656. .delete-confirm-ok-text {
  1657. font-size: 28rpx;
  1658. color: #ffffff;
  1659. }
  1660. /* 图片预览弹窗样式 */
  1661. .image-preview-modal {
  1662. position: fixed;
  1663. top: 0;
  1664. left: 0;
  1665. right: 0;
  1666. bottom: 0;
  1667. background-color: #000000;
  1668. z-index: 10000;
  1669. display: flex;
  1670. align-items: center;
  1671. justify-content: center;
  1672. }
  1673. .preview-swiper {
  1674. width: 100%;
  1675. height: 80%;
  1676. }
  1677. .preview-image {
  1678. width: 100%;
  1679. height: 100%;
  1680. }
  1681. .preview-close {
  1682. position: absolute;
  1683. top: 80rpx;
  1684. right: 30rpx;
  1685. width: 60rpx;
  1686. height: 60rpx;
  1687. border-radius: 30rpx;
  1688. background-color: rgba(255, 255, 255, 0.3);
  1689. display: flex;
  1690. align-items: center;
  1691. justify-content: center;
  1692. }
  1693. .preview-close-text {
  1694. font-size: 40rpx;
  1695. color: #ffffff;
  1696. }
  1697. .preview-indicator {
  1698. position: absolute;
  1699. bottom: 100rpx;
  1700. left: 50%;
  1701. transform: translateX(-50%);
  1702. padding: 10rpx 30rpx;
  1703. background-color: rgba(0, 0, 0, 0.5);
  1704. border-radius: 20rpx;
  1705. }
  1706. .preview-indicator-text {
  1707. font-size: 28rpx;
  1708. color: #ffffff;
  1709. }
  1710. </style>