contract-form.vue 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523
  1. <!-- 合同流程专用表单组件 -->
  2. <template>
  3. <view class="contract-form-component">
  4. <!-- 基本信息 -->
  5. <uni-card>
  6. <uni-section titleFontSize="1.3rem" title="基本信息" type="line"></uni-section>
  7. <uni-forms ref="baseFormRef" :modelValue="baseForm" :rules="baseFormRules" label-position="left" :label-width="100" :border="true">
  8. <uni-forms-item name="contract_number" label="合同编号">
  9. <!-- 发起环节或字段可编辑时显示输入框 -->
  10. <uni-easyinput v-if="isInitiateOrFieldEditable('contract_number')"
  11. v-model="baseForm.contract_number"
  12. placeholder="请输入合同编号"></uni-easyinput>
  13. <!-- 否则显示只读文本 -->
  14. <uni-easyinput v-else v-model="baseForm.contract_number" disabled></uni-easyinput>
  15. </uni-forms-item>
  16. <uni-forms-item name="contract_name" label="合同名称" required>
  17. <uni-easyinput v-model="baseForm.contract_name"
  18. :disabled="!isInitiateOrFieldEditable('contract_name')"
  19. :placeholder="'请输入合同名称'"
  20. :clearable="false"></uni-easyinput>
  21. </uni-forms-item>
  22. <uni-forms-item name="contract_type" label="合同类型" required>
  23. <!-- 合同类型:发起环节或字段可编辑时显示选择器 -->
  24. <picker v-if="isInitiateOrFieldEditable('contract_type')"
  25. @change="onContractTypeChange"
  26. :range="contractTypeList"
  27. range-key="contract_type_name">
  28. <view class="picker">{{ baseForm.contract_type_name || '请选择合同类型' }}</view>
  29. </picker>
  30. <uni-easyinput v-else v-model="baseForm.contract_type_name" disabled></uni-easyinput>
  31. </uni-forms-item>
  32. <uni-forms-item name="applyDate" label="填报日期">
  33. <uni-easyinput v-model="baseForm.applyDate" disabled></uni-easyinput>
  34. </uni-forms-item>
  35. <uni-forms-item name="department" label="填报部门">
  36. <uni-easyinput v-model="baseForm.department" disabled></uni-easyinput>
  37. </uni-forms-item>
  38. <uni-forms-item name="salesman_name" label="经办人">
  39. <!-- 经办人:发起环节或字段可编辑时显示选择器 -->
  40. <!-- <uni-easyinput v-if="isInitiateOrFieldEditable('salesman_name')"
  41. v-model="baseForm.salesman_name"
  42. :disabled="!isInitiateOrFieldEditable('salesman_name')"
  43. placeholder="自动生成"></uni-easyinput>-->
  44. <uni-easyinput v-model="baseForm.salesman_name" disabled></uni-easyinput>
  45. </uni-forms-item>
  46. <uni-forms-item name="salesmanTel" label="联系电话">
  47. <uni-easyinput v-model="baseForm.salesmanTel"
  48. :disabled="!isInitiateOrFieldEditable('salesmanTel')"
  49. type="number"
  50. placeholder="请输入联系电话"></uni-easyinput>
  51. </uni-forms-item>
  52. <uni-forms-item name="firstparty_name" label="需方" required>
  53. <!-- 销售合同:显示选择客户按钮 -->
  54. <view v-if="isSalesContract && isInitiateOrFieldEditable('firstparty_name')"
  55. class="selector-wrapper"
  56. @click="openClientSelector">
  57. <text v-if="baseForm.firstparty_name">{{ baseForm.firstparty_name }}</text>
  58. <text v-else class="placeholder">请选择客户</text>
  59. </view>
  60. <!-- 其他合同类型或不可编辑时:显示公司名称(只读) -->
  61. <uni-easyinput v-else v-model="baseForm.firstparty_name" disabled></uni-easyinput>
  62. </uni-forms-item>
  63. <uni-forms-item name="secondparty_name" label="供方" required>
  64. <!-- 销售合同:显示公司名称(只读) -->
  65. <uni-easyinput v-if="isSalesContract" v-model="baseForm.secondparty_name" disabled></uni-easyinput>
  66. <!-- 其他合同类型:发起环节或字段可编辑时显示选择器 -->
  67. <view v-else-if="isInitiateOrFieldEditable('secondparty_name')"
  68. class="selector-wrapper"
  69. @click="openSupplierSelector">
  70. <text v-if="baseForm.secondparty_name">{{ baseForm.secondparty_name }}</text>
  71. <text v-else class="placeholder">请选择供应商</text>
  72. </view>
  73. <uni-easyinput v-else v-model="baseForm.secondparty_name" disabled></uni-easyinput>
  74. </uni-forms-item>
  75. <uni-forms-item name="contract_money" label="合同金额">
  76. <uni-easyinput v-model="baseForm.contract_money"
  77. :disabled="!isInitiateOrFieldEditable('contract_money')"
  78. type="digit"
  79. placeholder="请输入合同金额"></uni-easyinput>
  80. </uni-forms-item>
  81. <uni-forms-item name="contractContent" label="合同内容">
  82. <uni-easyinput v-if="isInitiateOrFieldEditable('contractContent')"
  83. v-model="baseForm.contractContent"
  84. type="textarea"
  85. placeholder="请输入合同内容"></uni-easyinput>
  86. <text v-else class="field-value">{{ baseForm.contractContent || '-' }}</text>
  87. </uni-forms-item>
  88. <uni-forms-item name="projectItem" label="所属项目或产品">
  89. <uni-easyinput v-model="baseForm.projectItem"
  90. :disabled="!isInitiateOrFieldEditable('projectItem')"
  91. placeholder="请输入所属项目或产品"></uni-easyinput>
  92. </uni-forms-item>
  93. <uni-forms-item name="usePosition" label="使用位置">
  94. <uni-easyinput v-model="baseForm.usePosition"
  95. :disabled="!isInitiateOrFieldEditable('usePosition')"
  96. placeholder="请输入使用位置"></uni-easyinput>
  97. </uni-forms-item>
  98. <uni-forms-item name="other_contractor" label="对方联系人及电话">
  99. <uni-easyinput v-model="baseForm.other_contractor"
  100. :disabled="!isInitiateOrFieldEditable('other_contractor')"
  101. placeholder="请输入对方联系人及电话"></uni-easyinput>
  102. </uni-forms-item>
  103. <uni-forms-item name="otherFile" label="随合同提交的其它材料">
  104. <uni-easyinput v-if="isInitiateOrFieldEditable('otherFile')"
  105. v-model="baseForm.otherFile"
  106. type="textarea"
  107. placeholder="请输入其它材料说明"></uni-easyinput>
  108. <text v-else class="field-value">{{ baseForm.otherFile || '-' }}</text>
  109. </uni-forms-item>
  110. <uni-forms-item name="salesmanSign" label="经办人签字">
  111. <uni-easyinput v-model="baseForm.salesmanSign"
  112. :disabled="!isInitiateOrFieldEditable('salesmanSign')"
  113. placeholder="请输入经办人签字"></uni-easyinput>
  114. </uni-forms-item>
  115. <!-- 部门意见 -->
  116. <uni-forms-item label="部门意见" name="departmentalOpinion">
  117. <view class="element_value_container">
  118. <view v-if="isApprovalFieldEditable(departmentalOpinionElem)" class="element_value">
  119. <!-- 审批签字板 -->
  120. <view v-if="departmentalOpinionElem && (!departmentalOpinionElem.defaultValue || departmentalOpinionElem.defaultValue == '')">
  121. <uni-row>
  122. <uni-col :span="24">
  123. <button type="primary" @click="handleApprovalSignature('departmental_opinion')">手动签名</button>
  124. </uni-col>
  125. <uni-col :span="24">
  126. <button style="margin-top: 5px;" type="primary" @click="handleAutoSeal('departmental_opinion')">一键签名</button>
  127. </uni-col>
  128. </uni-row>
  129. </view>
  130. <view v-else-if="departmentalOpinionElem && departmentalOpinionElem.defaultValue" class="signature_img">
  131. <img style="width: 100%;" mode="widthFix" @click="handleApprovalSignature('departmental_opinion')"
  132. :src="config.baseUrlPre + departmentalOpinionElem.sealImgPath"
  133. :alt="departmentalOpinionElem.elementName + '签名'" />
  134. </view>
  135. </view>
  136. <view v-else-if="departmentalOpinionElem && typeof departmentalOpinionElem.sealImgPath === 'string' && departmentalOpinionElem.sealImgPath.startsWith('/shares')" class="signature_img">
  137. <img style="width: 100%;" mode="widthFix"
  138. :src="config.baseUrlPre + departmentalOpinionElem.sealImgPath" />
  139. </view>
  140. </view>
  141. </uni-forms-item>
  142. <!-- 财务意见 -->
  143. <uni-forms-item label="财务意见" name="financeOpinion">
  144. <view class="element_value_container">
  145. <view v-if="isApprovalFieldEditable(financeOpinionElem)" class="element_value">
  146. <!-- 审批签字板 -->
  147. <view v-if="financeOpinionElem && (!financeOpinionElem.defaultValue || financeOpinionElem.defaultValue == '')">
  148. <uni-row>
  149. <uni-col :span="24">
  150. <button type="primary" @click="handleApprovalSignature('finance_opinion')">手动签名</button>
  151. </uni-col>
  152. <uni-col :span="24">
  153. <button style="margin-top: 5px;" type="primary" @click="handleAutoSeal('finance_opinion')">一键签名</button>
  154. </uni-col>
  155. </uni-row>
  156. </view>
  157. <view v-else-if="financeOpinionElem && financeOpinionElem.defaultValue" class="signature_img">
  158. <img style="width: 100%;" mode="widthFix" @click="handleApprovalSignature('finance_opinion')"
  159. :src="config.baseUrlPre + financeOpinionElem.sealImgPath"
  160. :alt="financeOpinionElem.elementName + '签名'" />
  161. </view>
  162. </view>
  163. <view v-else-if="financeOpinionElem && typeof financeOpinionElem.sealImgPath === 'string' && financeOpinionElem.sealImgPath.startsWith('/shares')" class="signature_img">
  164. <img style="width: 100%;" mode="widthFix"
  165. :src="config.baseUrlPre + financeOpinionElem.sealImgPath" />
  166. </view>
  167. </view>
  168. </uni-forms-item>
  169. <!-- 分管副总意见 -->
  170. <uni-forms-item label="分管副总" name="dgmOpinion">
  171. <view class="element_value_container">
  172. <view v-if="isApprovalFieldEditable(deputyGeneralManagerOpinionElem)" class="element_value">
  173. <!-- 审批签字板 -->
  174. <view v-if="deputyGeneralManagerOpinionElem && (!deputyGeneralManagerOpinionElem.defaultValue || deputyGeneralManagerOpinionElem.defaultValue == '')">
  175. <uni-row>
  176. <uni-col :span="24">
  177. <button type="primary" @click="handleApprovalSignature('deputy_general_manager_opinion')">手动签名</button>
  178. </uni-col>
  179. <uni-col :span="24">
  180. <button style="margin-top: 5px;" type="primary" @click="handleAutoSeal('deputy_general_manager_opinion')">一键签名</button>
  181. </uni-col>
  182. </uni-row>
  183. </view>
  184. <view v-else-if="deputyGeneralManagerOpinionElem && deputyGeneralManagerOpinionElem.defaultValue" class="signature_img">
  185. <img style="width: 100%;" mode="widthFix" @click="handleApprovalSignature('deputy_general_manager_opinion')"
  186. :src="config.baseUrlPre + deputyGeneralManagerOpinionElem.sealImgPath"
  187. :alt="deputyGeneralManagerOpinionElem.elementName + '签名'" />
  188. </view>
  189. </view>
  190. <view v-else-if="deputyGeneralManagerOpinionElem && typeof deputyGeneralManagerOpinionElem.sealImgPath === 'string' && deputyGeneralManagerOpinionElem.sealImgPath.startsWith('/shares')" class="signature_img">
  191. <img style="width: 100%;" mode="widthFix"
  192. :src="config.baseUrlPre + deputyGeneralManagerOpinionElem.sealImgPath" />
  193. </view>
  194. </view>
  195. </uni-forms-item>
  196. <!-- 审核副总意见 -->
  197. <uni-forms-item label="分管副总" name="auditDgmOpinion">
  198. <view class="element_value_container">
  199. <view v-if="isApprovalFieldEditable(auditDeputyGeneralManagerOpinionElem)" class="element_value">
  200. <!-- 审批签字板 -->
  201. <view v-if="auditDeputyGeneralManagerOpinionElem && (!auditDeputyGeneralManagerOpinionElem.defaultValue || auditDeputyGeneralManagerOpinionElem.defaultValue == '')">
  202. <uni-row>
  203. <uni-col :span="24">
  204. <button type="primary" @click="handleApprovalSignature('audit_deputy_general_manager_opinion')">手动签名</button>
  205. </uni-col>
  206. <uni-col :span="24">
  207. <button style="margin-top: 5px;" type="primary" @click="handleAutoSeal('audit_deputy_general_manager_opinion')">一键签名</button>
  208. </uni-col>
  209. </uni-row>
  210. </view>
  211. <view v-else-if="auditDeputyGeneralManagerOpinionElem && auditDeputyGeneralManagerOpinionElem.defaultValue" class="signature_img">
  212. <img style="width: 100%;" mode="widthFix" @click="handleApprovalSignature('audit_deputy_general_manager_opinion')"
  213. :src="config.baseUrlPre + auditDeputyGeneralManagerOpinionElem.sealImgPath"
  214. :alt="auditDeputyGeneralManagerOpinionElem.elementName + '签名'" />
  215. </view>
  216. </view>
  217. <view v-else-if="auditDeputyGeneralManagerOpinionElem && typeof auditDeputyGeneralManagerOpinionElem.sealImgPath === 'string' && auditDeputyGeneralManagerOpinionElem.sealImgPath.startsWith('/shares')" class="signature_img">
  218. <img style="width: 100%;" mode="widthFix"
  219. :src="config.baseUrlPre + auditDeputyGeneralManagerOpinionElem.sealImgPath" />
  220. </view>
  221. </view>
  222. </uni-forms-item>
  223. <!-- 总经理意见 -->
  224. <uni-forms-item label="总经理" name="gmOpinion">
  225. <view class="element_value_container">
  226. <view v-if="isApprovalFieldEditable(generalManagerOpinionElem)" class="element_value">
  227. <!-- 审批签字板 -->
  228. <view v-if="generalManagerOpinionElem && (!generalManagerOpinionElem.defaultValue || generalManagerOpinionElem.defaultValue == '')">
  229. <uni-row>
  230. <uni-col :span="24">
  231. <button type="primary" @click="handleApprovalSignature('general_manager_opinion')">手动签名</button>
  232. </uni-col>
  233. <uni-col :span="24">
  234. <button style="margin-top: 5px;" type="primary" @click="handleAutoSeal('general_manager_opinion')">一键签名</button>
  235. </uni-col>
  236. </uni-row>
  237. </view>
  238. <view v-else-if="generalManagerOpinionElem && generalManagerOpinionElem.defaultValue" class="signature_img">
  239. <img style="width: 100%;" mode="widthFix" @click="handleApprovalSignature('general_manager_opinion')"
  240. :src="config.baseUrlPre + generalManagerOpinionElem.sealImgPath"
  241. :alt="generalManagerOpinionElem.elementName + '签名'" />
  242. </view>
  243. </view>
  244. <view v-else-if="generalManagerOpinionElem && typeof generalManagerOpinionElem.sealImgPath === 'string' && generalManagerOpinionElem.sealImgPath.startsWith('/shares')" class="signature_img">
  245. <img style="width: 100%;" mode="widthFix"
  246. :src="config.baseUrlPre + generalManagerOpinionElem.sealImgPath" />
  247. </view>
  248. </view>
  249. </uni-forms-item>
  250. <!-- 董事长意见 -->
  251. <uni-forms-item label="董事长意见" name="chairmanOpinion">
  252. <view class="element_value_container">
  253. <view v-if="isApprovalFieldEditable(chairmanOpinionElem)" class="element_value">
  254. <!-- 审批签字板 -->
  255. <view v-if="chairmanOpinionElem && (!chairmanOpinionElem.defaultValue || chairmanOpinionElem.defaultValue == '')">
  256. <uni-row>
  257. <uni-col :span="24">
  258. <button type="primary" @click="handleApprovalSignature('chairman_opinion')">手动签名</button>
  259. </uni-col>
  260. <uni-col :span="24">
  261. <button style="margin-top: 5px;" type="primary" @click="handleAutoSeal('chairman_opinion')">一键签名</button>
  262. </uni-col>
  263. </uni-row>
  264. </view>
  265. <view v-else-if="chairmanOpinionElem && chairmanOpinionElem.defaultValue" class="signature_img">
  266. <img style="width: 100%;" mode="widthFix" @click="handleApprovalSignature('chairman_opinion')"
  267. :src="config.baseUrlPre + chairmanOpinionElem.sealImgPath"
  268. :alt="chairmanOpinionElem.elementName + '签名'" />
  269. </view>
  270. </view>
  271. <view v-else-if="chairmanOpinionElem && typeof chairmanOpinionElem.sealImgPath === 'string' && chairmanOpinionElem.sealImgPath.startsWith('/shares')" class="signature_img">
  272. <img style="width: 100%;" mode="widthFix"
  273. :src="config.baseUrlPre + chairmanOpinionElem.sealImgPath" />
  274. </view>
  275. </view>
  276. </uni-forms-item>
  277. </uni-forms>
  278. </uni-card>
  279. <!-- 物料明细 -->
  280. <uni-card>
  281. <uni-section titleFontSize="1.3rem" title="物料明细" type="line"></uni-section>
  282. <!-- 添加物料按钮:发起环节或字段可编辑时显示 -->
  283. <view v-if="isSeModel" class="material-actions">
  284. <button type="primary" size="mini" @click="openMaterialSelector" plain>添加物料</button>
  285. </view>
  286. <!-- 物料列表 - 卡片式展示 -->
  287. <view v-if="materialList.length > 0" class="material-list">
  288. <view v-for="(item, index) in materialList" :key="'material-' + item.itemCode + '-' + index" class="material-card">
  289. <view class="material-header" @click="toggleMaterialExpand(index)">
  290. <view class="material-main-info">
  291. <text class="material-name">{{ item.itemName }}</text>
  292. <text class="material-code">{{ item.itemCode }}</text>
  293. </view>
  294. <view class="material-expand">
  295. <uni-icons :type="item.expanded ? 'up' : 'down'" size="16" color="#999"></uni-icons>
  296. </view>
  297. </view>
  298. <!-- 展开的详细信息 -->
  299. <view v-show="item.expanded" class="material-detail">
  300. <view class="detail-row">
  301. <text class="detail-label">采购申请单号:</text>
  302. <text class="detail-value purchase-number">{{ item.purchaseNumber || '-' }}</text>
  303. </view>
  304. <view class="detail-row">
  305. <text class="detail-label">规格型号:</text>
  306. <text class="detail-value">{{ item.specification }}</text>
  307. </view>
  308. <view class="detail-row">
  309. <text class="detail-label">单位:</text>
  310. <text class="detail-value">{{ item.measureName }}</text>
  311. </view>
  312. <view class="detail-row">
  313. <text class="detail-label">数量:</text>
  314. <uni-easyinput
  315. v-model="item.qty"
  316. type="digit"
  317. v-if="isSeModel"
  318. placeholder="请输入数量"
  319. style="width: 100px; display: inline-block; margin-right: 15px;"
  320. @blur="onQuantityBlur(item)"
  321. />
  322. <text v-if="!isSeModel" class="detail-value">{{ item.qty }}</text>
  323. </view>
  324. <view class="detail-row">
  325. <text class="detail-label">税前单价:</text>
  326. <uni-easyinput
  327. v-model="item.price"
  328. type="digit"
  329. v-if="isSeModel"
  330. placeholder="请输入税前单价"
  331. style="width: 100px; display: inline-block; margin-right: 15px;"
  332. @blur="onPriceBlur(item)"
  333. />
  334. <text v-if="!isSeModel" class="detail-value">{{ item.price }}</text>
  335. </view>
  336. <view class="detail-row">
  337. <text class="detail-label">税率:</text>
  338. <uni-easyinput
  339. v-model="item.cess"
  340. type="digit"
  341. v-if="isSeModel"
  342. placeholder="请输入税率"
  343. style="width: 80px; display: inline-block; margin-right: 15px;"
  344. @blur="onCessBlur(item)"
  345. />
  346. <text v-if="!isSeModel" class="detail-value">{{ item.cess }}%</text>
  347. </view>
  348. <view class="detail-row">
  349. <text class="detail-label">税后单价:</text>
  350. <text class="detail-value price-value">{{ item.priceTax }}</text>
  351. </view>
  352. <view v-if="isSeModel" class="detail-row delete-row">
  353. <button type="warn" size="mini" @click="removeMaterial(index)">删除</button>
  354. </view>
  355. </view>
  356. </view>
  357. </view>
  358. <view v-else-if="materialList.length === 0" class="empty-materials">
  359. <text>暂无物料</text>
  360. </view>
  361. </uni-card>
  362. <!-- 付款明细 -->
  363. <uni-card>
  364. <uni-section titleFontSize="1.3rem" title="付款明细" type="line"></uni-section>
  365. <!-- 添加付款按钮:发起环节或字段可编辑时显示 -->
  366. <view v-if="isSeModel" class="payment-actions">
  367. <button type="primary" size="mini" @click="addPayment" :disabled="materialList.length === 0" plain>添加付款</button>
  368. </view>
  369. <!-- 付款列表 - 卡片式展示 -->
  370. <view v-if="paymentList.length > 0" class="payment-list">
  371. <view v-for="(item, index) in paymentList" :key="'payment-' + item.payType + '-' + index" class="payment-card">
  372. <view class="payment-header" @click="togglePaymentExpand(index)">
  373. <view class="payment-main-info">
  374. <text class="payment-name">{{ item.payTypeName || item.payType }}</text>
  375. </view>
  376. <view class="payment-expand">
  377. <uni-icons :type="item.expanded ? 'up' : 'down'" size="16" color="#999"></uni-icons>
  378. </view>
  379. </view>
  380. <!-- 展开的详细信息 -->
  381. <view v-show="item.expanded" class="payment-detail">
  382. <view class="detail-row">
  383. <text class="detail-label">付款方式:</text>
  384. <picker
  385. v-if="isSeModel"
  386. @change="(e) => onPaymentTypeChange(index, e)"
  387. :range="paymentTypeList"
  388. range-key="payTypeName">
  389. <view class="picker">
  390. {{ item.payTypeName || '请选择付款方式' }}
  391. </view>
  392. </picker>
  393. <text v-if="!isSeModel" class="detail-value">{{ item.payTypeName || item.payType }}</text>
  394. </view>
  395. <view class="detail-row">
  396. <text class="detail-label">付款比例:</text>
  397. <uni-easyinput
  398. v-model="item.proportion"
  399. type="digit"
  400. v-if="isSeModel"
  401. placeholder="请输入比例"
  402. style="width: 80px; display: inline-block; margin-right: 10px;"
  403. @blur="onProportionBlur(item)"
  404. />
  405. <text v-if="!isSeModel" class="detail-value">{{ item.proportion }}</text>
  406. <text>%</text>
  407. </view>
  408. <view class="detail-row">
  409. <text class="detail-label">付款金额:</text>
  410. <text class="detail-value price-value">{{ item.amount }}</text>
  411. </view>
  412. <view class="detail-row">
  413. <text class="detail-label">已付金额:</text>
  414. <uni-easyinput
  415. v-model="item.amountPaid"
  416. type="digit"
  417. v-if="isSeModel"
  418. placeholder="请输入已付金额"
  419. style="width: 100px; display: inline-block; margin-right: 10px;"
  420. @blur="onAmountPaidBlur(item)"
  421. />
  422. <text v-if="!isSeModel" class="detail-value">{{ item.amountPaid || 0 }}</text>
  423. </view>
  424. <view class="detail-row">
  425. <text class="detail-label">付款时间:</text>
  426. <uni-datetime-picker
  427. v-if="isSeModel"
  428. v-model="item.payTime"
  429. type="date"
  430. placeholder="选择付款时间"
  431. style="display: inline-block;"
  432. @click.native.stop
  433. @change="(e) => onPayTimeChange(item, e)"
  434. />
  435. <text v-if="!isSeModel" class="detail-value">{{ item.payTime || '-' }}</text>
  436. </view>
  437. <view class="detail-row">
  438. <text class="detail-label">付款状态:</text>
  439. <text class="detail-value status-tag" :class="'status-' + (item.payStatus || '0')">{{ getPayStatusName(item) }}</text>
  440. </view>
  441. <view class="detail-row">
  442. <text class="detail-label">备注:</text>
  443. <uni-easyinput
  444. v-model="item.remark"
  445. v-if="isSeModel"
  446. placeholder="请输入备注"
  447. style="flex: 1; display: inline-block;"
  448. />
  449. <text v-if="!isSeModel" class="detail-value">{{ item.remark || '-' }}</text>
  450. <button v-if="isSeModel" type="warn" size="mini" @click="removePayment(index)" style="margin-left: 10px;">删除</button>
  451. </view>
  452. </view>
  453. </view>
  454. </view>
  455. <view v-else-if="paymentList.length === 0" class="empty-payments">
  456. <text>暂无付款明细</text>
  457. </view>
  458. </uni-card>
  459. <!-- 签名板弹出层 -->
  460. <uni-popup ref="signaturePopup" @maskClick="closeSignature">
  461. <view class="signature_container" :class="{ 'signature_container_landscape': isLandscape }">
  462. <view class="signature_content">
  463. <l-signature ref="signatureRef" v-if="signaturePopupShow" :landscape="isLandscape" :penSize="8"
  464. :minLineWidth="4" :maxLineWidth="12" :openSmooth="true" :preferToDataURL="true"
  465. backgroundColor="#ffffff" penColor="black"></l-signature>
  466. </view>
  467. <view class="signature_button_container">
  468. <uni-row :gutter="10">
  469. <uni-col :span="6">
  470. <button type="warn" @click="onclickSignatureButton('undo')">撤销</button>
  471. </uni-col>
  472. <uni-col :span="6">
  473. <button type="warn" @click="onclickSignatureButton('clear')">清空</button>
  474. </uni-col>
  475. <uni-col :span="6">
  476. <button type="primary" @click="onclickSignatureButton('save')">保存</button>
  477. </uni-col>
  478. <uni-col :span="6">
  479. <button @click="onclickSignatureButton('landscape')">全屏</button>
  480. </uni-col>
  481. </uni-row>
  482. </view>
  483. </view>
  484. </uni-popup>
  485. <!-- 选择器弹出层(物料、供应商) -->
  486. <uni-popup ref="selectorPopup" type="center">
  487. <view class="selector-popup">
  488. <view class="popup-header">
  489. <text class="popup-title">{{ popupTitle }}</text>
  490. <uni-icons type="closeempty" size="20" @click="closePopup"></uni-icons>
  491. </view>
  492. <!-- 物料来源选择(仅物料选择时显示) -->
  493. <view v-if="selectorType === 'material'" class="material-source-selector">
  494. <view class="source-options">
  495. <view
  496. :class="['source-option', materialSource === 'mes' ? 'active' : '']"
  497. @click="materialSource = 'mes'; onMaterialSourceChange()">
  498. MES 系统
  499. </view>
  500. <view
  501. :class="['source-option', materialSource === 'purchase' ? 'active' : '']"
  502. @click="materialSource = 'purchase'; onMaterialSourceChange()">
  503. 采购申请
  504. </view>
  505. </view>
  506. </view>
  507. <!-- 搜索框 -->
  508. <view v-if="(selectorType === 'material' && materialSource === 'mes') || selectorType === 'supplier' || selectorType === 'client'" class="search-bar">
  509. <uni-easyinput
  510. v-model="searchKeyword"
  511. :placeholder="selectorType === 'material' ? '输入物料名称搜索' : (selectorType === 'supplier' ? '输入供应商名称搜索' : '输入客户名称搜索')"
  512. clearable
  513. @confirm="handleSearch"
  514. />
  515. <button type="primary" size="mini" @click="handleSearch">搜索</button>
  516. </view>
  517. <!-- 采购申请单选择器(采购申请模式) -->
  518. <view v-if="selectorType === 'material' && materialSource === 'purchase'" class="purchase-selector">
  519. <picker @change="onPurchaseChange" :range="purchaseApplyList" range-key="contractPurchaseFormNumber">
  520. <view class="picker">
  521. {{ selectedPurchaseApply ? selectedPurchaseApply.contractPurchaseFormNumber : '全部采购申请单' }}
  522. </view>
  523. </picker>
  524. <button type="primary" size="mini" @click="loadPurchaseMaterials(true)">查询</button>
  525. <button type="warn" size="mini" @click="clearPurchaseSelection" v-if="selectedPurchaseApply">清空</button>
  526. </view>
  527. <scroll-view
  528. scroll-y
  529. class="popup-content"
  530. refresher-enabled
  531. :refresher-triggered="isRefreshing"
  532. @refresherrefresh="onRefresh"
  533. @scrolltolower="loadMore"
  534. >
  535. <view v-for="(item, index) in selectorList" :key="index"
  536. class="selector-item"
  537. @click="selectItem(item)">
  538. <view class="selector-item-content">
  539. <view class="item-info">
  540. <text class="item-name">{{ getSelectorItemName(item) }}</text>
  541. <!-- 采购申请模式显示采购单号 -->
  542. <text v-if="materialSource === 'purchase' && item.purchaseNumber" class="item-purchase">
  543. 采购单:{{ item.purchaseNumber }}
  544. </text>
  545. <text v-if="getItemCode(item)" class="item-code">{{ getItemCode(item) }}</text>
  546. <text v-if="getItemSpec(item)" class="item-spec">{{ getItemSpec(item) }}</text>
  547. <!-- 显示单位和数量 -->
  548. <text v-if="item.measureName || item.qty" class="item-extra">
  549. <text v-if="item.measureName">{{ item.measureName }}</text>
  550. <text v-if="item.qty"> 可用:{{ item.qty }}</text>
  551. </text>
  552. </view>
  553. <text v-if="isSelected(item)" class="selected-tag">已选择</text>
  554. </view>
  555. </view>
  556. <!-- 加载状态 -->
  557. <view v-if="isLoading && selectorList.length > 0" class="loading-text">
  558. <uni-load-more status="loading" />
  559. </view>
  560. <!-- 没有更多数据 -->
  561. <view v-else-if="!hasMore && selectorList.length > 0" class="no-more-text">
  562. <text>没有更多了</text>
  563. </view>
  564. <!-- 空数据提示 -->
  565. <view v-if="selectorList.length === 0 && !isLoading" class="empty-data">
  566. <text>{{ searchKeyword ? '暂无相关数据' : '暂无数据' }}</text>
  567. </view>
  568. </scroll-view>
  569. </view>
  570. </uni-popup>
  571. </view>
  572. </template>
  573. <script setup lang="ts">
  574. import { ref, watch, computed, nextTick, onMounted } from 'vue'
  575. import { useUserStore } from '@/store/user.js'
  576. import config from '@/config.js'
  577. import { uploadSignatureBoardImg, getSeal } from '@/api/process.js'
  578. import { getContractTypeList, getPaymentTypeList, getMaterialList, getSupplierList, getClientList, getPurchaseApplyList, getPurchaseDetailList, checkContractNumber } from '@/api/contract.js'
  579. import $modal from '@/plugins/modal.js'
  580. const userStore = useUserStore()
  581. // 组件挂载时加载合同类型和付款方式列表
  582. onMounted(() => {
  583. loadContractTypeList()
  584. loadPaymentTypeList()
  585. })
  586. // 加载合同类型列表
  587. function loadContractTypeList() {
  588. getContractTypeList(userStore.user.useId).then(({ returnParams }) => {
  589. if (returnParams && Array.isArray(returnParams.typeList)) {
  590. contractTypeList.value = returnParams.typeList
  591. }
  592. }).catch(err => {
  593. console.error('加载合同类型列表失败:', err)
  594. })
  595. }
  596. // 加载付款方式列表
  597. const paymentTypeList = ref<any[]>([])
  598. function loadPaymentTypeList() {
  599. getPaymentTypeList(userStore.user.useId).then(({ returnParams }) => {
  600. if (returnParams && Array.isArray(returnParams.paymentList)) {
  601. paymentTypeList.value = returnParams.paymentList
  602. }
  603. }).catch(err => {
  604. console.error('加载付款方式列表失败:', err)
  605. })
  606. }
  607. const props = defineProps({
  608. formData: {
  609. type: Object,
  610. default: () => ({})
  611. },
  612. formElements: {
  613. type: Array,
  614. default: () => []
  615. },
  616. repeatingForm: {
  617. type: Object,
  618. default: () => ({ elementItem: [], elements: [] })
  619. },
  620. // 是否为发起环节(seModel == '1')
  621. isInitiate: {
  622. type: Boolean,
  623. default: false
  624. },
  625. // 当前环节可编辑的字段列表
  626. editableFields: {
  627. type: Array,
  628. default: () => []
  629. },
  630. // 当前环节的审批意见配置
  631. currentTacheOpinion: {
  632. type: Object,
  633. default: null
  634. }
  635. })
  636. const emits = defineEmits(['update', 'signature-change'])
  637. // 表单数据
  638. const baseForm = ref<any>({
  639. contract_number: '',
  640. contract_name: '',
  641. contract_type: '',
  642. contract_type_name: '',
  643. applyDate: '',
  644. department: '',
  645. salesman: '',
  646. salesman_name: '',
  647. salesmanTel: '',
  648. supplierCode: '',
  649. supplierName: '',
  650. firstparty_name: '',
  651. contract_money: '',
  652. contractContent: '',
  653. projectItem: '',
  654. usePosition: '',
  655. other_contractor: '',
  656. otherFile: '',
  657. salesmanSign: '',
  658. // 录入人信息
  659. contract_entrying_operator: '',
  660. contract_entrying_operator_name: '',
  661. // 组织 ID
  662. unit_id: '',
  663. // 合同ID(用于审批流程中排除自己)
  664. universalid: ''
  665. })
  666. const baseFormRules = ref({
  667. contract_name: [
  668. {
  669. required: true,
  670. errorMessage: '请输入合同名称'
  671. }
  672. ]
  673. })
  674. const materialList = ref<any[]>([])
  675. const paymentList = ref<any[]>([])
  676. const signaturePopup = ref(null)
  677. const signatureRef = ref(null)
  678. const signatureImg = ref('')
  679. const currentApprovalText = ref('')
  680. const approvals = ref<any[]>([]) // 历史审批意见列表
  681. const signaturePopupShow = ref(false)
  682. const isLandscape = ref(false)
  683. // 合同类型列表
  684. const contractTypeList = ref<any[]>([])
  685. // 判断是否为销售合同
  686. const isSalesContract = computed(() => {
  687. return baseForm.value.contract_type === '1' || baseForm.value.contract_type === 1
  688. })
  689. // 选择器相关变量
  690. const selectorPopup = ref(null)
  691. const selectorList = ref<any[]>([])
  692. const selectorType = ref('') // 'material', 'supplier', 'client'
  693. const materialSource = ref('mes') // 'mes' - MES 系统,'purchase' - 采购申请
  694. const purchaseApplyList = ref<any[]>([]) // 采购申请单列表
  695. const selectedPurchaseApply = ref<any>(null) // 选中的采购申请单
  696. const currentPage = ref(1)
  697. const pageSize = 20
  698. const hasMore = ref(true)
  699. const isLoading = ref(false)
  700. const isRefreshing = ref(false)
  701. const searchKeyword = ref('')
  702. // 选择器弹出层标题
  703. const popupTitle = computed(() => {
  704. if (selectorType.value === 'material') return '选择物料'
  705. if (selectorType.value === 'supplier') return '选择供应商'
  706. if (selectorType.value === 'client') return '选择客户'
  707. return '选择'
  708. })
  709. // 获取指定的审批意见元素
  710. const getApprovalElement = (fieldName: string) => {
  711. if (!props.formElements || !Array.isArray(props.formElements)) {
  712. return null
  713. }
  714. // 从 formElements 中找到对应的字段
  715. const elem = props.formElements.find(e => e.tableField === fieldName || e.elementName.includes(fieldName.replace(/_/g, '')))
  716. return elem || null
  717. }
  718. // 获取各部门意见元素(计算属性,避免重复调用)
  719. const departmentalOpinionElem = computed(() => getApprovalElement('departmental_opinion'))
  720. const deputyGeneralManagerOpinionElem = computed(() => getApprovalElement('deputy_general_manager_opinion'))
  721. const auditDeputyGeneralManagerOpinionElem = computed(() => getApprovalElement('audit_deputy_general_manager_opinion'))
  722. const generalManagerOpinionElem = computed(() => getApprovalElement('general_manager_opinion'))
  723. const financeOpinionElem = computed(() => getApprovalElement('finance_opinion'))
  724. const chairmanOpinionElem = computed(() => getApprovalElement('chairman_opinion'))
  725. // 是否发起环节
  726. const isSeModel = computed(() => props.isInitiate)
  727. // 计算各部门意见是否可编辑
  728. const isApprovalFieldEditable = (elem: any) => {
  729. if (!elem) return false
  730. return props.editableFields && props.editableFields.includes(elem.tableField)
  731. }
  732. // 处理审批意见签名
  733. let lastFormInsId = ''
  734. // 计算字段是否可编辑 (只需要该字段在 table_fields 中即可)
  735. const getFieldEditable = (fieldName: string) => {
  736. // 如果没有配置 editableFields,则都不可编辑
  737. if (!props.editableFields || props.editableFields.length === 0) {
  738. return false
  739. }
  740. // 检查该字段是否在可编辑字段列表中 (table_fields 包含的字段才可以编辑)
  741. return props.editableFields.includes(fieldName)
  742. }
  743. // 计算是否为发起环节或字段可编辑 (满足任一条件即可)
  744. const isInitiateOrFieldEditable = (fieldName: string) => {
  745. return props.isInitiate || getFieldEditable(fieldName)
  746. }
  747. // 监听表单数据变化
  748. watch(() => props.formData, (newVal) => {
  749. if (!newVal || Object.keys(newVal).length === 0) {
  750. return
  751. }
  752. // 使用 formInsId 判断是否是新的数据(formInsId 肯定存在)
  753. const currentFormInsId = newVal.lFormInsId || newVal.universalid || ''
  754. // 只有当 formInsId 变化时,才认为是新的数据需要加载
  755. if (currentFormInsId && currentFormInsId !== lastFormInsId) {
  756. lastFormInsId = currentFormInsId
  757. // 填充基本信息 - 直接使用后端返回的字段
  758. baseForm.value = {
  759. contract_number: newVal.contract_number || '',
  760. contract_name: newVal.contract_name || '',
  761. contract_type: newVal.contract_type || '',
  762. contract_type_name: newVal.contract_type_name || '', // 直接使用后端返回的名称
  763. applyDate: newVal.applyDate || '',
  764. department: newVal.department || '',
  765. salesman: newVal.salesman || '',
  766. salesman_name: newVal.salesman_name || '',
  767. salesmanTel: newVal.salesmanTel || '',
  768. supplierCode: newVal.supplierCode || '',
  769. supplierName: newVal.supplierName || '',
  770. firstparty_name: newVal.firstparty_name || '',
  771. secondparty_name: newVal.secondparty_name || '',
  772. contract_money: newVal.contract_money || '',
  773. contractContent: newVal.contractContent || '',
  774. projectItem: newVal.projectItem || '',
  775. usePosition: newVal.usePosition || '',
  776. other_contractor: newVal.other_contractor || '',
  777. otherFile: newVal.otherFile || '',
  778. salesmanSign: newVal.salesmanSign || '',
  779. // 录入人信息
  780. contract_entrying_operator: newVal.contract_entrying_operator || '',
  781. contract_entrying_operator_name: newVal.contract_entrying_operator_name || '',
  782. // 组织 ID
  783. unit_id: newVal.unit_id || '',
  784. // 保存公司名称,用于销售合同时对调需方供方(从后端获取)
  785. companyName: newVal.companyName || '',
  786. // 合同ID(用于审批流程中排除自己)
  787. universalid: newVal.universalid || ''
  788. }
  789. // 从 contractMaterialList 中获取物料列表
  790. const rawMaterialList = newVal.details || newVal.contractMaterialList || []
  791. // 加载物料数据
  792. if (Array.isArray(rawMaterialList)) {
  793. materialList.value = rawMaterialList.map((item: any) => ({
  794. itemCode: item.itemCode || item.materialCode,
  795. itemName: item.itemName || item.materialName,
  796. specification: item.specification || item.materialModel,
  797. measureName: item.measureName || item.unit,
  798. qty: item.qty || 0,
  799. price: item.price || 0,
  800. cess: item.cess || 0,
  801. priceTax: item.priceTax || 0,
  802. purchaseId: item.purchaseId || '',
  803. purchaseNumber: item.purchaseNumber || '',
  804. unit_id: item.unit_id || newVal.unit_id || '', // 从明细或主表获取 unit_id
  805. expanded: true // 默认展开
  806. }))
  807. } else {
  808. materialList.value = []
  809. }
  810. // 从 contractPaymentList 中获取付款列表
  811. const rawPaymentList = newVal.contractPaymentList || []
  812. // 加载付款数据
  813. if (Array.isArray(rawPaymentList)) {
  814. paymentList.value = rawPaymentList.map((item: any) => ({
  815. payType: item.payType || '',
  816. payTypeName: item.payTypeName || '',
  817. proportion: item.proportion || 0,
  818. amount: item.amount || 0,
  819. amountPaid: item.amountPaid || 0,
  820. payTime: item.payTime || '',
  821. payStatus: item.payStatus || '0',
  822. payStatusName: item.payStatusName || getPayStatusName(item),
  823. remark: item.remark || '',
  824. unit_id: item.unit_id || newVal.unit_id || '', // 从明细或主表获取 unit_id
  825. expanded: true // 默认展开
  826. }))
  827. // 如果付款方式名称为空,尝试从列表中查找
  828. if (paymentTypeList.value.length > 0) {
  829. paymentList.value.forEach(payment => {
  830. if (!payment.payTypeName && payment.payType) {
  831. const payType = paymentTypeList.value.find(p => p.payType == payment.payType)
  832. if (payType) {
  833. payment.payTypeName = payType.payTypeName
  834. }
  835. }
  836. })
  837. }
  838. } else {
  839. paymentList.value = []
  840. }
  841. }
  842. }, { immediate: true, deep: true })
  843. // 切换物料展开/收起状态
  844. function toggleMaterialExpand(index: number) {
  845. if (materialList.value[index]) {
  846. materialList.value[index].expanded = !materialList.value[index].expanded
  847. }
  848. }
  849. // 切换付款展开/收起状态
  850. function togglePaymentExpand(index: number) {
  851. if (paymentList.value[index]) {
  852. paymentList.value[index].expanded = !paymentList.value[index].expanded
  853. }
  854. }
  855. // 打开物料选择器
  856. async function openMaterialSelector() {
  857. selectorType.value = 'material'
  858. materialSource.value = 'mes' // 默认 MES 系统模式
  859. currentPage.value = 1
  860. hasMore.value = true
  861. selectorList.value = []
  862. await loadMaterials(1, false)
  863. openPopup()
  864. }
  865. // 打开供应商选择器
  866. async function openSupplierSelector() {
  867. selectorType.value = 'supplier'
  868. currentPage.value = 1
  869. hasMore.value = true
  870. selectorList.value = []
  871. await loadSuppliers(1, false)
  872. openPopup()
  873. }
  874. // 打开客户选择器(销售合同时使用)
  875. async function openClientSelector() {
  876. selectorType.value = 'client'
  877. currentPage.value = 1
  878. hasMore.value = true
  879. selectorList.value = []
  880. await loadClients(1, false)
  881. openPopup()
  882. }
  883. // 加载客户列表(分页)
  884. async function loadClients(page: number, append: boolean = false) {
  885. if (isLoading.value) return
  886. isLoading.value = true
  887. if (page === 1) {
  888. isRefreshing.value = true
  889. }
  890. try {
  891. const res = await getClientList(
  892. userStore.user.useId,
  893. page,
  894. pageSize,
  895. searchKeyword.value
  896. )
  897. if (res.returnCode === '1') {
  898. const result = res.returnParams
  899. const newList = result.list || []
  900. if (append) {
  901. // 追加模式(加载更多)
  902. selectorList.value = [...selectorList.value, ...newList]
  903. } else {
  904. // 覆盖模式(刷新/搜索)
  905. selectorList.value = newList
  906. }
  907. // 判断是否还有更多数据
  908. hasMore.value = selectorList.value.length < result.total
  909. } else {
  910. $modal.msgError('加载客户失败')
  911. }
  912. } catch (error) {
  913. console.error('加载客户失败', error)
  914. $modal.msgError('加载失败')
  915. } finally {
  916. isLoading.value = false
  917. isRefreshing.value = false
  918. }
  919. }
  920. // 打开弹出层
  921. function openPopup() {
  922. if (selectorPopup.value) {
  923. ;(selectorPopup.value as any).open()
  924. }
  925. }
  926. // 关闭弹出层
  927. function closePopup() {
  928. if (selectorPopup.value) {
  929. ;(selectorPopup.value as any).close()
  930. }
  931. }
  932. // 加载物料列表(分页)
  933. async function loadMaterials(page: number, append: boolean = false) {
  934. if (isLoading.value) return
  935. isLoading.value = true
  936. if (page === 1) {
  937. isRefreshing.value = true
  938. }
  939. try {
  940. const res = await getMaterialList(
  941. userStore.user.useId,
  942. page,
  943. pageSize,
  944. searchKeyword.value
  945. )
  946. if (res.returnCode === '1') {
  947. const result = res.returnParams
  948. const newList = result.list || []
  949. if (append) {
  950. // 追加模式(加载更多)
  951. selectorList.value = [...selectorList.value, ...newList]
  952. } else {
  953. // 覆盖模式(刷新/搜索)
  954. selectorList.value = newList
  955. }
  956. // 判断是否还有更多数据
  957. hasMore.value = selectorList.value.length < result.total
  958. } else {
  959. $modal.msgError('加载物料失败')
  960. }
  961. } catch (error) {
  962. console.error('加载物料失败', error)
  963. $modal.msgError('加载失败')
  964. } finally {
  965. isLoading.value = false
  966. isRefreshing.value = false
  967. }
  968. }
  969. // 加载供应商列表(分页)
  970. async function loadSuppliers(page: number, append: boolean = false) {
  971. if (isLoading.value) return
  972. isLoading.value = true
  973. if (page === 1) {
  974. isRefreshing.value = true
  975. }
  976. try {
  977. const res = await getSupplierList(
  978. userStore.user.useId,
  979. page,
  980. pageSize,
  981. searchKeyword.value
  982. )
  983. if (res.returnCode === '1') {
  984. const result = res.returnParams
  985. const newList = result.list || []
  986. if (append) {
  987. selectorList.value = [...selectorList.value, ...newList]
  988. } else {
  989. selectorList.value = newList
  990. }
  991. hasMore.value = selectorList.value.length < result.total
  992. } else {
  993. $modal.msgError('加载供应商失败')
  994. }
  995. } catch (error) {
  996. console.error('加载供应商失败', error)
  997. $modal.msgError('加载失败')
  998. } finally {
  999. isLoading.value = false
  1000. isRefreshing.value = false
  1001. }
  1002. }
  1003. // 加载采购申请单列表
  1004. async function loadPurchaseApplyList() {
  1005. if (isLoading.value) return
  1006. isLoading.value = true
  1007. isRefreshing.value = true
  1008. try {
  1009. const res = await getPurchaseApplyList(userStore.user.useId)
  1010. if (res.returnCode === '1') {
  1011. const result = res.returnParams
  1012. purchaseApplyList.value = result.list || []
  1013. selectedPurchaseApply.value = null
  1014. selectorList.value = [] // 清空物料列表
  1015. } else {
  1016. $modal.msgError('加载采购申请单失败')
  1017. }
  1018. } catch (error) {
  1019. console.error('加载采购申请单失败', error)
  1020. $modal.msgError('加载失败')
  1021. } finally {
  1022. isLoading.value = false
  1023. isRefreshing.value = false
  1024. }
  1025. }
  1026. // 加载采购申请物料
  1027. async function loadPurchaseMaterials(resetPage: boolean = false) {
  1028. if (isLoading.value) return
  1029. // 如果是分页加载,不清空列表
  1030. if (resetPage) {
  1031. currentPage.value = 1
  1032. selectorList.value = []
  1033. }
  1034. isLoading.value = true
  1035. isRefreshing.value = resetPage
  1036. try {
  1037. // 如果不指定采购申请单,则查询所有物料
  1038. const purchaseFormId = selectedPurchaseApply.value
  1039. ? selectedPurchaseApply.value.contractPurchaseFormId.toString()
  1040. : ''
  1041. const res = await getPurchaseDetailList(
  1042. userStore.user.useId,
  1043. purchaseFormId,
  1044. currentPage.value,
  1045. 10 // 每页 10 条,与 PC 端一致
  1046. )
  1047. if (res.returnCode === '1') {
  1048. const result = res.returnParams
  1049. const newList = result.list || []
  1050. if (resetPage) {
  1051. selectorList.value = newList
  1052. } else {
  1053. // 追加数据
  1054. selectorList.value.push(...newList)
  1055. }
  1056. // 判断是否还有更多数据
  1057. hasMore.value = selectorList.value.length < result.total
  1058. if (!resetPage) {
  1059. currentPage.value++
  1060. }
  1061. } else {
  1062. $modal.msgError('加载物料失败')
  1063. }
  1064. } catch (error) {
  1065. console.error('加载物料失败', error)
  1066. $modal.msgError('加载失败')
  1067. } finally {
  1068. isLoading.value = false
  1069. isRefreshing.value = false
  1070. }
  1071. }
  1072. // 物料来源切换时
  1073. async function onMaterialSourceChange() {
  1074. currentPage.value = 1
  1075. hasMore.value = true
  1076. selectorList.value = []
  1077. searchKeyword.value = ''
  1078. if (materialSource.value === 'mes') {
  1079. await loadMaterials(1, false)
  1080. } else {
  1081. // 采购申请模式,先加载采购申请单列表,然后加载所有物料
  1082. await loadPurchaseApplyList()
  1083. // 加载完采购申请单后,立即查询物料(默认不指定具体采购单)
  1084. await loadPurchaseMaterials(true) // true 表示重置分页
  1085. }
  1086. }
  1087. // 采购申请单选择变化
  1088. function onPurchaseChange(e: any) {
  1089. const selectedIndex = e.detail.value
  1090. selectedPurchaseApply.value = purchaseApplyList.value[selectedIndex]
  1091. loadPurchaseMaterials(true)
  1092. }
  1093. // 清空采购申请单选择
  1094. function clearPurchaseSelection() {
  1095. selectedPurchaseApply.value = null
  1096. selectorList.value = []
  1097. loadPurchaseMaterials(true)
  1098. }
  1099. // 加载更多
  1100. function loadMore() {
  1101. if (!hasMore.value || isLoading.value) return
  1102. currentPage.value++
  1103. if (selectorType.value === 'material') {
  1104. if (materialSource.value === 'mes') {
  1105. loadMaterials(currentPage.value, true)
  1106. } else {
  1107. loadPurchaseMaterials(false)
  1108. }
  1109. } else if (selectorType.value === 'supplier') {
  1110. loadSuppliers(currentPage.value, true)
  1111. } else if (selectorType.value === 'client') {
  1112. loadClients(currentPage.value, true)
  1113. }
  1114. }
  1115. // 下拉刷新
  1116. function onRefresh() {
  1117. currentPage.value = 1
  1118. if (selectorType.value === 'material') {
  1119. if (materialSource.value === 'mes') {
  1120. loadMaterials(1, false)
  1121. } else {
  1122. loadPurchaseMaterials(true)
  1123. }
  1124. } else if (selectorType.value === 'supplier') {
  1125. loadSuppliers(1, false)
  1126. } else if (selectorType.value === 'client') {
  1127. loadClients(1, false)
  1128. }
  1129. }
  1130. // 搜索
  1131. function handleSearch() {
  1132. currentPage.value = 1
  1133. if (selectorType.value === 'material') {
  1134. loadMaterials(1, false)
  1135. } else if (selectorType.value === 'supplier') {
  1136. loadSuppliers(1, false)
  1137. } else if (selectorType.value === 'client') {
  1138. loadClients(1, false)
  1139. }
  1140. }
  1141. // 获取物料/供应商/客户名称
  1142. function getSelectorItemName(item: any): string {
  1143. if (selectorType.value === 'material') {
  1144. return item.itemName || ''
  1145. } else if (selectorType.value === 'supplier') {
  1146. return item.vendorName || ''
  1147. } else if (selectorType.value === 'client') {
  1148. return item.clientName || ''
  1149. }
  1150. return ''
  1151. }
  1152. // 获取编码
  1153. function getItemCode(item: any): string {
  1154. if (selectorType.value === 'material') {
  1155. return item.itemCode || ''
  1156. } else if (selectorType.value === 'supplier') {
  1157. return item.vendorCode || ''
  1158. } else if (selectorType.value === 'client') {
  1159. return item.clientCode || ''
  1160. }
  1161. return ''
  1162. }
  1163. // 获取规格型号(仅物料有)
  1164. function getItemSpec(item: any): string {
  1165. if (selectorType.value === 'material') {
  1166. return item.specification || ''
  1167. }
  1168. return ''
  1169. }
  1170. // 判断是否已选中
  1171. // 注意:只有当物料编码和采购申请单编号都相同时,才认为是重复选择
  1172. function isSelected(item: any): boolean {
  1173. if (selectorType.value === 'material') {
  1174. const itemCode = item.itemCode || ''
  1175. const purchaseNumber = item.purchaseNumber || ''
  1176. // 检查物料列表中是否存在相同的物料(物料编码 + 采购申请单编号都相同)
  1177. return materialList.value.some(m => {
  1178. const existItemCode = m.itemCode || ''
  1179. const existPurchaseNumber = m.purchaseNumber || ''
  1180. // 只有当物料编码和采购申请单编号都相同时,才认为是重复
  1181. return existItemCode === itemCode &&
  1182. ((existPurchaseNumber === purchaseNumber) ||
  1183. (!existPurchaseNumber && !purchaseNumber))
  1184. })
  1185. } else if (selectorType.value === 'supplier') {
  1186. const code = item.vendorCode || item.supplierCode
  1187. return baseForm.value.supplierCode === code
  1188. } else if (selectorType.value === 'client') {
  1189. const code = item.clientCode
  1190. return baseForm.value.supplierCode === code
  1191. }
  1192. return false
  1193. }
  1194. // 选择物料/供应商/客户
  1195. function selectItem(item: any) {
  1196. if (selectorType.value === 'material') {
  1197. // 检查是否已存在(根据物料编码 + 采购申请单编号判断)
  1198. const exists = isSelected(item)
  1199. if (exists) {
  1200. $modal.msg('该物料已添加')
  1201. return
  1202. }
  1203. // 确保数值字段正确转换(防止后端返回对象或字符串)
  1204. const qty = parseFloat(item.qty) || 0
  1205. const price = parseFloat(item.price) || 0
  1206. const cess = parseFloat(item.cess) || 0
  1207. const priceTax = parseFloat(item.priceTax) || 0
  1208. // 添加物料到列表
  1209. materialList.value.push({
  1210. itemCode: item.itemCode,
  1211. itemName: item.itemName,
  1212. specification: item.specification,
  1213. measureName: item.measureName,
  1214. qty: qty,
  1215. price: price,
  1216. cess: cess,
  1217. priceTax: priceTax,
  1218. purchaseId: item.purchaseId || selectedPurchaseApply.value?.contractPurchaseFormId || '',
  1219. purchaseNumber: item.purchaseNumber || selectedPurchaseApply.value?.contractPurchaseFormNumber || '',
  1220. expanded: true
  1221. })
  1222. // 重新计算总价
  1223. calculateTotalPrice()
  1224. } else if (selectorType.value === 'supplier') {
  1225. // 选择供应商:供方=供应商名称,supplierCode/supplierName 保存供应商信息
  1226. baseForm.value.secondparty_name = item.vendorName
  1227. baseForm.value.supplierCode = item.vendorCode
  1228. baseForm.value.supplierName = item.vendorName
  1229. } else if (selectorType.value === 'client') {
  1230. // 选择客户:需方=客户名称,supplierCode/supplierName 保存客户信息
  1231. baseForm.value.firstparty_name = item.clientName
  1232. baseForm.value.supplierCode = item.clientCode
  1233. baseForm.value.supplierName = item.clientName
  1234. }
  1235. closePopup()
  1236. }
  1237. // 合同类型变化
  1238. function onContractTypeChange(e: any) {
  1239. const index = e.detail.value
  1240. if (contractTypeList.value[index]) {
  1241. baseForm.value.contract_type = contractTypeList.value[index].contract_type
  1242. baseForm.value.contract_type_name = contractTypeList.value[index].contract_type_name
  1243. // 根据合同类型调整需方和供方的显示
  1244. adjustPartyDisplay()
  1245. }
  1246. }
  1247. // 根据合同类型调整需方和供方的显示
  1248. function adjustPartyDisplay() {
  1249. // 从 baseForm 中获取保存的公司名称
  1250. const companyName = (baseForm.value as any).companyName || ''
  1251. if (isSalesContract.value) {
  1252. // 销售合同:需方=选择客户,供方=公司名称(只读)
  1253. baseForm.value.secondparty_name = companyName
  1254. baseForm.value.supplierCode = ''
  1255. baseForm.value.supplierName = ''
  1256. baseForm.value.firstparty_name = ''
  1257. } else {
  1258. // 其他合同类型:需方=公司名称(只读),供方=选择供应商
  1259. baseForm.value.firstparty_name = companyName
  1260. baseForm.value.secondparty_name = ''
  1261. baseForm.value.supplierCode = ''
  1262. baseForm.value.supplierName = ''
  1263. }
  1264. }
  1265. // 删除物料
  1266. function removeMaterial(index: number) {
  1267. $modal.confirm('', '确定删除该物料?')
  1268. .then(() => {
  1269. materialList.value.splice(index, 1)
  1270. // 重新计算总价
  1271. calculateTotalPrice()
  1272. }).catch(() => {})
  1273. }
  1274. // 物料价格计算 (与 start.vue 保持一致)
  1275. function calculateMaterialPrice(item: any) {
  1276. const price = parseFloat(item.price) || 0
  1277. const cess = parseFloat(item.cess) || 0
  1278. // 计算税后单价:税前单价 * (1 + 税率 / 100)
  1279. item.priceTax = (price * (1 + cess / 100)).toFixed(2)
  1280. // 重新计算总价
  1281. calculateTotalPrice()
  1282. }
  1283. // 计算合同总价
  1284. function calculateTotalPrice() {
  1285. let total = 0
  1286. materialList.value.forEach(item => {
  1287. const qty = parseFloat(item.qty) || 0
  1288. const priceTax = parseFloat(item.priceTax) || 0
  1289. total += qty * priceTax
  1290. })
  1291. // 如果合同金额为空或小于总价,自动更新
  1292. const currentMoney = parseFloat(baseForm.value.contract_money) || 0
  1293. if (!currentMoney || currentMoney < total) {
  1294. baseForm.value.contract_money = total.toFixed(2)
  1295. }
  1296. // 更新付款信息中的金额
  1297. calculatePaymentAmount()
  1298. }
  1299. // 计算物料总价值(仅返回数值,不更新合同金额)
  1300. function calculateTotalPriceValue(): number {
  1301. let total = 0
  1302. materialList.value.forEach(item => {
  1303. const qty = parseFloat(item.qty) || 0
  1304. const priceTax = parseFloat(item.priceTax) || 0
  1305. total += qty * priceTax
  1306. })
  1307. return total
  1308. }
  1309. // 数量变化时
  1310. function onQuantityBlur(item: any) {
  1311. calculateTotalPrice()
  1312. }
  1313. // 合同金额失焦验证 (已移除,改为提交前统一验证)
  1314. // function onContractMoneyBlur() {}
  1315. // 税前单价变化时
  1316. function onPriceBlur(item: any) {
  1317. calculateMaterialPrice(item)
  1318. }
  1319. // 税率变化时
  1320. function onCessBlur(item: any) {
  1321. calculateMaterialPrice(item)
  1322. }
  1323. // 添加付款
  1324. function addPayment() {
  1325. paymentList.value.push({
  1326. payType: '',
  1327. payTypeName: '',
  1328. proportion: '0',
  1329. amount: '0',
  1330. amountPaid: '0',
  1331. payTime: '',
  1332. payStatus: '0',
  1333. payStatusName: '未支付',
  1334. remark: '',
  1335. expanded: true
  1336. })
  1337. }
  1338. // 比例变化时重新计算金额
  1339. function onProportionBlur(item: any) {
  1340. calculatePaymentAmount()
  1341. }
  1342. // 付款方式类型变化
  1343. function onPaymentTypeChange(index: number, e: any) {
  1344. const selectedIndex = e.detail.value
  1345. const selected = paymentTypeList.value[selectedIndex]
  1346. if (selected) {
  1347. paymentList.value[index].payType = selected.payType
  1348. paymentList.value[index].payTypeName = selected.payTypeName
  1349. }
  1350. }
  1351. // 已付金额变化时更新付款状态
  1352. function onAmountPaidBlur(item: any) {
  1353. updatePaymentStatus(item)
  1354. }
  1355. // 付款时间变化
  1356. function onPayTimeChange(item: any, e: any) {
  1357. // uni-datetime-picker 返回的可能是时间戳或 Date 对象,需要转换为字符串
  1358. const dateValue = e
  1359. if (dateValue) {
  1360. // 如果是时间戳或数字,转换为日期字符串
  1361. if (typeof dateValue === 'number' || typeof dateValue === 'string') {
  1362. const date = new Date(dateValue)
  1363. if (!isNaN(date.getTime())) {
  1364. const year = date.getFullYear()
  1365. const month = String(date.getMonth() + 1).padStart(2, '0')
  1366. const day = String(date.getDate()).padStart(2, '0')
  1367. item.payTime = `${year}-${month}-${day}`
  1368. }
  1369. } else if (typeof dateValue === 'object') {
  1370. // 如果已经是 Date 对象
  1371. const year = dateValue.getFullYear()
  1372. const month = String(dateValue.getMonth() + 1).padStart(2, '0')
  1373. const day = String(dateValue.getDate()).padStart(2, '0')
  1374. item.payTime = `${year}-${month}-${day}`
  1375. }
  1376. }
  1377. }
  1378. // 计算付款金额(根据比例)
  1379. function calculatePaymentAmount() {
  1380. const contractMoney = parseFloat(baseForm.value.contract_money) || 0
  1381. paymentList.value.forEach(item => {
  1382. const proportion = parseFloat(item.proportion) || 0
  1383. const amount = (contractMoney * proportion / 100).toFixed(2)
  1384. item.amount = amount
  1385. // 更新付款状态
  1386. updatePaymentStatus(item)
  1387. })
  1388. }
  1389. // 更新付款状态
  1390. function updatePaymentStatus(item: any) {
  1391. const amount = parseFloat(item.amount) || 0
  1392. const amountPaid = parseFloat(item.amountPaid) || 0
  1393. if (amountPaid === 0) {
  1394. item.payStatus = '0'
  1395. item.payStatusName = '未支付'
  1396. } else if (amountPaid < amount) {
  1397. item.payStatus = '1'
  1398. item.payStatusName = '部分支付'
  1399. } else if (amountPaid >= amount) {
  1400. item.payStatus = '2'
  1401. item.payStatusName = '已支付'
  1402. }
  1403. }
  1404. // 获取付款状态名称
  1405. function getPayStatusName(item: any): string {
  1406. const amount = parseFloat(item.amount) || 0
  1407. const amountPaid = parseFloat(item.amountPaid) || 0
  1408. if (amountPaid === 0) {
  1409. return '未支付'
  1410. } else if (amountPaid < amount) {
  1411. return '部分支付'
  1412. } else if (amountPaid >= amount) {
  1413. return '已支付'
  1414. }
  1415. return '未支付'
  1416. }
  1417. // 删除付款
  1418. function removePayment(index: number) {
  1419. $modal.confirm('', '确定删除该付款明细?')
  1420. .then(() => {
  1421. paymentList.value.splice(index, 1)
  1422. }).catch(() => {})
  1423. }
  1424. // 处理审批意见签名
  1425. const currentApprovalFieldName = ref('')
  1426. // 存储每个签名字段的印章信息
  1427. const approvalSealInfo = ref<Record<string, any>>({})
  1428. function handleApprovalSignature(fieldName: string) {
  1429. currentApprovalFieldName.value = fieldName
  1430. signaturePopupShow.value = false
  1431. nextTick(() => {
  1432. signaturePopupShow.value = true
  1433. })
  1434. signaturePopup.value.open()
  1435. }
  1436. // 处理一键签名
  1437. function handleAutoSeal(fieldName: string) {
  1438. const elem = getApprovalElement(fieldName)
  1439. if (elem) {
  1440. getSeal(userStore.user.useId).then(({ returnParams }) => {
  1441. const elem = getApprovalElement(fieldName)
  1442. elem.defaultValue = returnParams.sealFileId.universalid
  1443. elem.sealImgPath = returnParams.sealFileId.path
  1444. // 保存印章信息(用于后端处理)
  1445. // 一键签名时,sealFileId.universalid 就是印章模板 ID
  1446. approvalSealInfo.value[fieldName] = {
  1447. sealInsId: returnParams.sealFileId.universalid, // 签名实例 ID(这里与印章模板 ID 相同)
  1448. sealFileId: returnParams.sealFileId.universalid, // 印章模板 ID(用于 imgval)
  1449. left: 0, // 默认左边距为 0
  1450. top: 0 // 默认上边距为 0
  1451. }
  1452. }).catch(err => {
  1453. $modal.msgError('获取签名失败:' + err)
  1454. })
  1455. }
  1456. }
  1457. // 初始化签字板
  1458. function initSignature() {
  1459. signaturePopupShow.value = false
  1460. setTimeout(() => {
  1461. signaturePopupShow.value = true
  1462. }, 100)
  1463. }
  1464. // 点击签字板按钮
  1465. function onclickSignatureButton(event: string) {
  1466. switch (event) {
  1467. case 'undo':
  1468. signatureRef.value.undo()
  1469. break
  1470. case 'clear':
  1471. signatureRef.value.clear()
  1472. break
  1473. case 'save':
  1474. signatureRef.value.canvasToTempFilePath({
  1475. success: (res: any) => {
  1476. if (res.isEmpty) {
  1477. $modal.msgError('签名不能为空!')
  1478. return
  1479. }
  1480. // 判断上传文件是否是 base64
  1481. if (res.tempFilePath.substring(0, 'data:image/png;base64,'.length) == 'data:image/png;base64,') {
  1482. const _fileData = res.tempFilePath
  1483. uploadSignatureBoardImg(userStore.user.useId, _fileData, getApprovalElement(currentApprovalFieldName.value).tableField)
  1484. .then(({ returnParams }) => {
  1485. const elem = getApprovalElement(currentApprovalFieldName.value)
  1486. elem.defaultValue = returnParams.sealInsID
  1487. elem.sealImgPath = returnParams.path
  1488. // 保存印章信息(用于后端处理)
  1489. // sealInsID 是手写签名的实例 ID
  1490. approvalSealInfo.value[currentApprovalFieldName.value] = {
  1491. sealInsId: returnParams.sealInsID, // 签名实例 ID
  1492. sealFileId: returnParams.sealInsID, // 手写签名图片 ID
  1493. left: 0, // 默认左边距为 0
  1494. top: 0 // 默认上边距为 0
  1495. }
  1496. currentApprovalFieldName.value = ''
  1497. signaturePopupShow.value = false
  1498. signaturePopup.value.close()
  1499. })
  1500. } else {
  1501. // 转 base64
  1502. uni.getFileSystemManager().readFile({
  1503. filePath: res.tempFilePath,
  1504. encoding: 'base64',
  1505. success: (fileData: any) => {
  1506. const _fileData = 'data:image/png;base64,' + fileData.data
  1507. uploadSignatureBoardImg(userStore.user.useId, _fileData, getApprovalElement(currentApprovalFieldName.value).tableField)
  1508. .then(({ returnParams }) => {
  1509. const elem = getApprovalElement(currentApprovalFieldName.value)
  1510. elem.defaultValue = returnParams.sealInsID
  1511. elem.sealImgPath = returnParams.path
  1512. // 保存印章信息(用于后端处理)
  1513. // sealInsID 是手写签名的实例 ID
  1514. approvalSealInfo.value[currentApprovalFieldName.value] = {
  1515. sealInsId: returnParams.sealInsID, // 签名实例 ID
  1516. sealFileId: returnParams.sealInsID, // 手写签名图片 ID
  1517. left: 0, // 默认左边距为 0
  1518. top: 0 // 默认上边距为 0
  1519. }
  1520. currentApprovalFieldName.value = ''
  1521. signaturePopupShow.value = false
  1522. signaturePopup.value.close()
  1523. })
  1524. }
  1525. })
  1526. }
  1527. }
  1528. })
  1529. break
  1530. case 'landscape':
  1531. isLandscape.value = !isLandscape.value
  1532. initSignature()
  1533. break
  1534. }
  1535. }
  1536. // 清空签名
  1537. function clearSignature() {
  1538. onclickSignatureButton('clear')
  1539. }
  1540. // 保存签名
  1541. function saveSignature() {
  1542. onclickSignatureButton('save')
  1543. }
  1544. // 关闭签名
  1545. function closeSignature() {
  1546. signaturePopupShow.value = false
  1547. signaturePopup.value.close()
  1548. }
  1549. // 暴露验证方法给父组件
  1550. defineExpose({
  1551. validate: async () => {
  1552. // 合同编号验证(发起环节或字段可编辑时需要验证)
  1553. if (isSeModel.value || getFieldEditable('contract_number')) {
  1554. if (!baseForm.value.contract_number || !baseForm.value.contract_number.trim()) {
  1555. return Promise.reject(new Error('合同编号不能为空!'))
  1556. }
  1557. // 验证合同编号唯一性(异步调用后端接口)
  1558. try {
  1559. const res = await checkContractNumber(userStore.user.useId, baseForm.value.contract_number, baseForm.value.universalid || '')
  1560. if (res.returnCode !== '1') {
  1561. return Promise.reject(new Error(res.returnMsg || '合同编号验证失败'))
  1562. }
  1563. } catch (error) {
  1564. console.error('合同编号验证失败', error)
  1565. return Promise.reject(new Error('合同编号验证失败,请重试'))
  1566. }
  1567. }
  1568. // 基本信息验证
  1569. if (!baseForm.value.contract_name || !baseForm.value.contract_name.trim()) {
  1570. return Promise.reject(new Error('合同名称不能为空!'))
  1571. }
  1572. // 合同名称长度验证(最多 100 字符)
  1573. if (baseForm.value.contract_name && baseForm.value.contract_name.length > 100) {
  1574. return Promise.reject(new Error('合同名称长度不能超过 100!'))
  1575. }
  1576. // 合同类型验证 (发起环节或字段可编辑时需要验证)
  1577. if (isSeModel.value || getFieldEditable('contract_type')) {
  1578. const contractType = baseForm.value.contract_type
  1579. if (!contractType || (typeof contractType === 'string' && !contractType.trim())) {
  1580. return Promise.reject(new Error('合同类型不能为空!'))
  1581. }
  1582. }
  1583. // 经办人验证(发起环节或字段可编辑时需要验证)
  1584. /*if (isSeModel.value || getFieldEditable('salesman_name')) {
  1585. if (!baseForm.value.salesman || !baseForm.value.salesman.trim()) {
  1586. return Promise.reject(new Error('经办人不能为空!'))
  1587. }
  1588. }*/
  1589. // 合同金额验证(发起环节或字段可编辑时需要验证)
  1590. if (isSeModel.value || getFieldEditable('contract_money')) {
  1591. if (baseForm.value.contract_money) {
  1592. // 验证是否为数字
  1593. const moneyRegex = /^\d+(\.\d{1,2})?$/
  1594. if (!moneyRegex.test(baseForm.value.contract_money)) {
  1595. return Promise.reject(new Error('合同金额只能是数字!'))
  1596. }
  1597. // 验证合同金额不能小于物料总金额
  1598. const totalPrice = calculateTotalPriceValue()
  1599. const contractMoney = parseFloat(baseForm.value.contract_money)
  1600. if (contractMoney < totalPrice) {
  1601. return Promise.reject(new Error('合同金额不能小于物料总金额:' + totalPrice.toFixed(2)))
  1602. }
  1603. }
  1604. }
  1605. // 供方验证(发起环节或字段可编辑时需要验证)
  1606. if (isSeModel.value || getFieldEditable('secondparty_name')) {
  1607. if (!baseForm.value.secondparty_name || !baseForm.value.secondparty_name.trim()) {
  1608. return Promise.reject(new Error('供方不能为空!'))
  1609. }
  1610. }
  1611. // 物料明细验证(发起环节时验证)
  1612. if (isSeModel.value && materialList.value.length > 0) {
  1613. for (let i = 0; i < materialList.value.length; i++) {
  1614. const item = materialList.value[i]
  1615. // 数量验证:不能为空且必须大于 0
  1616. if (!item.qty || Number(item.qty) <= 0) {
  1617. return Promise.reject(new Error(`请填写第${i + 1}个物料的数量,且必须大于 0`))
  1618. }
  1619. // 税前单价验证:不能为空且不能为负数
  1620. if (!item.price || Number(item.price) < 0) {
  1621. return Promise.reject(new Error(`请填写第${i + 1}个物料的税前单价,且不能为负数`))
  1622. }
  1623. // 税率验证:不能为空且不能为负数
  1624. if (!item.cess || Number(item.cess) < 0) {
  1625. return Promise.reject(new Error(`请填写第${i + 1}个物料的税率,且不能为负数`))
  1626. }
  1627. // 税后单价验证:不能为空且不能为负数
  1628. if (!item.priceTax || Number(item.priceTax) < 0) {
  1629. return Promise.reject(new Error(`请填写第${i + 1}个物料的税后单价,且不能为负数`))
  1630. }
  1631. }
  1632. }
  1633. // 付款明细验证(发起环节时验证)
  1634. if (isSeModel.value && paymentList.value.length > 0) {
  1635. for (let i = 0; i < paymentList.value.length; i++) {
  1636. const item = paymentList.value[i]
  1637. // 付款方式验证
  1638. if (!item.payType || !item.payTypeName) {
  1639. return Promise.reject(new Error(`第${i + 1}行付款方式不能为空!`))
  1640. }
  1641. // 比例验证:不能为空且必须大于 0
  1642. if (!item.proportion || Number(item.proportion) <= 0) {
  1643. return Promise.reject(new Error(`请填写第${i + 1}个付款比例,且必须大于 0`))
  1644. }
  1645. // 金额验证
  1646. /*if (!item.amount || item.amount.toString().trim() === '') {
  1647. return Promise.reject(new Error(`第${i + 1}行付款金额不能为空!`))
  1648. }*/
  1649. }
  1650. }
  1651. // 验证审批意见字段(如果在 table_fields 中)
  1652. const approvalFields = [
  1653. { fieldName: 'departmental_opinion', msg: '部门意见' },
  1654. { fieldName: 'deputy_general_manager_opinion', msg: '分管副总意见' },
  1655. { fieldName: 'audit_deputy_general_manager_opinion', msg: '分管副总意见' },
  1656. { fieldName: 'general_manager_opinion', msg: '总经理意见' },
  1657. { fieldName: 'finance_opinion', msg: '财务意见' },
  1658. { fieldName: 'chairman_opinion', msg: '董事长意见' }
  1659. ]
  1660. for (const field of approvalFields) {
  1661. const elem = getApprovalElement(field.fieldName)
  1662. if (elem) {
  1663. // 检查该字段是否在当前环节的可编辑字段列表中
  1664. // editableFields 包含了当前环节可编辑的所有字段(即 table_fields)
  1665. if (props.editableFields && props.editableFields.includes(field.fieldName)) {
  1666. if (!elem.defaultValue || elem.defaultValue === '') {
  1667. return Promise.reject(new Error(field.msg + '不能为空!'))
  1668. }
  1669. }
  1670. }
  1671. }
  1672. return Promise.resolve()
  1673. },
  1674. // 获取表单数据(返回 formElements 格式)
  1675. getFormElements: () => {
  1676. const formElements: any[] = []
  1677. // 添加基本信息字段
  1678. Object.keys(baseForm.value).forEach(key => {
  1679. const value = baseForm.value[key]
  1680. if (value !== undefined && value !== null) {
  1681. formElements.push({
  1682. name: key,
  1683. value: String(value),
  1684. type: '0' // 普通文本类型
  1685. })
  1686. }
  1687. })
  1688. // 添加审批意见字段
  1689. const approvalFields = ['departmental_opinion', 'deputy_general_manager_opinion', 'audit_deputy_general_manager_opinion', 'general_manager_opinion', 'finance_opinion', 'chairman_opinion']
  1690. approvalFields.forEach(fieldName => {
  1691. const elem = getApprovalElement(fieldName)
  1692. if (elem) {
  1693. formElements.push({
  1694. name: fieldName,
  1695. value: elem.defaultValue || '',
  1696. type: elem.type || '0'
  1697. })
  1698. // 添加签名图片的 imgval 值(用于后端处理)
  1699. // 格式:sealFileId_left_top(必须使用印章模板 ID,而不是签名实例 ID)
  1700. if (approvalSealInfo.value[fieldName]) {
  1701. const sealInfo = approvalSealInfo.value[fieldName]
  1702. formElements.push({
  1703. name: fieldName + '_imgval',
  1704. value: `${sealInfo.sealFileId}_${sealInfo.left}_${sealInfo.top}`,
  1705. type: '0'
  1706. })
  1707. } else if (elem.sealImgPath && elem.defaultValue) {
  1708. // 兼容旧数据:如果有 sealImgPath 和 defaultValue,提取 sealId 构建 imgval
  1709. // sealImgPath 格式:/shares/document/seal/593268258724500.png
  1710. const sealIdMatch = elem.sealImgPath.match(/\/seal\/(\d+)\.png$/)
  1711. if (sealIdMatch) {
  1712. const sealId = sealIdMatch[1]
  1713. formElements.push({
  1714. name: fieldName + '_imgval',
  1715. value: `${sealId}_0_0`,
  1716. type: '0'
  1717. })
  1718. }
  1719. }
  1720. }
  1721. })
  1722. // 添加物料明细(JSON 字符串格式)
  1723. if (materialList.value && materialList.value.length > 0) {
  1724. formElements.push({
  1725. name: 'contractMaterialList',
  1726. value: JSON.stringify(materialList.value),
  1727. type: '0'
  1728. })
  1729. }
  1730. // 添加付款明细(JSON 字符串格式)
  1731. if (paymentList.value && paymentList.value.length > 0) {
  1732. formElements.push({
  1733. name: 'contractPaymentList',
  1734. value: JSON.stringify(paymentList.value),
  1735. type: '0'
  1736. })
  1737. }
  1738. return formElements
  1739. },
  1740. // 获取表单数据(兼容旧版本,返回键值对格式)
  1741. getFormData: () => {
  1742. const formData: any = {
  1743. ...baseForm.value,
  1744. contractMaterialList: materialList.value || [],
  1745. contractPaymentList: paymentList.value || []
  1746. }
  1747. // 添加审批意见字段数据
  1748. const approvalFields = ['departmental_opinion', 'deputy_general_manager_opinion', 'audit_deputy_general_manager_opinion', 'general_manager_opinion', 'finance_opinion', 'chairman_opinion']
  1749. approvalFields.forEach(fieldName => {
  1750. const elem = getApprovalElement(fieldName)
  1751. if (elem) {
  1752. formData[fieldName] = elem.defaultValue || ''
  1753. // 添加签名图片的 imgval 值(用于后端处理)
  1754. // 格式:sealFileId_left_top(必须使用印章模板 ID,而不是签名实例 ID)
  1755. if (approvalSealInfo.value[fieldName]) {
  1756. const sealInfo = approvalSealInfo.value[fieldName]
  1757. formData[fieldName + '_imgval'] = `${sealInfo.sealFileId}_${sealInfo.left}_${sealInfo.top}`
  1758. } else if (elem.sealImgPath && elem.defaultValue) {
  1759. // 兼容旧数据:如果有 sealImgPath 和 defaultValue,提取 sealId 构建 imgval
  1760. // sealImgPath 格式:/shares/document/seal/593268258724500.png
  1761. const sealIdMatch = elem.sealImgPath.match(/\/seal\/(\d+)\.png$/)
  1762. if (sealIdMatch) {
  1763. const sealId = sealIdMatch[1]
  1764. formData[fieldName + '_imgval'] = `${sealId}_0_0`
  1765. }
  1766. }
  1767. }
  1768. })
  1769. return formData
  1770. }
  1771. })
  1772. </script>
  1773. <style lang="scss" scoped>
  1774. /* 基本信息中的禁用字段样式优化 */
  1775. ::v-deep .uni-forms {
  1776. .uni-forms-item__content {
  1777. .uni-easyinput__content-input {
  1778. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1779. font-weight: 500;
  1780. color: #333;
  1781. }
  1782. .uni-date {
  1783. .uni-icons {
  1784. font-size: calc(22px + 1.2*(1rem - 16px)) !important;
  1785. font-weight: 500;
  1786. }
  1787. .uni-date__x-input {
  1788. height: auto;
  1789. font-size: calc(14px + 1.2*(1rem - 16px)) !important;
  1790. font-weight: 500;
  1791. color: #333;
  1792. }
  1793. }
  1794. }
  1795. }
  1796. // 审批意见字段样式(与 purchase-form 保持一致)
  1797. .element_value_container {
  1798. .signature_img {
  1799. width: 180px;
  1800. }
  1801. }
  1802. // 选择器样式
  1803. .selector-wrapper {
  1804. padding: 10px 0;
  1805. cursor: pointer;
  1806. .placeholder {
  1807. color: #c0c4cc;
  1808. }
  1809. }
  1810. .picker {
  1811. padding: 10px 0;
  1812. color: #333;
  1813. }
  1814. // 签名弹窗样式(与 purchase-form 保持一致)
  1815. .signature_container {
  1816. background-color: #f5f5f5;
  1817. height: 40vh;
  1818. width: 90vw;
  1819. .signature_content {
  1820. height: 80%;
  1821. width: 100%;
  1822. }
  1823. .signature_button_container {
  1824. height: 20%;
  1825. width: 100%;
  1826. button {
  1827. height: 100%;
  1828. }
  1829. }
  1830. }
  1831. .signature_container_landscape {
  1832. height: 100vh;
  1833. width: 100vw;
  1834. .signature_content {
  1835. height: 85%;
  1836. width: 100%;
  1837. }
  1838. .signature_button_container {
  1839. margin-top: 10%;
  1840. height: 15%;
  1841. width: 100%;
  1842. button {
  1843. height: 100%;
  1844. width: 100%;
  1845. transform: rotate(90deg);
  1846. }
  1847. }
  1848. }
  1849. // 物料列表 - 卡片式展示
  1850. .material-list {
  1851. display: flex;
  1852. flex-direction: column;
  1853. gap: 10px;
  1854. }
  1855. .material-actions {
  1856. display: flex;
  1857. gap: 10px;
  1858. margin-bottom: 15px;
  1859. button {
  1860. flex: 1;
  1861. }
  1862. }
  1863. .material-card {
  1864. border: 1px solid #e5e5e5;
  1865. border-radius: 6px;
  1866. overflow: hidden;
  1867. background-color: #fff;
  1868. margin-bottom: 8px;
  1869. .material-header {
  1870. display: flex;
  1871. justify-content: space-between;
  1872. align-items: center;
  1873. padding: 10px 12px;
  1874. background-color: #f8f9fa;
  1875. cursor: pointer;
  1876. .material-main-info {
  1877. display: flex;
  1878. align-items: center;
  1879. gap: 8px;
  1880. flex: 1;
  1881. .material-name {
  1882. font-size: 14px;
  1883. font-weight: bold;
  1884. color: #333;
  1885. }
  1886. .material-code {
  1887. font-size: 12px;
  1888. color: #999;
  1889. white-space: nowrap;
  1890. }
  1891. }
  1892. .material-expand {
  1893. display: flex;
  1894. align-items: center;
  1895. margin-left: 10px;
  1896. }
  1897. }
  1898. .material-detail {
  1899. padding: 10px 12px;
  1900. border-top: 1px solid #e5e5e5;
  1901. .detail-row {
  1902. display: flex;
  1903. align-items: center;
  1904. flex-wrap: wrap;
  1905. gap: 8px;
  1906. .detail-label {
  1907. font-size: 13px;
  1908. color: #666;
  1909. flex-shrink: 0;
  1910. }
  1911. .detail-value {
  1912. flex: 0 0 auto;
  1913. font-size: 13px;
  1914. color: #333;
  1915. }
  1916. }
  1917. // 删除按钮行的特殊样式
  1918. &.delete-row {
  1919. button {
  1920. margin-left: auto;
  1921. padding: 2px 10px;
  1922. height: auto;
  1923. line-height: 1.5;
  1924. }
  1925. }
  1926. // 价格样式
  1927. .price-value {
  1928. color: #f56c6c;
  1929. font-weight: bold;
  1930. }
  1931. // 采购申请单编号样式
  1932. .purchase-number {
  1933. color: #409eff;
  1934. font-weight: normal;
  1935. }
  1936. }
  1937. }
  1938. .empty-materials {
  1939. text-align: center;
  1940. padding: 30px;
  1941. color: #909399;
  1942. font-size: 14px;
  1943. }
  1944. // 付款状态标签样式
  1945. .status-tag {
  1946. padding: 2px 8px;
  1947. border-radius: 4px;
  1948. font-size: 12px;
  1949. &.status-0 {
  1950. background-color: #f0f0f0;
  1951. color: #333;
  1952. }
  1953. &.status-1 {
  1954. background-color: #fff7e6;
  1955. color: #fa8c16;
  1956. }
  1957. &.status-2 {
  1958. background-color: #f6ffed;
  1959. color: #52c41a;
  1960. }
  1961. }
  1962. // 付款列表 - 卡片式展示
  1963. .payment-list {
  1964. display: flex;
  1965. flex-direction: column;
  1966. gap: 10px;
  1967. }
  1968. .payment-actions {
  1969. display: flex;
  1970. gap: 10px;
  1971. margin-bottom: 15px;
  1972. button {
  1973. flex: 1;
  1974. }
  1975. }
  1976. // 付款列表 - 卡片式展示
  1977. .payment-list {
  1978. display: flex;
  1979. flex-direction: column;
  1980. gap: 10px;
  1981. }
  1982. .payment-actions {
  1983. display: flex;
  1984. gap: 10px;
  1985. margin-bottom: 15px;
  1986. button {
  1987. flex: 1;
  1988. }
  1989. }
  1990. .payment-card {
  1991. border: 1px solid #e5e5e5;
  1992. border-radius: 6px;
  1993. overflow: hidden;
  1994. background-color: #fff;
  1995. margin-bottom: 8px;
  1996. .payment-header {
  1997. display: flex;
  1998. justify-content: space-between;
  1999. align-items: center;
  2000. padding: 10px 12px;
  2001. background-color: #f8f9fa;
  2002. cursor: pointer;
  2003. .payment-main-info {
  2004. display: flex;
  2005. align-items: center;
  2006. gap: 8px;
  2007. flex: 1;
  2008. .payment-name {
  2009. font-size: 14px;
  2010. font-weight: bold;
  2011. color: #333;
  2012. }
  2013. }
  2014. .payment-expand {
  2015. display: flex;
  2016. align-items: center;
  2017. margin-left: 10px;
  2018. }
  2019. }
  2020. .payment-detail {
  2021. padding: 10px 12px;
  2022. border-top: 1px solid #e5e5e5;
  2023. .detail-row {
  2024. display: flex;
  2025. align-items: center;
  2026. flex-wrap: wrap;
  2027. gap: 8px;
  2028. .detail-label {
  2029. font-size: 13px;
  2030. color: #666;
  2031. flex-shrink: 0;
  2032. }
  2033. .detail-value {
  2034. flex: 0 0 auto;
  2035. font-size: 13px;
  2036. color: #333;
  2037. }
  2038. }
  2039. }
  2040. }
  2041. .empty-payments {
  2042. text-align: center;
  2043. padding: 30px;
  2044. color: #909399;
  2045. font-size: 14px;
  2046. }
  2047. // 付款状态标签样式
  2048. .status-tag {
  2049. padding: 2px 8px;
  2050. border-radius: 4px;
  2051. font-size: 12px;
  2052. &.status-0 {
  2053. background-color: #f0f0f0;
  2054. color: #999;
  2055. }
  2056. &.status-1 {
  2057. background-color: #ffecdb;
  2058. color: #ff8800;
  2059. }
  2060. &.status-2 {
  2061. background-color: #e8f5e9;
  2062. color: #4caf50;
  2063. }
  2064. }
  2065. // 采购申请单编号样式
  2066. .purchase-number {
  2067. color: #007aff;
  2068. font-weight: 500;
  2069. }
  2070. // 选择器弹窗样式
  2071. .selector-popup {
  2072. // ✅ 关键:使用固定宽度
  2073. width: 580px;
  2074. max-width: 95vw;
  2075. min-width: 300px;
  2076. max-height: 70vh;
  2077. background-color: #fff;
  2078. border-radius: 12px;
  2079. overflow: hidden;
  2080. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  2081. position: relative;
  2082. margin: 0 auto;
  2083. .popup-header {
  2084. display: flex;
  2085. justify-content: space-between;
  2086. align-items: center;
  2087. padding: 15px;
  2088. border-bottom: 1px solid #e5e5e5;
  2089. width: 100%;
  2090. box-sizing: border-box;
  2091. overflow: hidden;
  2092. .popup-title {
  2093. font-size: 16px;
  2094. font-weight: bold;
  2095. overflow: hidden;
  2096. text-overflow: ellipsis;
  2097. white-space: nowrap;
  2098. max-width: calc(100% - 30px);
  2099. }
  2100. }
  2101. // 物料来源选择
  2102. .material-source-selector {
  2103. padding: 10px 15px;
  2104. border-bottom: 1px solid #f0f0f0;
  2105. width: 100%;
  2106. box-sizing: border-box;
  2107. overflow: hidden;
  2108. .source-options {
  2109. display: flex;
  2110. gap: 10px;
  2111. width: 100%;
  2112. .source-option {
  2113. flex: 1;
  2114. min-width: 0;
  2115. padding: 8px 12px;
  2116. text-align: center;
  2117. background-color: #f5f5f5;
  2118. border-radius: 6px;
  2119. font-size: 14px;
  2120. cursor: pointer;
  2121. transition: all 0.2s;
  2122. overflow: hidden;
  2123. &.active {
  2124. background-color: #007aff;
  2125. color: #fff;
  2126. font-weight: 500;
  2127. }
  2128. }
  2129. }
  2130. }
  2131. // 采购申请单选择器
  2132. .purchase-selector {
  2133. display: flex;
  2134. gap: 8px;
  2135. padding: 10px 15px;
  2136. border-bottom: 1px solid #f0f0f0;
  2137. align-items: center;
  2138. width: 100%;
  2139. box-sizing: border-box;
  2140. overflow: hidden;
  2141. .picker {
  2142. flex: 1;
  2143. min-width: 0;
  2144. padding: 8px 12px;
  2145. background-color: #f5f5f5;
  2146. border-radius: 6px;
  2147. font-size: 14px;
  2148. overflow: hidden;
  2149. text-overflow: ellipsis;
  2150. }
  2151. button[type="warn"] {
  2152. flex-shrink: 0;
  2153. padding: 0 12px;
  2154. }
  2155. }
  2156. .search-bar {
  2157. display: flex;
  2158. gap: 10px;
  2159. padding: 10px 15px;
  2160. align-items: center;
  2161. width: 100%;
  2162. box-sizing: border-box;
  2163. overflow: hidden;
  2164. button {
  2165. flex-shrink: 0;
  2166. }
  2167. }
  2168. .popup-content {
  2169. max-height: 50vh;
  2170. width: 100%;
  2171. overflow-x: hidden;
  2172. position: relative;
  2173. .selector-item {
  2174. padding: 10px 12px;
  2175. border-bottom: 1px solid #f0f0f0;
  2176. width: 100%;
  2177. box-sizing: border-box;
  2178. overflow: hidden;
  2179. &:active {
  2180. background-color: #f5f5f5;
  2181. }
  2182. .selector-item-content {
  2183. display: flex;
  2184. justify-content: space-between;
  2185. align-items: center;
  2186. gap: 8px;
  2187. width: 100%;
  2188. max-width: 100%;
  2189. overflow: hidden;
  2190. min-width: 0;
  2191. .item-info {
  2192. flex: 1 1 auto !important;
  2193. min-width: 0 !important;
  2194. max-width: none !important;
  2195. display: flex;
  2196. flex-wrap: wrap;
  2197. align-items: center;
  2198. gap: 4px;
  2199. overflow: hidden;
  2200. position: relative;
  2201. .item-name {
  2202. font-size: 15px;
  2203. font-weight: bold;
  2204. color: #333;
  2205. flex-basis: 100%;
  2206. margin-bottom: 4px;
  2207. word-break: break-all;
  2208. overflow-wrap: break-word;
  2209. }
  2210. .item-purchase {
  2211. font-size: 12px;
  2212. color: #007aff;
  2213. flex-basis: 100%;
  2214. margin-bottom: 2px;
  2215. word-break: break-all;
  2216. overflow-wrap: break-word;
  2217. }
  2218. .item-code,
  2219. .item-spec,
  2220. .item-extra {
  2221. font-size: 13px;
  2222. color: #666;
  2223. white-space: nowrap;
  2224. font-weight: 500;
  2225. flex-shrink: 0;
  2226. max-width: 100%;
  2227. overflow: hidden;
  2228. text-overflow: ellipsis;
  2229. }
  2230. .item-code::after,
  2231. .item-spec::after {
  2232. content: ' | ';
  2233. margin: 0 4px;
  2234. color: #ddd;
  2235. }
  2236. .item-spec:last-child::after,
  2237. .item-extra:last-child::after {
  2238. content: '';
  2239. }
  2240. }
  2241. .selected-tag {
  2242. color: #409eff;
  2243. font-size: 12px;
  2244. padding: 4px 8px;
  2245. background-color: #ecf5ff;
  2246. border-radius: 4px;
  2247. }
  2248. }
  2249. }
  2250. .loading-text,
  2251. .no-more-text {
  2252. padding: 16px;
  2253. text-align: center;
  2254. color: #999;
  2255. font-size: 14px;
  2256. }
  2257. .empty-data {
  2258. padding: 40px 16px;
  2259. text-align: center;
  2260. color: #999;
  2261. font-size: 14px;
  2262. }
  2263. }
  2264. }
  2265. </style>