start.vue 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182
  1. <template>
  2. <view class="contract-container">
  3. <!-- 基本信息 -->
  4. <uni-card title="基本信息" spacing="0">
  5. <uni-forms ref="baseFormRef" :modelValue="baseForm" :rules="baseFormRules" label-position="left" :label-width="100" :border="true">
  6. <uni-forms-item name="contract_number" label="合同编号" required>
  7. <uni-easyinput v-model="baseForm.contract_number" placeholder="请输入合同编号"></uni-easyinput>
  8. </uni-forms-item>
  9. <uni-forms-item name="contract_name" label="合同名称" required>
  10. <uni-easyinput v-model="baseForm.contract_name" placeholder="请输入合同名称"></uni-easyinput>
  11. </uni-forms-item>
  12. <uni-forms-item name="contract_type" label="合同类型" required>
  13. <picker @change="onContractTypeChange" :range="contractTypeList" range-key="contract_type_name">
  14. <view class="picker">{{ baseForm.contract_type_name || '请选择合同类型' }}</view>
  15. </picker>
  16. </uni-forms-item>
  17. <uni-forms-item name="applyDate" label="申请日期">
  18. <uni-easyinput v-model="baseForm.applyDate" type="date" disabled />
  19. </uni-forms-item>
  20. <uni-forms-item name="department" label="填报部门">
  21. <uni-easyinput v-model="baseForm.department" disabled></uni-easyinput>
  22. </uni-forms-item>
  23. <uni-forms-item name="salesman_name" label="经办人">
  24. <uni-easyinput v-model="baseForm.salesman_name" disabled placeholder="自动生成"></uni-easyinput>
  25. </uni-forms-item>
  26. <uni-forms-item name="salesmanTel" label="联系电话">
  27. <uni-easyinput v-model="baseForm.salesmanTel" type="number" placeholder="请输入联系电话"></uni-easyinput>
  28. </uni-forms-item>
  29. <uni-forms-item name="firstparty_name" label="需方" required>
  30. <!-- 销售合同:显示选择客户按钮 -->
  31. <view v-if="isSalesContract" class="selector-wrapper" @click="openClientSelector">
  32. <text v-if="baseForm.firstparty_name">{{ baseForm.firstparty_name }}</text>
  33. <text v-else class="placeholder">请选择客户</text>
  34. </view>
  35. <!-- 其他合同类型:显示公司名称(只读) -->
  36. <uni-easyinput v-else v-model="baseForm.firstparty_name" disabled placeholder="自动生成"></uni-easyinput>
  37. </uni-forms-item>
  38. <uni-forms-item name="secondparty_name" label="供方" required>
  39. <!-- 销售合同:显示公司名称(只读) -->
  40. <uni-easyinput v-if="isSalesContract" v-model="baseForm.secondparty_name" disabled placeholder="自动生成"></uni-easyinput>
  41. <!-- 其他合同类型:显示选择供应商按钮 -->
  42. <view v-else class="selector-wrapper" @click="openSupplierSelector">
  43. <text v-if="baseForm.secondparty_name">{{ baseForm.secondparty_name }}</text>
  44. <text v-else class="placeholder">请选择供应商</text>
  45. </view>
  46. </uni-forms-item>
  47. <uni-forms-item name="contract_money" label="合同金额">
  48. <view>
  49. <uni-easyinput
  50. v-model="baseForm.contract_money"
  51. type="digit"
  52. placeholder="请输入合同金额(自动计算或手动输入)"
  53. :readonly="!canEditContractMoney"
  54. @blur="onContractMoneyBlur"
  55. ></uni-easyinput>
  56. <view class="contract-money-uppercase">
  57. <text>{{ contractMoneyUppercase }}</text>
  58. </view>
  59. </view>
  60. </uni-forms-item>
  61. <uni-forms-item name="contractContent" label="合同内容">
  62. <uni-easyinput v-model="baseForm.contractContent" type="textarea" placeholder="请输入合同内容"></uni-easyinput>
  63. </uni-forms-item>
  64. <uni-forms-item name="projectItem" label="所属项目或产品">
  65. <uni-easyinput v-model="baseForm.projectItem" placeholder="请输入所属项目或产品"></uni-easyinput>
  66. </uni-forms-item>
  67. <uni-forms-item name="usePosition" label="使用位置">
  68. <uni-easyinput v-model="baseForm.usePosition" placeholder="请输入使用位置"></uni-easyinput>
  69. </uni-forms-item>
  70. <uni-forms-item name="other_contractor" label="对方联系人及电话">
  71. <uni-easyinput v-model="baseForm.other_contractor" placeholder="请输入对方联系人及电话"></uni-easyinput>
  72. </uni-forms-item>
  73. <uni-forms-item name="otherFile" label="随合同提交的其它材料">
  74. <uni-easyinput v-model="baseForm.otherFile" type="textarea" placeholder="请输入其它材料说明"></uni-easyinput>
  75. </uni-forms-item>
  76. <uni-forms-item name="salesmanSign" label="经办人签字">
  77. <uni-easyinput v-model="baseForm.salesmanSign" placeholder="请输入经办人签字"></uni-easyinput>
  78. </uni-forms-item>
  79. </uni-forms>
  80. </uni-card>
  81. <!-- 物料明细 -->
  82. <uni-card title="物品信息" spacing="0">
  83. <view class="material-actions">
  84. <button type="primary" size="mini" @click="openMaterialSelector" plain>添加物料</button>
  85. </view>
  86. <!-- 物料列表 - 卡片式展示 -->
  87. <view v-if="materialList.length > 0" class="material-list">
  88. <view v-for="(item, index) in materialList" :key="index" class="material-card">
  89. <view class="material-header" @click="toggleExpand(index)">
  90. <view class="material-main-info">
  91. <text class="material-name">{{ item.itemName }}</text>
  92. <text class="material-code">{{ item.itemCode }}</text>
  93. </view>
  94. <view class="material-expand">
  95. <uni-icons :type="item.expanded ? 'up' : 'down'" size="16" color="#999"></uni-icons>
  96. </view>
  97. </view>
  98. <!-- 展开的详细信息 -->
  99. <view v-show="item.expanded" class="material-detail">
  100. <view class="detail-row">
  101. <text class="detail-label">规格型号:</text>
  102. <text class="detail-value">{{ item.specification }}</text>
  103. </view>
  104. <view class="detail-row">
  105. <text class="detail-label">单位:</text>
  106. <text class="detail-value">{{ item.measureName }}</text>
  107. </view>
  108. <view class="detail-row">
  109. <text class="detail-label">数量:</text>
  110. <uni-easyinput
  111. v-model="item.qty"
  112. type="digit"
  113. placeholder="请输入数量"
  114. style="width: 100px; display: inline-block;"
  115. @blur="onQuantityBlur(item)"
  116. />
  117. </view>
  118. <view class="detail-row">
  119. <text class="detail-label">税前单价:</text>
  120. <uni-easyinput
  121. v-model="item.price"
  122. type="digit"
  123. placeholder="请输入税前单价"
  124. style="width: 120px; display: inline-block;"
  125. @blur="onPriceBlur(item)"
  126. />
  127. </view>
  128. <view class="detail-row">
  129. <text class="detail-label">税率 (%):</text>
  130. <uni-easyinput
  131. v-model="item.cess"
  132. type="digit"
  133. placeholder="请输入税率"
  134. style="width: 80px; display: inline-block;"
  135. @blur="onCessBlur(item)"
  136. />
  137. </view>
  138. <view class="detail-row">
  139. <text class="detail-label">税后单价:</text>
  140. <text class="detail-value price-value">{{ item.priceTax }}</text>
  141. </view>
  142. <!-- 采购申请单编号(仅当从采购申请单添加且非销售合同时显示) -->
  143. <view v-if="!isSalesContract && item.purchaseNumber" class="detail-row purchase-number-row">
  144. <text class="detail-label">采购申请单:</text>
  145. <text class="detail-value purchase-number">{{ item.purchaseNumber }}</text>
  146. </view>
  147. <view class="detail-row delete-row">
  148. <button type="warn" size="mini" @click="removeMaterial(index)">删除</button>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. <view v-else class="empty-materials">
  154. <text>暂无物料,请点击上方按钮添加</text>
  155. </view>
  156. </uni-card>
  157. <!-- 付款信息 -->
  158. <uni-card title="付款信息" spacing="0">
  159. <view class="payment-actions">
  160. <button type="primary" size="mini" @click="addPaymentInfo" :disabled="!canAddPayment" plain>添加付款方式</button>
  161. </view>
  162. <!-- 付款方式列表 -->
  163. <view v-if="paymentList.length > 0" class="payment-list">
  164. <view v-for="(item, index) in paymentList" :key="index" class="payment-card">
  165. <view class="payment-header" @click="togglePaymentExpand(index)">
  166. <view class="payment-main-info">
  167. <text class="payment-type">{{ item.payTypeName }}</text>
  168. <text class="payment-proportion">比例:{{ item.proportion }}%</text>
  169. </view>
  170. <view class="payment-expand">
  171. <uni-icons :type="item.expanded ? 'up' : 'down'" size="16" color="#999"></uni-icons>
  172. </view>
  173. </view>
  174. <!-- 展开的详细信息 -->
  175. <view v-show="item.expanded" class="payment-detail">
  176. <view class="detail-row">
  177. <text class="detail-label">付款方式:</text>
  178. <picker @change="(e) => onPaymentTypeChange(index, e)" :range="paymentTypeList" range-key="payTypeName">
  179. <view class="picker">
  180. {{ item.payTypeName || '请选择付款方式' }}
  181. </view>
  182. </picker>
  183. </view>
  184. <view class="detail-row">
  185. <text class="detail-label">比例:</text>
  186. <uni-easyinput
  187. v-model="item.proportion"
  188. type="digit"
  189. placeholder="请输入比例"
  190. style="width: 80px; display: inline-block;"
  191. @blur="onProportionBlur(item)"
  192. />
  193. <text>%</text>
  194. </view>
  195. <view class="detail-row">
  196. <text class="detail-label">金额:</text>
  197. <text class="detail-value price-value">{{ item.amount }}</text>
  198. </view>
  199. <view class="detail-row">
  200. <text class="detail-label">已付金额:</text>
  201. <uni-easyinput
  202. v-model="item.amountPaid"
  203. type="digit"
  204. placeholder="请输入已付金额"
  205. style="width: 120px; display: inline-block;"
  206. @blur="onAmountPaidBlur(item)"
  207. />
  208. </view>
  209. <view class="detail-row">
  210. <text class="detail-label">付款状态:</text>
  211. <text class="detail-value status-tag" :class="'status-' + item.payStatus">{{ item.payStatusName }}</text>
  212. </view>
  213. <view class="detail-row">
  214. <text class="detail-label">付款时间:</text>
  215. <uni-datetime-picker
  216. ref="payTimePicker"
  217. v-model="item.payTime"
  218. type="date"
  219. placeholder="选择付款时间"
  220. style="display: inline-block;"
  221. @click.native.stop
  222. @confirm="(e) => onPayTimeConfirm(item, e)"
  223. />
  224. </view>
  225. <view class="detail-row">
  226. <text class="detail-label">备注:</text>
  227. <uni-easyinput
  228. v-model="item.remark"
  229. placeholder="请输入备注"
  230. style="flex: 1; display: inline-block;"
  231. />
  232. </view>
  233. <view class="detail-row delete-row">
  234. <button type="warn" size="mini" @click="removePayment(index)">删除</button>
  235. </view>
  236. </view>
  237. </view>
  238. </view>
  239. <view v-else class="empty-payments">
  240. <text v-if="!canAddPayment">请先输入合同金额</text>
  241. <text v-else>暂无付款方式,请点击上方按钮添加</text>
  242. </view>
  243. </uni-card>
  244. <!-- 上传附件 -->
  245. <uni-card title="上传附件" :extra="`${fileList.length}/50`" spacing="0">
  246. <uni-file-picker
  247. ref="filePicker"
  248. v-model="fileList"
  249. :auto-upload="true"
  250. mode="list"
  251. :limit="50"
  252. :limit-length="50"
  253. file-mediatype="all"
  254. @select="handleFileSelect"
  255. @progress="handleFileProgress"
  256. @success="handleFileSuccess"
  257. @fail="handleFileFail"
  258. @delete="handleFileDelete"
  259. />
  260. </uni-card>
  261. <!-- 提交按钮 -->
  262. <view class="submit-btn-wrapper">
  263. <button type="primary" :loading="isSubmitting" :disabled="isSubmitting" @click="submitForm">提 交</button>
  264. </view>
  265. <!-- 选择器弹出层 -->
  266. <uni-popup ref="selectorPopup" type="center">
  267. <view class="selector-popup">
  268. <view class="popup-header">
  269. <text class="popup-title">{{ popupTitle }}</text>
  270. <uni-icons type="closeempty" size="20" @click="closePopup"></uni-icons>
  271. </view>
  272. <!-- 物料来源选择(仅物料选择时显示,且非销售合同) -->
  273. <view v-if="selectorType === 'material' && !isSalesContract" class="material-source-selector">
  274. <view class="source-options">
  275. <view
  276. :class="['source-option', materialSource === 'mes' ? 'active' : '']"
  277. @click="materialSource = 'mes'; onMaterialSourceChange()">
  278. MES 系统
  279. </view>
  280. <view
  281. :class="['source-option', materialSource === 'purchase' ? 'active' : '']"
  282. @click="materialSource = 'purchase'; onMaterialSourceChange()">
  283. 采购申请
  284. </view>
  285. </view>
  286. </view>
  287. <!-- 搜索框 -->
  288. <view v-if="(selectorType === 'material' && materialSource === 'mes') || selectorType === 'supplier' || selectorType === 'client'" class="search-bar">
  289. <uni-easyinput
  290. v-model="searchKeyword"
  291. :placeholder="selectorType === 'material' ? '输入物料名称搜索' : (selectorType === 'supplier' ? '输入供应商名称搜索' : '输入客户名称搜索')"
  292. clearable
  293. @confirm="handleSearch"
  294. />
  295. <button type="primary" size="mini" @click="handleSearch">搜索</button>
  296. </view>
  297. <!-- 采购申请单选择器(采购申请模式,且非销售合同) -->
  298. <view v-if="selectorType === 'material' && materialSource === 'purchase' && !isSalesContract" class="purchase-selector">
  299. <picker @change="onPurchaseChange" :range="purchaseApplyList" range-key="contractPurchaseFormNumber">
  300. <view class="picker">
  301. {{ selectedPurchaseApply ? selectedPurchaseApply.contractPurchaseFormNumber : '全部采购申请单' }}
  302. </view>
  303. </picker>
  304. <button type="primary" size="mini" @click="loadPurchaseMaterials">查询</button>
  305. <button type="warn" size="mini" @click="clearPurchaseSelection" v-if="selectedPurchaseApply">清空</button>
  306. </view>
  307. <scroll-view
  308. scroll-y
  309. class="popup-content"
  310. refresher-enabled
  311. :refresher-triggered="isRefreshing"
  312. @refresherrefresh="onRefresh"
  313. @scrolltolower="loadMore"
  314. >
  315. <view v-for="(item, index) in selectorList" :key="index"
  316. class="selector-item"
  317. @click="selectItem(item)">
  318. <view class="selector-item-content">
  319. <view class="item-info">
  320. <text class="item-name">{{ getSelectorItemName(item) }}</text>
  321. <!-- 采购申请模式显示采购单号(仅非销售合同) -->
  322. <text v-if="!isSalesContract && materialSource === 'purchase' && item.purchaseNumber" class="item-purchase">
  323. 采购单:{{ item.purchaseNumber }}
  324. </text>
  325. <text v-if="getItemCode(item)" class="item-code">{{ getItemCode(item) }}</text>
  326. <text v-if="getItemSpec(item)" class="item-spec">{{ getItemSpec(item) }}</text>
  327. <!-- 显示单位和数量 -->
  328. <text v-if="item.measureName || item.qty" class="item-extra">
  329. <text v-if="item.measureName">{{ item.measureName }}</text>
  330. <text v-if="item.qty"> 可用:{{ item.qty }}</text>
  331. </text>
  332. </view>
  333. <text v-if="isSelected(item)" class="selected-tag">已选择</text>
  334. </view>
  335. </view>
  336. <!-- 加载状态 -->
  337. <view v-if="isLoading && selectorList.length > 0" class="loading-text">
  338. <uni-load-more status="loading" />
  339. </view>
  340. <!-- 没有更多数据 -->
  341. <view v-else-if="!hasMore && selectorList.length > 0" class="no-more-text">
  342. <text>没有更多了</text>
  343. </view>
  344. <!-- 空数据提示 -->
  345. <view v-if="selectorList.length === 0 && !isLoading" class="empty-data">
  346. <text>{{ searchKeyword ? '暂无相关数据' : '暂无数据' }}</text>
  347. </view>
  348. </scroll-view>
  349. </view>
  350. </uni-popup>
  351. </view>
  352. </template>
  353. <script setup lang="ts">
  354. import { onMounted, reactive, ref, computed } from 'vue'
  355. import { onLoad } from '@dcloudio/uni-app'
  356. import { useUserStore } from '@/store/user.js'
  357. import $modal from '@/plugins/modal.js'
  358. import $tab from '@/plugins/tab.js'
  359. import { getContractInitData, startContractProcess, getMaterialList, getSupplierList, getClientList, getPurchaseApplyList, getPurchaseDetailList, checkContractNumber } from '@/api/contract.js'
  360. import { uploadFile, getProcessInfo } from '@/api/work.js'
  361. import config from '@/config.js'
  362. const userStore = useUserStore()
  363. // 流程信息(参考通用流程)
  364. let processInfo = reactive({
  365. modelName: '合同审批',
  366. reqOffice: 0,
  367. control: '',
  368. formId: '',
  369. modelId: '',
  370. tmodelId: '',
  371. isMoreIns: '',
  372. pathJudgeType: '',
  373. form: []
  374. })
  375. // 接收页面参数
  376. onLoad((options) => {
  377. const { modelName, modelId, control } = options
  378. if (modelName) processInfo.modelName = modelName
  379. if (modelId) processInfo.modelId = modelId
  380. if (control) processInfo.control = control
  381. })
  382. // 初始化流程信息(获取 formId, tmodelId 等)
  383. onMounted(() => {
  384. initProcessInfo().then(() => {
  385. // 初始化基本信息(流水号、部门等)
  386. initBaseForm()
  387. })
  388. })
  389. function initProcessInfo() {
  390. return new Promise<void>((resolve, reject) => {
  391. // 如果没有传入 modelId,使用默认值或提示错误
  392. if (!processInfo.modelId) {
  393. $modal.msgError('缺少流程模型')
  394. reject(new Error('缺少流程模型 ID'))
  395. return
  396. }
  397. getProcessInfo(processInfo)
  398. .then(({ returnParams }) => {
  399. const { formId, tmodelId, isMoreIns, pathJudgeType, reqOffice } = returnParams.flow[0]
  400. processInfo.formId = formId
  401. processInfo.tmodelId = tmodelId
  402. processInfo.isMoreIns = isMoreIns
  403. processInfo.pathJudgeType = pathJudgeType
  404. processInfo.reqOffice = reqOffice || 0 // 是否需要附件(0-不需要,1-需要)
  405. resolve()
  406. })
  407. .catch(err => {
  408. console.error('获取流程信息失败:', err)
  409. reject(err)
  410. })
  411. })
  412. }
  413. function initBaseForm() {
  414. // 获取初始化数据 (流水号、部门信息等)
  415. getContractInitData(userStore.user.useId).then(res => {
  416. if (res.returnCode === '1') {
  417. const params = res.returnParams
  418. // 合同编号改为手动输入,不再生成
  419. // baseForm.contract_number = params.contract_number || ''
  420. baseForm.contract_number = '' // 清空,由用户手动输入
  421. baseForm.initiator = params.initiator || userStore.user.name
  422. baseForm.department = params.department || ''
  423. baseForm.depid = params.depid || null
  424. baseForm.applyDate = params.applyDate || ''
  425. baseForm.salesman_name = params.salesman_name || userStore.user.name
  426. baseForm.salesmanTel = params.salesmanTel || ''
  427. baseForm.salesman = params.salesman || userStore.user.useId.toString()
  428. baseForm.firstparty_name = params.firstparty_name || ''
  429. // 保存公司名称,用于销售合同时对调需方供方
  430. ;(baseForm as any).companyName = params.firstparty_name || ''
  431. // 录入人信息 (与 PC 端保持一致)
  432. baseForm.contract_entrying_operator = params.contract_entrying_operator || userStore.user.useId.toString()
  433. baseForm.contract_entrying_operator_name = params.contract_entrying_operator_name || userStore.user.name
  434. // 合同类型列表
  435. if (params.typeList && params.typeList.length > 0) {
  436. contractTypeList.value = params.typeList
  437. }
  438. // 付款方式列表(用于付款信息选择)
  439. if (params.paymentList && params.paymentList.length > 0) {
  440. paymentTypeList.value = params.paymentList
  441. }
  442. } else {
  443. console.error('获取初始化数据失败,returnCode:', res.returnCode)
  444. $modal.msgError('获取初始化数据失败:' + (res.returnMsg || '未知错误'))
  445. }
  446. }).catch(err => {
  447. console.error('获取初始化数据异常:', err)
  448. $modal.msgError('获取初始化数据失败:' + (err.message || '未知错误'))
  449. })
  450. }
  451. const baseForm = reactive({
  452. contract_number: '',
  453. contract_name: '',
  454. contract_type: '',
  455. contract_type_name: '',
  456. applyDate: '',
  457. initiator: '',
  458. department: '',
  459. depid: null,
  460. salesman: '',
  461. salesman_name: '',
  462. salesmanTel: '',
  463. supplierCode: '', // 供应商或客户的编码
  464. supplierName: '', // 供应商或客户的名称
  465. contract_money: '',
  466. contractContent: '',
  467. projectItem: '',
  468. usePosition: '',
  469. other_contractor: '',
  470. otherFile: '',
  471. salesmanSign: '',
  472. firstparty_name: '', // 需方名称
  473. secondparty_name: '', // 供方名称
  474. // 录入人信息 (与 PC 端保持一致)
  475. contract_entrying_operator: '',
  476. contract_entrying_operator_name: ''
  477. })
  478. const contractTypeList = ref<any[]>([])
  479. const paymentTypeList = ref<any[]>([])
  480. const materialList = ref<any[]>([])
  481. const paymentList = ref<any[]>([])
  482. const isSubmitting = ref(false)
  483. // 文件上传相关
  484. const fileList = ref<any[]>([])
  485. const fileSeqs = ref<any[]>([])
  486. // 表单校验规则
  487. const baseFormRef = ref(null)
  488. const baseFormRules = computed(() => {
  489. return {
  490. contract_number: {
  491. rules: [{ required: true, message: '请输入合同编号' }],
  492. label: '合同编号'
  493. },
  494. contract_name: {
  495. rules: [{ required: true, message: '请输入合同名称' }],
  496. label: '合同名称'
  497. },
  498. contract_type: {
  499. rules: [{ required: true, message: '请选择合同类型' }],
  500. label: '合同类型'
  501. },
  502. secondparty_name: {
  503. rules: [{ required: true, message: '请选择供方' }],
  504. label: '供方'
  505. }
  506. }
  507. })
  508. // 选择器相关
  509. const selectorPopup = ref(null)
  510. const selectorList = ref<any[]>([])
  511. const selectorType = ref('') // 'material', 'supplier', 'client', 'salesman'
  512. // 物料来源:'mes' - MES 系统,'purchase' - 采购申请
  513. const materialSource = ref('mes')
  514. const purchaseApplyList = ref<any[]>([]) // 采购申请单列表
  515. const selectedPurchaseApply = ref<any>(null) // 选中的采购申请单
  516. // 分页和搜索相关
  517. const currentPage = ref(1)
  518. const pageSize = 20
  519. const hasMore = ref(true)
  520. const isLoading = ref(false)
  521. const isRefreshing = ref(false)
  522. const searchKeyword = ref('')
  523. // 判断是否为销售合同
  524. const isSalesContract = computed(() => {
  525. return baseForm.contract_type === '1' || baseForm.contract_type === 1
  526. })
  527. // 合同金额是否可编辑(有物料时可编辑)
  528. const canEditContractMoney = computed(() => {
  529. return materialList.value.length > 0
  530. })
  531. const popupTitle = computed(() => {
  532. if (selectorType.value === 'material') return '选择物料'
  533. if (selectorType.value === 'supplier') return '选择供应商'
  534. if (selectorType.value === 'client') return '选择客户'
  535. if (selectorType.value === 'salesman') return '选择经办人'
  536. return '选择'
  537. })
  538. // 切换展开/收起状态
  539. function toggleExpand(index: number) {
  540. if (materialList.value[index]) {
  541. materialList.value[index].expanded = !materialList.value[index].expanded
  542. }
  543. }
  544. // 切换付款方式展开/收起
  545. function togglePaymentExpand(index: number) {
  546. if (paymentList.value[index]) {
  547. paymentList.value[index].expanded = !paymentList.value[index].expanded
  548. }
  549. }
  550. // 物料价格计算
  551. function calculateMaterialPrice(item: any) {
  552. const price = parseFloat(item.price) || 0
  553. const cess = parseFloat(item.cess) || 0
  554. // 计算税后单价:税前单价 * (1 + 税率 / 100)
  555. item.priceTax = (price * (1 + cess / 100)).toFixed(2)
  556. // 重新计算总价
  557. calculateTotalPrice()
  558. // 更新大写金额
  559. updateContractMoneyUppercase()
  560. }
  561. // 计算合同总价
  562. let manualInput = false // 标记用户是否手动输入过合同金额
  563. function calculateTotalPrice() {
  564. let total = 0
  565. const hasMaterial = materialList.value.length > 0
  566. materialList.value.forEach(item => {
  567. const qty = parseFloat(item.qty) || 0
  568. const priceTax = parseFloat(item.priceTax) || 0
  569. total += qty * priceTax
  570. })
  571. // 获取当前合同金额
  572. const currentMoney = parseFloat(baseForm.contract_money)
  573. if (hasMaterial) {
  574. // 有物料时,检查是否需要更新合同金额
  575. // 如果是手动输入且大于物料总额,保留用户输入
  576. // 否则,使用物料总额
  577. if (manualInput && currentMoney && currentMoney > total) {
  578. // 保留用户手动输入的较大值
  579. // 不更新合同金额
  580. } else {
  581. // 自动更新为物料总额(包括非手动输入,或手动输入但物料总额更大的情况)
  582. baseForm.contract_money = total.toFixed(2)
  583. // 重置手动输入标记
  584. manualInput = false
  585. }
  586. } else {
  587. // 没有物料时,只有非手动输入才清空
  588. if (!manualInput) {
  589. baseForm.contract_money = ''
  590. // 合同金额被清空时,删除所有付款信息
  591. clearAllPaymentInfo()
  592. }
  593. // 注意:如果是手动输入,即使没有物料也保留用户输入
  594. }
  595. // 更新付款信息中的金额
  596. calculatePaymentAmount()
  597. // 更新大写金额
  598. updateContractMoneyUppercase()
  599. }
  600. // 数量变化时
  601. function onQuantityBlur(item: any) {
  602. calculateTotalPrice()
  603. }
  604. // 税前单价变化时
  605. function onPriceBlur(item: any) {
  606. calculateMaterialPrice(item)
  607. }
  608. // 税率变化时
  609. function onCessBlur(item: any) {
  610. calculateMaterialPrice(item)
  611. }
  612. // 判断是否可以添加付款(有合同金额即可)
  613. const canAddPayment = computed(() => {
  614. const contractMoney = parseFloat(baseForm.contract_money) || 0
  615. return contractMoney > 0
  616. })
  617. // 添加付款方式
  618. function addPaymentInfo() {
  619. if (!canAddPayment.value) {
  620. $modal.msgWarn('请先输入合同金额')
  621. return
  622. }
  623. paymentList.value.push({
  624. payType: '',
  625. payTypeName: '',
  626. proportion: '0',
  627. amount: '0',
  628. amountPaid: '0',
  629. payTime: '',
  630. payStatus: '0',
  631. payStatusName: '未支付',
  632. remark: '',
  633. expanded: true
  634. })
  635. }
  636. // 付款方式类型变化
  637. function onPaymentTypeChange(index: number, e: any) {
  638. const selectedIndex = e.detail.value
  639. const selected = paymentTypeList.value[selectedIndex]
  640. if (selected) {
  641. paymentList.value[index].payType = selected.payType
  642. paymentList.value[index].payTypeName = selected.payTypeName
  643. }
  644. }
  645. // 付款时间变化
  646. function onPayTimeChange(item: any, e: any) {
  647. // uni-datetime-picker 返回的可能是时间戳或 Date 对象,需要转换为字符串
  648. const dateValue = e
  649. if (dateValue) {
  650. // 如果是时间戳或数字,转换为日期字符串
  651. if (typeof dateValue === 'number' || typeof dateValue === 'string') {
  652. const date = new Date(dateValue)
  653. if (!isNaN(date.getTime())) {
  654. const year = date.getFullYear()
  655. const month = String(date.getMonth() + 1).padStart(2, '0')
  656. const day = String(date.getDate()).padStart(2, '0')
  657. item.payTime = `${year}-${month}-${day}`
  658. }
  659. } else if (typeof dateValue === 'object') {
  660. // 如果已经是 Date 对象
  661. const year = dateValue.getFullYear()
  662. const month = String(dateValue.getMonth() + 1).padStart(2, '0')
  663. const day = String(dateValue.getDate()).padStart(2, '0')
  664. item.payTime = `${year}-${month}-${day}`
  665. }
  666. }
  667. }
  668. // 比例变化时重新计算金额
  669. function onProportionBlur(item: any) {
  670. calculatePaymentAmount()
  671. }
  672. // 计算付款金额(根据比例)
  673. function calculatePaymentAmount() {
  674. const contractMoney = parseFloat(baseForm.contract_money) || 0
  675. paymentList.value.forEach(item => {
  676. const proportion = parseFloat(item.proportion) || 0
  677. const amount = (contractMoney * proportion / 100).toFixed(2)
  678. item.amount = amount
  679. // 更新付款状态
  680. updatePaymentStatus(item)
  681. })
  682. }
  683. // 更新付款状态
  684. function updatePaymentStatus(item: any) {
  685. const amount = parseFloat(item.amount) || 0
  686. const amountPaid = parseFloat(item.amountPaid) || 0
  687. if (amountPaid === 0) {
  688. item.payStatus = '0'
  689. item.payStatusName = '未支付'
  690. } else if (amountPaid < amount) {
  691. item.payStatus = '1'
  692. item.payStatusName = '部分支付'
  693. } else if (amountPaid >= amount) {
  694. item.payStatus = '2'
  695. item.payStatusName = '已支付'
  696. }
  697. }
  698. // 清空所有付款信息
  699. function clearAllPaymentInfo() {
  700. paymentList.value = []
  701. }
  702. // 已付金额变化时
  703. function onAmountPaidBlur(item: any) {
  704. updatePaymentStatus(item)
  705. }
  706. // 合同金额大写
  707. const contractMoneyUppercase = ref('零元整')
  708. // 数字转中文大写函数
  709. function numberToChineseUppercase(n) {
  710. const fraction = ['角', '分']
  711. const digit = [
  712. '零', '壹', '贰', '叁', '肆',
  713. '伍', '陆', '柒', '捌', '玖'
  714. ]
  715. const unit = [
  716. ['元', '万', '亿'],
  717. ['', '拾', '佰', '仟']
  718. ]
  719. const head = n < 0 ? '欠' : ''
  720. n = Math.abs(n)
  721. let s = ''
  722. for (let i = 0; i < fraction.length; i++) {
  723. s += (digit[Math.floor(n * 10 * Math.pow(10, i)) % 10] + fraction[i]).replace(/零./, '')
  724. }
  725. s = s || '整'
  726. n = Math.floor(n)
  727. for (let i = 0; i < unit[0].length && n > 0; i++) {
  728. let p = ''
  729. for (let j = 0; j < unit[1].length && n > 0; j++) {
  730. p = digit[n % 10] + unit[1][j] + p
  731. n = Math.floor(n / 10)
  732. }
  733. s = p.replace(/(零.)*零$/, '').replace(/^$/, '零') + unit[0][i] + s
  734. }
  735. return head + s.replace(/(零.)*零元/, '元')
  736. .replace(/(零.)+/g, '零')
  737. .replace(/^整$/, '零元整')
  738. }
  739. // 更新合同金额大写显示
  740. function updateContractMoneyUppercase() {
  741. const contractMoney = parseFloat(baseForm.contract_money) || 0
  742. contractMoneyUppercase.value = numberToChineseUppercase(contractMoney)
  743. }
  744. // 监听合同金额变化(检测用户手动输入)- 失焦时触发
  745. function onContractMoneyBlur() {
  746. // 当用户手动修改合同金额时,设置手动输入标记
  747. const calculatedTotal = calculateTotalPriceValue()
  748. const currentMoney = parseFloat(baseForm.contract_money)
  749. if (currentMoney && currentMoney !== calculatedTotal) {
  750. manualInput = true
  751. }
  752. // 更新大写金额
  753. updateContractMoneyUppercase()
  754. calculatePaymentAmount()
  755. }
  756. // 计算物料总价值(仅返回数值,不更新合同金额)
  757. function calculateTotalPriceValue(): number {
  758. let total = 0
  759. materialList.value.forEach(item => {
  760. const qty = parseFloat(item.qty) || 0
  761. const priceTax = parseFloat(item.priceTax) || 0
  762. total += qty * priceTax
  763. })
  764. return total
  765. }
  766. // 打开物料选择器
  767. async function openMaterialSelector() {
  768. selectorType.value = 'material'
  769. materialSource.value = 'mes' // 默认 MES 系统模式
  770. currentPage.value = 1
  771. hasMore.value = true
  772. selectorList.value = []
  773. await loadMaterials(1, false)
  774. openPopup()
  775. }
  776. // 打开供应商选择器
  777. async function openSupplierSelector() {
  778. selectorType.value = 'supplier'
  779. currentPage.value = 1
  780. hasMore.value = true
  781. selectorList.value = []
  782. await loadSuppliers(1, false)
  783. openPopup()
  784. }
  785. // 加载物料列表(分页)
  786. async function loadMaterials(page: number, append: boolean = false) {
  787. if (isLoading.value) return
  788. isLoading.value = true
  789. if (page === 1) {
  790. isRefreshing.value = true
  791. }
  792. try {
  793. const res = await getMaterialList(
  794. userStore.user.useId,
  795. page,
  796. pageSize,
  797. searchKeyword.value
  798. )
  799. if (res.returnCode === '1') {
  800. const result = res.returnParams
  801. const newList = result.list || []
  802. if (append) {
  803. // 追加模式(加载更多)
  804. selectorList.value = [...selectorList.value, ...newList]
  805. } else {
  806. // 覆盖模式(刷新/搜索)
  807. selectorList.value = newList
  808. }
  809. // 判断是否还有更多数据
  810. hasMore.value = selectorList.value.length < result.total
  811. } else {
  812. $modal.msgError('加载物料失败')
  813. }
  814. } catch (error) {
  815. console.error('加载物料失败', error)
  816. $modal.msgError('加载失败')
  817. } finally {
  818. isLoading.value = false
  819. isRefreshing.value = false
  820. }
  821. }
  822. // 加载供应商列表(分页)
  823. async function loadSuppliers(page: number, append: boolean = false) {
  824. if (isLoading.value) return
  825. isLoading.value = true
  826. if (page === 1) {
  827. isRefreshing.value = true
  828. }
  829. try {
  830. const res = await getSupplierList(
  831. userStore.user.useId,
  832. page,
  833. pageSize,
  834. searchKeyword.value
  835. )
  836. if (res.returnCode === '1') {
  837. const result = res.returnParams
  838. const newList = result.list || []
  839. if (append) {
  840. selectorList.value = [...selectorList.value, ...newList]
  841. } else {
  842. selectorList.value = newList
  843. }
  844. hasMore.value = selectorList.value.length < result.total
  845. } else {
  846. $modal.msgError('加载供应商失败')
  847. }
  848. } catch (error) {
  849. console.error('加载供应商失败', error)
  850. $modal.msgError('加载失败')
  851. } finally {
  852. isLoading.value = false
  853. isRefreshing.value = false
  854. }
  855. }
  856. // 加载更多
  857. function loadMore() {
  858. if (!hasMore.value || isLoading.value) return
  859. currentPage.value++
  860. if (selectorType.value === 'material') {
  861. if (materialSource.value === 'mes') {
  862. loadMaterials(currentPage.value, true)
  863. } else {
  864. // 采购申请模式,加载物料分页
  865. loadPurchaseMaterials(false)
  866. }
  867. } else if (selectorType.value === 'supplier') {
  868. loadSuppliers(currentPage.value, true)
  869. } else if (selectorType.value === 'client') {
  870. loadClients(currentPage.value, true)
  871. }
  872. }
  873. // 下拉刷新
  874. function onRefresh() {
  875. currentPage.value = 1
  876. if (selectorType.value === 'material') {
  877. if (materialSource.value === 'mes') {
  878. loadMaterials(1, false)
  879. } else {
  880. // 采购申请模式,重新加载物料
  881. loadPurchaseMaterials(true)
  882. }
  883. } else if (selectorType.value === 'supplier') {
  884. loadSuppliers(1, false)
  885. } else if (selectorType.value === 'client') {
  886. loadClients(1, false)
  887. }
  888. }
  889. // 搜索
  890. function handleSearch() {
  891. currentPage.value = 1
  892. if (selectorType.value === 'material') {
  893. loadMaterials(1, false)
  894. } else if (selectorType.value === 'supplier') {
  895. loadSuppliers(1, false)
  896. } else if (selectorType.value === 'client') {
  897. loadClients(1, false)
  898. }
  899. }
  900. // 物料来源切换时
  901. async function onMaterialSourceChange() {
  902. currentPage.value = 1
  903. hasMore.value = true
  904. selectorList.value = []
  905. searchKeyword.value = ''
  906. if (materialSource.value === 'mes') {
  907. // MES 系统模式,加载物料列表
  908. await loadMaterials(1, false)
  909. } else {
  910. // 采购申请模式,先加载采购申请单列表,然后加载所有物料
  911. await loadPurchaseApplyList()
  912. // 加载完采购申请单后,立即查询物料(默认不指定具体采购单)
  913. await loadPurchaseMaterials(true) // true 表示重置分页
  914. }
  915. }
  916. // 加载采购申请单列表(与 PC 端一致,不分页)
  917. async function loadPurchaseApplyList() {
  918. if (isLoading.value) return
  919. isLoading.value = true
  920. isRefreshing.value = true
  921. try {
  922. const res = await getPurchaseApplyList(
  923. userStore.user.useId
  924. )
  925. if (res.returnCode === '1') {
  926. const result = res.returnParams
  927. purchaseApplyList.value = result.list || []
  928. selectedPurchaseApply.value = null
  929. selectorList.value = [] // 清空物料列表
  930. } else {
  931. $modal.msgError('加载采购申请单失败')
  932. }
  933. } catch (error) {
  934. console.error('加载采购申请单失败', error)
  935. $modal.msgError('加载失败')
  936. } finally {
  937. isLoading.value = false
  938. isRefreshing.value = false
  939. }
  940. }
  941. // 采购申请单选择变化
  942. function onPurchaseChange(e: any) {
  943. const selectedIndex = e.detail.value
  944. selectedPurchaseApply.value = purchaseApplyList.value[selectedIndex]
  945. // 选择采购单后,重新加载物料(重置分页)
  946. loadPurchaseMaterials(true)
  947. }
  948. // 清空采购申请单选择
  949. function clearPurchaseSelection() {
  950. selectedPurchaseApply.value = null
  951. // 清空后重新加载所有物料
  952. loadPurchaseMaterials(true)
  953. }
  954. // 加载采购申请单的物料
  955. async function loadPurchaseMaterials(resetPage = false) {
  956. if (isLoading.value) return
  957. // 如果是分页加载,不清空列表
  958. if (resetPage) {
  959. currentPage.value = 1
  960. selectorList.value = []
  961. }
  962. isLoading.value = true
  963. isRefreshing.value = resetPage
  964. try {
  965. // 如果不指定采购申请单,则查询所有物料
  966. const purchaseFormId = selectedPurchaseApply.value
  967. ? selectedPurchaseApply.value.contractPurchaseFormId.toString()
  968. : ''
  969. const res = await getPurchaseDetailList(
  970. userStore.user.useId,
  971. purchaseFormId,
  972. currentPage.value,
  973. 10 // 每页 10 条,与 PC 端一致
  974. )
  975. if (res.returnCode === '1') {
  976. const result = res.returnParams
  977. const newList = result.list || []
  978. if (resetPage) {
  979. selectorList.value = newList
  980. } else {
  981. // 追加数据
  982. selectorList.value.push(...newList)
  983. }
  984. // 判断是否还有更多数据
  985. hasMore.value = selectorList.value.length < result.total
  986. if (!resetPage) {
  987. currentPage.value++
  988. }
  989. } else {
  990. $modal.msgError('加载物料失败')
  991. }
  992. } catch (error) {
  993. console.error('加载物料失败', error)
  994. $modal.msgError('加载失败')
  995. } finally {
  996. isLoading.value = false
  997. isRefreshing.value = false
  998. }
  999. }
  1000. // 判断是否已选中
  1001. // 注意:只有当物料编码和采购申请单编号都相同时,才认为是重复选择
  1002. function isSelected(item: any): boolean {
  1003. if (selectorType.value === 'material') {
  1004. const itemCode = item.itemCode || item.materialCode || ''
  1005. const purchaseNumber = item.purchaseNumber || ''
  1006. // 检查物料列表中是否存在相同的物料(物料编码 + 采购申请单编号都相同)
  1007. return materialList.value.some(m => {
  1008. const existItemCode = m.itemCode || ''
  1009. const existPurchaseNumber = m.purchaseNumber || ''
  1010. // 只有当物料编码和采购申请单编号都相同时,才认为是重复
  1011. return existItemCode === itemCode &&
  1012. ((existPurchaseNumber === purchaseNumber) ||
  1013. (!existPurchaseNumber && !purchaseNumber))
  1014. })
  1015. } else if (selectorType.value === 'supplier') {
  1016. const code = item.vendorCode || item.supplierCode
  1017. return baseForm.supplierCode === code
  1018. } else if (selectorType.value === 'client') {
  1019. const code = item.clientCode
  1020. return baseForm.supplierCode === code
  1021. }
  1022. return false
  1023. }
  1024. function openPopup() {
  1025. ;(selectorPopup.value as any).open()
  1026. }
  1027. function closePopup() {
  1028. ;(selectorPopup.value as any).close()
  1029. }
  1030. function getSelectorItemName(item: any): string {
  1031. if (selectorType.value === 'material') {
  1032. return item.itemName || item.materialName || ''
  1033. } else if (selectorType.value === 'supplier') {
  1034. return item.vendorName || item.supplierName || ''
  1035. } else if (selectorType.value === 'client') {
  1036. return item.clientName || ''
  1037. }
  1038. return ''
  1039. }
  1040. function getItemCode(item: any): string {
  1041. if (selectorType.value === 'material') {
  1042. return item.itemCode || item.materialCode || ''
  1043. } else if (selectorType.value === 'supplier') {
  1044. return item.vendorCode || item.supplierCode || ''
  1045. } else if (selectorType.value === 'client') {
  1046. return item.clientCode || ''
  1047. }
  1048. return ''
  1049. }
  1050. function getItemSpec(item: any): string {
  1051. if (selectorType.value === 'material') {
  1052. return item.specification || item.materialModel || ''
  1053. }
  1054. // 客户和供应商没有规格字段
  1055. return ''
  1056. }
  1057. function selectItem(item: any) {
  1058. if (selectorType.value === 'material') {
  1059. addMaterial(item)
  1060. } else if (selectorType.value === 'supplier') {
  1061. selectSupplier(item)
  1062. } else if (selectorType.value === 'client') {
  1063. selectClient(item)
  1064. }
  1065. closePopup()
  1066. }
  1067. function addMaterial(item: any) {
  1068. // 检查是否已存在(根据物料编码 + 采购申请单编号判断)
  1069. const exists = isSelected(item)
  1070. if (exists) {
  1071. $modal.msgWarn('该物料已存在')
  1072. return
  1073. }
  1074. // 销售合同不允许选择有采购申请单的物料
  1075. if (isSalesContract.value) {
  1076. const purchaseId = item.purchaseId || ''
  1077. const purchaseNumber = item.purchaseNumber || ''
  1078. if ((purchaseId && purchaseId !== 'null' && purchaseId !== '0' && purchaseId !== 'undefined') ||
  1079. (purchaseNumber && purchaseNumber !== 'null' && purchaseNumber !== 'undefined')) {
  1080. $modal.msgWarn('销售合同不允许选择来自采购申请单的物料')
  1081. return
  1082. }
  1083. }
  1084. // 确保数值字段正确转换(防止后端返回对象或字符串)
  1085. const qty = parseFloat(item.qty) || 0
  1086. const price = parseFloat(item.price) || 0
  1087. const cess = parseFloat(item.cess) || 0
  1088. const priceTax = parseFloat(item.priceTax) || 0
  1089. materialList.value.push({
  1090. itemCode: item.itemCode,
  1091. itemName: item.itemName,
  1092. specification: item.specification,
  1093. measureName: item.measureName,
  1094. qty: qty,
  1095. price: price,
  1096. cess: cess,
  1097. priceTax: priceTax,
  1098. purchaseId: isSalesContract.value ? '' : (item.purchaseId || selectedPurchaseApply.value?.contractPurchaseFormId || ''),
  1099. purchaseNumber: isSalesContract.value ? '' : (item.purchaseNumber || selectedPurchaseApply.value?.contractPurchaseFormNumber || ''),
  1100. expanded: true
  1101. })
  1102. // 重新计算总价
  1103. calculateTotalPrice()
  1104. }
  1105. function selectSupplier(item: any) {
  1106. // 供方=供应商名称
  1107. baseForm.secondparty_name = item.vendorName
  1108. // supplierCode/supplierName 保存供应商信息
  1109. baseForm.supplierCode = item.vendorCode
  1110. baseForm.supplierName = item.vendorName
  1111. }
  1112. // 打开客户选择器(销售合同时使用)
  1113. async function openClientSelector() {
  1114. selectorType.value = 'client'
  1115. currentPage.value = 1
  1116. hasMore.value = true
  1117. selectorList.value = []
  1118. await loadClients(1, false)
  1119. openPopup()
  1120. }
  1121. // 加载客户列表(分页)
  1122. async function loadClients(page: number, append: boolean = false) {
  1123. if (isLoading.value) return
  1124. isLoading.value = true
  1125. if (page === 1) {
  1126. isRefreshing.value = true
  1127. }
  1128. try {
  1129. const res = await getClientList(
  1130. userStore.user.useId,
  1131. page,
  1132. pageSize,
  1133. searchKeyword.value
  1134. )
  1135. if (res.returnCode === '1') {
  1136. const result = res.returnParams
  1137. const newList = result.list || []
  1138. if (append) {
  1139. // 追加模式(加载更多)
  1140. selectorList.value = [...selectorList.value, ...newList]
  1141. } else {
  1142. // 覆盖模式(刷新/搜索)
  1143. selectorList.value = newList
  1144. }
  1145. // 判断是否还有更多数据
  1146. hasMore.value = selectorList.value.length < result.total
  1147. } else {
  1148. $modal.msgError('加载客户失败')
  1149. }
  1150. } catch (error) {
  1151. console.error('加载客户失败', error)
  1152. $modal.msgError('加载失败')
  1153. } finally {
  1154. isLoading.value = false
  1155. isRefreshing.value = false
  1156. }
  1157. }
  1158. // 选择客户
  1159. function selectClient(item: any) {
  1160. // 需方=客户名称
  1161. baseForm.firstparty_name = item.clientName
  1162. // supplierCode/supplierName 保存客户信息
  1163. baseForm.supplierCode = item.clientCode
  1164. baseForm.supplierName = item.clientName
  1165. }
  1166. function removeMaterial(index: number) {
  1167. $modal.confirm('', '确认删除该物料?')
  1168. .then(() => {
  1169. materialList.value.splice(index, 1)
  1170. // 重新计算总价
  1171. calculateTotalPrice()
  1172. })
  1173. .catch(() => {})
  1174. }
  1175. function removePayment(index: number) {
  1176. $modal.confirm('', '确认删除该付款方式?')
  1177. .then(() => {
  1178. paymentList.value.splice(index, 1)
  1179. })
  1180. .catch(() => {})
  1181. }
  1182. // 合同类型变化
  1183. let lastContractType = '' // 保存上一次的合同类型
  1184. function onContractTypeChange(e: any) {
  1185. const index = e.detail.value
  1186. const oldContractType = lastContractType
  1187. const newContractType = contractTypeList.value[index].contract_type
  1188. // 如果合同类型发生变化,检查是否需要清理物料
  1189. if (oldContractType !== String(newContractType)) {
  1190. // 切换到销售合同时,检查是否有来自采购申请单的物料
  1191. if (newContractType === '1' || newContractType === 1) {
  1192. const invalidMaterials: number[] = []
  1193. materialList.value.forEach((item, idx) => {
  1194. const purchaseId = item.purchaseId || ''
  1195. const purchaseNumber = item.purchaseNumber || ''
  1196. // 排除空值、null字符串、0等无效值
  1197. if ((purchaseId && purchaseId !== 'null' && purchaseId !== '0' && purchaseId !== 'undefined') ||
  1198. (purchaseNumber && purchaseNumber !== 'null' && purchaseNumber !== 'undefined')) {
  1199. invalidMaterials.push(idx)
  1200. }
  1201. })
  1202. if (invalidMaterials.length > 0) {
  1203. $modal.confirm('', `检测到已选择的物料中有 ${invalidMaterials.length} 条来自采购申请单的数据,销售合同不允许使用采购申请单物料,是否清除这些不符合要求的物料?`)
  1204. .then(() => {
  1205. // 用户确认,删除不符合要求的物料(从后往前删,避免索引错乱)
  1206. for (let i = invalidMaterials.length - 1; i >= 0; i--) {
  1207. materialList.value.splice(invalidMaterials[i], 1)
  1208. }
  1209. // 重新计算总价
  1210. calculateTotalPrice()
  1211. // 更新合同类型为销售合同
  1212. baseForm.contract_type = newContractType
  1213. baseForm.contract_type_name = contractTypeList.value[index].contract_type_name
  1214. lastContractType = String(newContractType)
  1215. // 调整需方供方显示
  1216. adjustPartyDisplay()
  1217. $modal.msgSuccess(`已清除 ${invalidMaterials.length} 条不符合要求的物料`)
  1218. })
  1219. .catch(() => {
  1220. // 用户取消,恢复原来的合同类型
  1221. // 不需要做任何事,因为还没有更新 contract_type
  1222. })
  1223. return // 等待用户确认后再继续
  1224. }
  1225. }
  1226. }
  1227. // 更新合同类型
  1228. baseForm.contract_type = newContractType
  1229. baseForm.contract_type_name = contractTypeList.value[index].contract_type_name
  1230. lastContractType = String(newContractType)
  1231. // 根据合同类型调整需方和供方的显示
  1232. adjustPartyDisplay()
  1233. }
  1234. // 根据合同类型调整需方和供方的显示
  1235. function adjustPartyDisplay() {
  1236. // 从初始化数据中获取公司名称(需在 initBaseForm 中保存)
  1237. const companyName = (baseForm as any).companyName || ''
  1238. if (isSalesContract.value) {
  1239. // 销售合同:需方=选择客户,供方=公司名称(只读)
  1240. baseForm.secondparty_name = companyName
  1241. baseForm.supplierCode = ''
  1242. baseForm.supplierName = ''
  1243. baseForm.firstparty_name = ''
  1244. } else {
  1245. // 其他合同类型:需方=公司名称(只读),供方=选择供应商
  1246. baseForm.firstparty_name = companyName
  1247. baseForm.secondparty_name = ''
  1248. baseForm.supplierCode = ''
  1249. baseForm.supplierName = ''
  1250. }
  1251. }
  1252. // 文件上传相关函数
  1253. async function handleFileSelect(files: any) {
  1254. files.tempFiles.forEach(async (file: any) => {
  1255. const data = {
  1256. name: file.name,
  1257. filePath: file.path,
  1258. }
  1259. try {
  1260. const res = await uploadFile(data)
  1261. file.seq = res.returnParams
  1262. fileSeqs.value.push({ 'seq': res.returnParams, 'path': file.path })
  1263. fileList.value.push(file)
  1264. $modal.msgSuccess('文件' + data.name + '上传成功')
  1265. } catch (err) {
  1266. $modal.msgError('文件' + data.name + '上传失败,请删除重新上传')
  1267. console.error('文件上传失败:', err)
  1268. }
  1269. })
  1270. }
  1271. function handleFileProgress(file: any, progress: any) {
  1272. //console.log('handleFileProgress', file, progress)
  1273. }
  1274. function handleFileSuccess(file: any, res: any) {
  1275. //console.log('handleFileSuccess', file, res)
  1276. }
  1277. function handleFileFail(file: any, err: any) {
  1278. //console.log('handleFileFail', file, err)
  1279. }
  1280. function handleFileDelete(file: any) {
  1281. const index = fileSeqs.value.findIndex(({ path }) => path === file.tempFilePath)
  1282. if (index !== -1) {
  1283. fileSeqs.value.splice(index, 1)
  1284. }
  1285. }
  1286. async function submitForm() {
  1287. // 先进行表单校验
  1288. if (!baseFormRef.value) {
  1289. $modal.msgError('表单未初始化')
  1290. return
  1291. }
  1292. try {
  1293. await baseFormRef.value.validate()
  1294. } catch (error) {
  1295. console.error('表单校验失败', error)
  1296. $modal.msgError('请填写必填项')
  1297. return
  1298. }
  1299. // 1. 校验基本信息
  1300. // 1. 校验必填字段
  1301. if (!baseForm.contract_number || baseForm.contract_number.trim() === '') {
  1302. $modal.msgError('合同编号不能为空')
  1303. return
  1304. }
  1305. // 验证合同编号唯一性
  1306. try {
  1307. const checkRes = await checkContractNumber(userStore.user.useId, baseForm.contract_number)
  1308. if (checkRes.returnCode !== '1') {
  1309. $modal.msgError(checkRes.returnMsg || '合同编号验证失败')
  1310. return
  1311. }
  1312. } catch (error) {
  1313. console.error('合同编号验证失败', error)
  1314. $modal.msgError('合同编号验证失败,请重试')
  1315. return
  1316. }
  1317. if (!baseForm.contract_name || baseForm.contract_name.trim() === '') {
  1318. $modal.msgError('合同名称不能为空')
  1319. return
  1320. }
  1321. if (baseForm.contract_name.length > 100) {
  1322. $modal.msgError('合同名称长度不能超过 100')
  1323. return
  1324. }
  1325. // 校验合同类型不能为空(可能是数字或字符串)
  1326. if (!baseForm.contract_type && baseForm.contract_type !== 0) {
  1327. $modal.msgError('合同类型不能为空')
  1328. return
  1329. }
  1330. // 经办人验证(与 PC 端一致)
  1331. /*if (!baseForm.salesman || !baseForm.salesman.trim()) {
  1332. $modal.msgError('经办人不能为空')
  1333. return
  1334. }*/
  1335. // 合同金额验证(与 PC 端一致,验证是否为数字)
  1336. if (baseForm.contract_money && isNaN(Number(baseForm.contract_money))) {
  1337. $modal.msgError('合同金额只能是数字')
  1338. return
  1339. }
  1340. // 根据合同类型验证不同字段:销售合同验证需方(客户),其他合同验证供方(供应商)
  1341. if (isSalesContract.value) {
  1342. // 销售合同:验证需方(客户)
  1343. if (!baseForm.firstparty_name || baseForm.firstparty_name.trim() === '') {
  1344. $modal.msgError('需方不能为空')
  1345. return
  1346. }
  1347. } else {
  1348. // 其他合同:验证供方(供应商)
  1349. if (!baseForm.secondparty_name || baseForm.secondparty_name.trim() === '') {
  1350. $modal.msgError('供方不能为空')
  1351. return
  1352. }
  1353. }
  1354. // 2. 校验物料列表(如果添加了的话)
  1355. for (let i = 0; i < materialList.value.length; i++) {
  1356. const item = materialList.value[i]
  1357. if (!item.qty || Number(item.qty) <= 0) {
  1358. $modal.msgError(`请填写第${i + 1}个物料的数量,且必须大于 0`)
  1359. return
  1360. }
  1361. if (!item.price || Number(item.price) < 0) {
  1362. $modal.msgError(`请填写第${i + 1}个物料的税前单价,且不能为负数`)
  1363. return
  1364. }
  1365. if (!item.cess || Number(item.cess) < 0) {
  1366. $modal.msgError(`请填写第${i + 1}个物料的税率,且不能为负数`)
  1367. return
  1368. }
  1369. if (!item.priceTax || Number(item.priceTax) < 0) {
  1370. $modal.msgError(`请填写第${i + 1}个物料的税后单价,且不能为负数`)
  1371. return
  1372. }
  1373. }
  1374. // 3. 校验付款信息(如果有添加的话)
  1375. if (paymentList.value.length > 0) {
  1376. // 校验每个付款信息的必填字段
  1377. for (let i = 0; i < paymentList.value.length; i++) {
  1378. const item = paymentList.value[i]
  1379. if (!item.payType || item.payType.trim() === '') {
  1380. $modal.msgError(`请填写第${i + 1}个付款方式的付款方式`)
  1381. return
  1382. }
  1383. if (!item.proportion || Number(item.proportion) <= 0) {
  1384. $modal.msgError(`请填写第${i + 1}个付款方式的比例,且必须大于 0`)
  1385. return
  1386. }
  1387. /* if (!item.amount || Number(item.amount) < 0) {
  1388. $modal.msgError(`请填写第${i + 1}个付款方式的金额,且不能为负数`)
  1389. return
  1390. }*/
  1391. }
  1392. }
  1393. // 4. 校验合同金额不能小于物料总金额
  1394. if (materialList.value.length > 0) {
  1395. const contractMoney = parseFloat(baseForm.contract_money) || 0
  1396. let totalPrice = 0
  1397. materialList.value.forEach(item => {
  1398. const qty = parseFloat(item.qty) || 0
  1399. const priceTax = parseFloat(item.priceTax) || 0
  1400. totalPrice += qty * priceTax
  1401. })
  1402. if (contractMoney && contractMoney < totalPrice) {
  1403. $modal.msgError('合同金额不能小于物料总金额:' + totalPrice.toFixed(2))
  1404. return
  1405. }
  1406. }
  1407. isSubmitting.value = true
  1408. try {
  1409. // 构建表单数据 (注意字段命名要与后端 Java 模型一致)
  1410. const formData = {
  1411. contract_number: baseForm.contract_number,
  1412. contract_name: baseForm.contract_name,
  1413. contract_type: baseForm.contract_type,
  1414. applyDate: baseForm.applyDate,
  1415. initiator: baseForm.initiator,
  1416. department: baseForm.department,
  1417. depid: baseForm.depid,
  1418. salesman: baseForm.salesman,
  1419. salesman_name: baseForm.salesman_name,
  1420. salesmanTel: baseForm.salesmanTel,
  1421. supplierCode: baseForm.supplierCode,
  1422. supplierName: baseForm.supplierName,
  1423. contract_money: baseForm.contract_money,
  1424. contractContent: baseForm.contractContent,
  1425. projectItem: baseForm.projectItem,
  1426. usePosition: baseForm.usePosition,
  1427. other_contractor: baseForm.other_contractor,
  1428. otherFile: baseForm.otherFile,
  1429. salesmanSign: baseForm.salesmanSign,
  1430. firstparty_name: baseForm.firstparty_name,
  1431. secondparty_name: baseForm.secondparty_name,
  1432. // 录入人信息 (与 PC 端保持一致)
  1433. contract_entrying_operator: baseForm.contract_entrying_operator,
  1434. contract_entrying_operator_name: baseForm.contract_entrying_operator_name,
  1435. materialList: materialList.value.map(item => ({
  1436. itemCode: item.itemCode,
  1437. itemName: item.itemName,
  1438. specification: item.specification,
  1439. measureName: item.measureName,
  1440. qty: item.qty,
  1441. price: item.price,
  1442. cess: item.cess,
  1443. priceTax: item.priceTax,
  1444. purchaseId: item.purchaseId,
  1445. purchaseNumber: item.purchaseNumber
  1446. })),
  1447. paymentList: paymentList.value.map(item => ({
  1448. payType: item.payType,
  1449. payTypeName: item.payTypeName,
  1450. proportion: item.proportion,
  1451. amount: item.amount,
  1452. amountPaid: item.amountPaid,
  1453. payTime: item.payTime,
  1454. payStatus: item.payStatus,
  1455. payStatusName: item.payStatusName,
  1456. remark: item.remark
  1457. }))
  1458. }
  1459. // 准备提交流程参数
  1460. const processInfoData = {
  1461. staffId: userStore.user.useId,
  1462. staffName: userStore.user.name,
  1463. gxId: userStore.user.gxId,
  1464. groupId: userStore.user.groupid,
  1465. insName: userStore.user.name + '的' + processInfo.modelName,
  1466. modelId: processInfo.modelId,
  1467. tmodelId: processInfo.tmodelId,
  1468. formId: processInfo.formId,
  1469. fileIds: fileSeqs.value.length === 0 ? '' : fileSeqs.value.map(f => f.seq)
  1470. }
  1471. // 检查是否需要附件
  1472. if (processInfo.reqOffice == 1 && fileSeqs.value.length === 0) {
  1473. $modal.msgError('该流程需要上传附件')
  1474. isSubmitting.value = false
  1475. return
  1476. }
  1477. // 一次性提交表单和流程数据
  1478. const res = await startContractProcess(userStore.user.useId, formData, processInfoData)
  1479. if (res.returnCode !== '1') {
  1480. $modal.msgError(res.returnMsg || '提交失败')
  1481. isSubmitting.value = false
  1482. return
  1483. }
  1484. $modal.msgSuccess('提交成功')
  1485. setTimeout(() => {
  1486. $tab.navigateBack()
  1487. }, 1000)
  1488. } catch (error) {
  1489. console.error('提交失败', error)
  1490. $modal.msgError('提交失败,请重试')
  1491. } finally {
  1492. isSubmitting.value = false
  1493. }
  1494. }
  1495. </script>
  1496. <style lang="scss" scoped>
  1497. .contract-container {
  1498. padding-bottom: 80px;
  1499. }
  1500. .selector-wrapper {
  1501. padding: 10px 0;
  1502. cursor: pointer;
  1503. .placeholder {
  1504. color: #c0c4cc;
  1505. }
  1506. }
  1507. .payment-actions,
  1508. .material-actions {
  1509. display: flex;
  1510. gap: 10px;
  1511. margin-bottom: 15px;
  1512. button {
  1513. flex: 1;
  1514. }
  1515. }
  1516. // 物料列表 - 卡片式展示
  1517. .material-list {
  1518. display: flex;
  1519. flex-direction: column;
  1520. gap: 10px;
  1521. }
  1522. .material-card {
  1523. border: 1px solid #e5e5e5;
  1524. border-radius: 6px;
  1525. overflow: hidden;
  1526. background-color: #fff;
  1527. margin-bottom: 8px;
  1528. .material-header {
  1529. display: flex;
  1530. justify-content: space-between;
  1531. align-items: center;
  1532. padding: 10px 12px;
  1533. background-color: #f8f9fa;
  1534. cursor: pointer;
  1535. .material-main-info {
  1536. display: flex;
  1537. align-items: center;
  1538. gap: 8px;
  1539. flex: 1;
  1540. .material-name {
  1541. font-size: 14px;
  1542. font-weight: bold;
  1543. color: #333;
  1544. }
  1545. .material-code {
  1546. font-size: 12px;
  1547. color: #999;
  1548. white-space: nowrap;
  1549. }
  1550. }
  1551. .material-expand {
  1552. display: flex;
  1553. align-items: center;
  1554. margin-left: 10px;
  1555. }
  1556. }
  1557. .material-detail {
  1558. padding: 10px 12px;
  1559. border-top: 1px solid #e5e5e5;
  1560. .detail-row {
  1561. display: flex;
  1562. align-items: center;
  1563. flex-wrap: wrap;
  1564. gap: 8px;
  1565. margin-bottom: 8px;
  1566. .detail-label {
  1567. font-size: 13px;
  1568. color: #666;
  1569. flex-shrink: 0;
  1570. }
  1571. .detail-value {
  1572. flex: 0 0 auto;
  1573. font-size: 13px;
  1574. color: #333;
  1575. }
  1576. .price-value {
  1577. font-weight: bold;
  1578. color: #f76560;
  1579. }
  1580. // ✅ 采购申请单编号样式
  1581. &.purchase-number-row {
  1582. background-color: #f9f9f9;
  1583. padding: 6px 8px;
  1584. border-radius: 4px;
  1585. margin-top: 4px;
  1586. .detail-label {
  1587. color: #999;
  1588. font-size: 12px;
  1589. }
  1590. .purchase-number {
  1591. color: #007aff;
  1592. font-weight: 500;
  1593. font-size: 13px;
  1594. }
  1595. }
  1596. }
  1597. .delete-row {
  1598. margin-top: 10px;
  1599. text-align: center;
  1600. padding-top: 8px;
  1601. border-top: 1px dashed #e5e5e5;
  1602. }
  1603. }
  1604. }
  1605. // 付款方式列表
  1606. .payment-list {
  1607. display: flex;
  1608. flex-direction: column;
  1609. gap: 10px;
  1610. }
  1611. .payment-card {
  1612. border: 1px solid #e5e5e5;
  1613. border-radius: 6px;
  1614. overflow: hidden;
  1615. background-color: #fff;
  1616. margin-bottom: 8px;
  1617. .payment-header {
  1618. display: flex;
  1619. justify-content: space-between;
  1620. align-items: center;
  1621. padding: 10px 12px;
  1622. background-color: #f8f9fa;
  1623. cursor: pointer;
  1624. .payment-main-info {
  1625. display: flex;
  1626. align-items: center;
  1627. gap: 8px;
  1628. flex: 1;
  1629. .payment-type {
  1630. font-size: 14px;
  1631. font-weight: bold;
  1632. color: #333;
  1633. }
  1634. .payment-proportion {
  1635. font-size: 12px;
  1636. color: #999;
  1637. }
  1638. }
  1639. .payment-expand {
  1640. display: flex;
  1641. align-items: center;
  1642. margin-left: 10px;
  1643. }
  1644. }
  1645. .payment-detail {
  1646. padding: 10px 12px;
  1647. border-top: 1px solid #e5e5e5;
  1648. .detail-row {
  1649. display: flex;
  1650. align-items: center;
  1651. flex-wrap: wrap;
  1652. gap: 8px;
  1653. margin-bottom: 8px;
  1654. .detail-label {
  1655. font-size: 13px;
  1656. color: #666;
  1657. flex-shrink: 0;
  1658. }
  1659. .detail-value {
  1660. flex: 0 0 auto;
  1661. font-size: 13px;
  1662. color: #333;
  1663. }
  1664. .status-tag {
  1665. padding: 2px 8px;
  1666. border-radius: 4px;
  1667. font-size: 12px;
  1668. &.status-0 {
  1669. background-color: #f0f0f0;
  1670. color: #999;
  1671. }
  1672. &.status-1 {
  1673. background-color: #ffecdb;
  1674. color: #ff8800;
  1675. }
  1676. &.status-2 {
  1677. background-color: #e8f5e9;
  1678. color: #4caf50;
  1679. }
  1680. }
  1681. }
  1682. .delete-row {
  1683. margin-top: 10px;
  1684. text-align: center;
  1685. padding-top: 8px;
  1686. border-top: 1px dashed #e5e5e5;
  1687. }
  1688. }
  1689. }
  1690. .empty-materials,
  1691. .empty-payments {
  1692. text-align: center;
  1693. padding: 30px;
  1694. color: #909399;
  1695. font-size: 14px;
  1696. }
  1697. // 合同金额大写样式
  1698. .contract-money-uppercase {
  1699. font-size: 12px;
  1700. color: #666;
  1701. margin-top: 5px;
  1702. padding-left: 2px;
  1703. }
  1704. .submit-btn-wrapper {
  1705. position: sticky;
  1706. width: 100%;
  1707. bottom: 10px;
  1708. padding: 10px 15px;
  1709. background-color: #fff;
  1710. box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  1711. z-index: 10;
  1712. box-sizing: border-box;
  1713. button {
  1714. background-color: #007aff !important;
  1715. color: #fff !important;
  1716. }
  1717. }
  1718. .selector-popup {
  1719. // ✅ 关键:使用固定宽度,不设置 width,只使用 max-width
  1720. width: 580px; // 固定宽度
  1721. max-width: 95vw; // 最大为屏幕宽度的 95%
  1722. min-width: 300px;
  1723. max-height: 70vh;
  1724. background-color: #fff;
  1725. border-radius: 12px;
  1726. overflow: hidden; // ✅ 隐藏所有超出内容
  1727. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  1728. position: relative;
  1729. margin: 0 auto;
  1730. .popup-header {
  1731. display: flex;
  1732. justify-content: space-between;
  1733. align-items: center;
  1734. padding: 15px;
  1735. border-bottom: 1px solid #e5e5e5;
  1736. width: 100%;
  1737. box-sizing: border-box;
  1738. overflow: hidden; // ✅ 防止内容撑开
  1739. .popup-title {
  1740. font-size: 16px;
  1741. font-weight: bold;
  1742. overflow: hidden;
  1743. text-overflow: ellipsis;
  1744. white-space: nowrap;
  1745. max-width: calc(100% - 30px); // ✅ 给关闭按钮留空间
  1746. }
  1747. }
  1748. // 物料来源选择器
  1749. .material-source-selector {
  1750. padding: 10px 15px;
  1751. border-bottom: 1px solid #f0f0f0;
  1752. width: 100%;
  1753. box-sizing: border-box;
  1754. overflow: hidden;
  1755. .source-options {
  1756. display: flex;
  1757. gap: 10px;
  1758. width: 100%;
  1759. .source-option {
  1760. flex: 1;
  1761. min-width: 0; // ✅ 允许缩小
  1762. padding: 8px 12px;
  1763. text-align: center;
  1764. background-color: #f5f5f5;
  1765. border-radius: 6px;
  1766. font-size: 14px;
  1767. cursor: pointer;
  1768. transition: all 0.2s;
  1769. overflow: hidden; // ✅ 防止撑开
  1770. &.active {
  1771. background-color: #007aff;
  1772. color: #fff;
  1773. font-weight: 500;
  1774. }
  1775. }
  1776. }
  1777. }
  1778. // 采购申请单选择器
  1779. .purchase-selector {
  1780. display: flex;
  1781. gap: 8px; // ✅ 减小间距
  1782. padding: 10px 15px;
  1783. border-bottom: 1px solid #f0f0f0;
  1784. align-items: center;
  1785. width: 100%;
  1786. box-sizing: border-box;
  1787. overflow: hidden;
  1788. .picker {
  1789. flex: 1;
  1790. min-width: 0; // ✅ 允许缩小
  1791. padding: 8px 12px;
  1792. background-color: #f5f5f5;
  1793. border-radius: 6px;
  1794. font-size: 14px;
  1795. overflow: hidden;
  1796. text-overflow: ellipsis; // ✅ 超出显示省略号
  1797. }
  1798. // ✅ 清空按钮样式
  1799. button[type="warn"] {
  1800. flex-shrink: 0;
  1801. padding: 0 12px;
  1802. }
  1803. }
  1804. .search-bar {
  1805. display: flex;
  1806. gap: 10px;
  1807. padding: 10px 15px;
  1808. align-items: center;
  1809. width: 100%;
  1810. box-sizing: border-box;
  1811. overflow: hidden;
  1812. }
  1813. .popup-content {
  1814. max-height: 50vh;
  1815. width: 100%;
  1816. overflow-x: hidden;
  1817. // ✅ 强制使用固定布局
  1818. position: relative;
  1819. .selector-item {
  1820. padding: 10px 12px;
  1821. border-bottom: 1px solid #f0f0f0;
  1822. width: 100%;
  1823. box-sizing: border-box;
  1824. // ✅ 防止内容撑开
  1825. overflow: hidden;
  1826. &:active {
  1827. background-color: #f5f5f5;
  1828. }
  1829. .selector-item-content {
  1830. display: flex;
  1831. justify-content: space-between;
  1832. align-items: center;
  1833. gap: 8px;
  1834. width: 100%;
  1835. max-width: 100%;
  1836. overflow: hidden;
  1837. // ✅ 关键:强制缩小
  1838. min-width: 0;
  1839. .item-info {
  1840. // ✅ 最强力的缩小设置
  1841. flex: 1 1 auto !important;
  1842. min-width: 0 !important;
  1843. max-width: none !important;
  1844. display: flex;
  1845. flex-wrap: wrap;
  1846. align-items: center;
  1847. gap: 4px;
  1848. overflow: hidden;
  1849. position: relative;
  1850. .item-name {
  1851. font-size: 15px;
  1852. font-weight: bold;
  1853. color: #333;
  1854. flex-basis: 100%;
  1855. margin-bottom: 4px;
  1856. word-break: break-all; // 长文字换行
  1857. overflow-wrap: break-word;
  1858. }
  1859. // 采购单号
  1860. .item-purchase {
  1861. font-size: 12px;
  1862. color: #007aff;
  1863. flex-basis: 100%;
  1864. margin-bottom: 2px;
  1865. word-break: break-all;
  1866. overflow-wrap: break-word;
  1867. }
  1868. .item-code,
  1869. .item-spec,
  1870. .item-extra {
  1871. font-size: 13px;
  1872. color: #666;
  1873. white-space: nowrap;
  1874. font-weight: 500;
  1875. flex-shrink: 0;
  1876. max-width: 100%; // 限制最大宽度
  1877. overflow: hidden;
  1878. text-overflow: ellipsis; // 超出显示省略号
  1879. }
  1880. .item-code::after,
  1881. .item-spec::after {
  1882. content: ' | ';
  1883. margin: 0 4px;
  1884. color: #ddd;
  1885. }
  1886. .item-spec:last-child::after,
  1887. .item-extra:last-child::after {
  1888. content: '';
  1889. }
  1890. }
  1891. .selected-tag {
  1892. color: #409eff;
  1893. font-size: 12px;
  1894. flex-shrink: 0;
  1895. flex-grow: 0;
  1896. white-space: nowrap;
  1897. max-width: 50px; // ✅ 限制最大宽度
  1898. overflow: hidden;
  1899. text-overflow: ellipsis;
  1900. }
  1901. }
  1902. }
  1903. .loading-text {
  1904. text-align: center;
  1905. padding: 12px;
  1906. color: #909399;
  1907. font-size: 13px;
  1908. }
  1909. .no-more-text {
  1910. text-align: center;
  1911. padding: 12px;
  1912. color: #909399;
  1913. font-size: 13px;
  1914. }
  1915. .empty-data {
  1916. text-align: center;
  1917. padding: 30px;
  1918. color: #909399;
  1919. }
  1920. }
  1921. }
  1922. // 基本信息中的禁用字段样式优化(参考 edit/index.vue)
  1923. ::v-deep .uni-forms {
  1924. .uni-forms-item__content {
  1925. .uni-easyinput__content-input {
  1926. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1927. font-weight: 500;
  1928. color: #333;
  1929. }
  1930. .uni-date {
  1931. .uni-icons {
  1932. font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  1933. font-weight: 500;
  1934. }
  1935. .uni-date__x-input {
  1936. height: auto;
  1937. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1938. font-weight: 500;
  1939. color: #333;
  1940. }
  1941. }
  1942. }
  1943. }
  1944. </style>