start.vue 63 KB

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