PurchaseForm.vue 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. <template>
  2. <view>
  3. <cu-custom :backUrl="'/pages/index/index'" :isBack="true" bgColor="bg-gradual-blue">
  4. <block slot="content">采购申请</block>
  5. </cu-custom>
  6. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules"
  7. ref="inputForm" v-if="!nodeFlag">
  8. <u-form-item label="采购编号" borderBottom prop="purchaseNo">
  9. <u--input placeholder='自动生成' v-model="inputForm.purchaseNo" disabled></u--input>
  10. </u-form-item>
  11. <u-form-item label="采购名称" borderBottom prop="purchaseSketch" :required="true">
  12. <u--input placeholder='请填写采购名称' v-model="inputForm.purchaseSketch"></u--input>
  13. </u-form-item>
  14. <u-form-item label="经办人" borderBottom prop="handledBy">
  15. <u--input placeholder='' v-model="inputForm.handledBy" disabled></u--input>
  16. </u-form-item>
  17. <u-form-item label="经办人部门" borderBottom prop="handledByOfficeName">
  18. <u--input placeholder='' v-model="inputForm.handledByOfficeName" disabled></u--input>
  19. </u-form-item>
  20. <u-form-item label="采购申请时间" borderBottom prop="purchaseDate" :required="true">
  21. <el-date-picker v-model="inputForm.purchaseDate" type="date" placeholder="请选择采购申请时间" style="width:100%"
  22. size="default" placement="bottom-start" clearable>
  23. </el-date-picker>
  24. </u-form-item>
  25. <u-form-item label="采购方式" borderBottom prop="purchaseMode" :required="true">
  26. <jp-picker placeholder='请选择采购方式' v-model="inputForm.purchaseMode" rangeKey="label" rangeValue="value"
  27. :range="[
  28. { label: '办公室采购', value: '1' },
  29. { label: '自行采购', value: '2' },
  30. ]"></jp-picker>
  31. </u-form-item>
  32. <u-form-item label="备注" borderBottom prop="remarks">
  33. <u--textarea placeholder='请填写备注信息' :rows="5" :maxlength="500" v-model="inputForm.remarks"></u--textarea>
  34. </u-form-item>
  35. <el-row :gutter="15" :key="index_experience" v-for="(item, index_experience) in this.inputForm.detailInfos">
  36. <el-col :span="24">
  37. <u-form-item label="">
  38. <el-divider content-position="left"> 采购详情 {{ index_experience + 1 }}</el-divider>
  39. </u-form-item>
  40. </el-col>
  41. <el-col :span="24">
  42. <u-form-item label="采购人" :prop="'detailInfos[' + index_experience + '].purchaserAgent'"
  43. :required="true" :rules="[
  44. ]">
  45. <u--input v-model="inputForm.detailInfos[index_experience].purchaserAgent" placeholder="请选择采购人"
  46. @focus="openUserPullForm(index_experience)" clearable></u--input>
  47. </u-form-item>
  48. <u-form-item label="采购人部门" :prop="'detailInfos[' + index_experience + '].procurementOffice'"
  49. :required="true" :rules="[
  50. ]">
  51. <u--input v-model="inputForm.detailInfos[index_experience].procurementOffice" placeholder=""
  52. clearable></u--input>
  53. </u-form-item>
  54. <u-form-item label="采购类型" :prop="'detailInfos[' + index_experience + '].procurementType'"
  55. :required="true" :rules="[
  56. ]">
  57. <u--input v-model="inputForm.detailInfos[index_experience].procurementType"
  58. placeholder="请选择采购类型" @focus="showPicker(index_experience)" clearable></u--input>
  59. </u-form-item>
  60. <psi-goods-selector :row-index="index_experience" :input-form="inputForm" row-path="detailInfos"
  61. :value-fields="['tradeName']" prop-field="tradeName" label="商品名称" placeholder="请选择商品名称"
  62. title="选择商品" search-placeholder="搜索商品名称" empty-text="暂无可选商品" :show-stock="false"
  63. :require-parent="true" parent-id-field="procurementTypeId" parent-name-field="procurementType"
  64. parent-required-text="请先选择采购类型" @selected="handleGoodsSelected"></psi-goods-selector>
  65. <!--<u-form-item label="商品名称" :prop="'detailInfos[' + index_experience + '].tradeName'"
  66. :rules="[
  67. ]">
  68. <u--input v-model="inputForm.detailInfos[index_experience].tradeName" placeholder="请选择物品名称" clearable></u--input>
  69. </u-form-item>-->
  70. <u-form-item label="商品单价(元)" :prop="'detailInfos[' + index_experience + '].tradePrice'" :rules="[
  71. ]">
  72. <u--input @blur="onInputCode(index_experience, $event, 'tradePrice')"
  73. v-model="inputForm.detailInfos[index_experience].tradePrice" placeholder="请输入商品单价(元)"
  74. clearable></u--input>
  75. </u-form-item>
  76. <u-form-item label="商品数量" :prop="'detailInfos[' + index_experience + '].tradeNumber'" :rules="[
  77. ]">
  78. <u--input @blur="onInputCode(index_experience, $event, 'tradeNumber')"
  79. v-model="inputForm.detailInfos[index_experience].tradeNumber" placeholder="请输入商品数量"
  80. clearable></u--input>
  81. </u-form-item>
  82. <u-form-item label="商品总价" :prop="'detailInfos[' + index_experience + '].priceSum'" :rules="[
  83. ]">
  84. <u--input v-model="inputForm.detailInfos[index_experience].priceSum" placeholder="请输入商品总价"
  85. :readonly="true" clearable></u--input>
  86. </u-form-item>
  87. <u-form-item label="品牌" :prop="'detailInfos[' + index_experience + '].brand'">
  88. <u--input v-model="inputForm.detailInfos[index_experience].brand" disabled></u--input>
  89. </u-form-item>
  90. <u-form-item label="规格" :prop="'detailInfos[' + index_experience + '].specification'">
  91. <u--input v-model="inputForm.detailInfos[index_experience].specification" disabled></u--input>
  92. </u-form-item>
  93. <u-form-item label="单位" :prop="'detailInfos[' + index_experience + '].company'" :rules="[
  94. ]">
  95. <u--input v-model="inputForm.detailInfos[index_experience].company" placeholder="请输入单位"
  96. disabled></u--input>
  97. </u-form-item>
  98. <u-form-item label="备注" :prop="'detailInfos[' + index_experience + '].remarks'" :rules="[
  99. ]">
  100. <u--input v-model="inputForm.detailInfos[index_experience].remarks" placeholder="请输入备注"
  101. clearable></u--input>
  102. </u-form-item>
  103. <u-form-item label="文件上传" v-if="false">
  104. <!-- <el-upload class="upload-demo"
  105. :action="`http://cpaoa.xgccpm.com/api/public-modules-server/oss/file/webUpload/upload`"
  106. :on-remove="(file, fileList) => handleRemove(file, fileList, index_experience, 'detail')"
  107. :file-list="inputForm.detailInfos[index_experience].fileInfoLost"
  108. :on-success="(response, file, fileList) => handleUploadSuccess(response, file, fileList, index_experience, 'detail')"
  109. :limit="3">
  110. <el-button size="small" type="primary">点击上传</el-button>
  111. <div slot="tip" class="el-upload__tip">只能上传不超过 3 个文件</div>
  112. <template slot="file" slot-scope="{ file }"
  113. v-if="shouldShowFile(file, index_experience, 'detail') || testFlag">
  114. <span @click="handleFileClick(file)">{{ file.name }}</span>
  115. <el-button type="text" icon="el-icon-close"
  116. @click="handleDelete(file, index_experience, 'detail')">✕</el-button>
  117. </template>
  118. </el-upload> -->
  119. <UploadComponent :uploadUrl="`${uploadUrl}/public-modules-server/oss/file/webUpload/upload`"
  120. @onRemove="(file, fileList, fileIndex) => handleRemove(file, fileList, index_experience, fileIndex, 'detail')"
  121. @onSuccess="(file, fileList) => handleUploadSuccess(file, fileList, index_experience, 'detail')"
  122. :fileList="inputForm.detailInfos[index_experience].fileInfoLost" :limit="3"
  123. :isDelete="nodeFlag" :isUpload="nodeFlag">
  124. </UploadComponent>
  125. </u-form-item>
  126. </el-col>
  127. <el-col :span="24" style="text-align: center">
  128. <u-form-item label="">
  129. <el-button style="width: 100%" type="danger" @click="removeRow(index_experience)" plain>删除采购详情
  130. {{ index_experience + 1 }}</el-button>
  131. </u-form-item>
  132. </el-col>
  133. </el-row>
  134. <u-form-item label="">
  135. <el-button style="width: 100%" type="primary" @click="addRow()" plain>新增采购详情</el-button>
  136. </u-form-item>
  137. <u-form-item label="附件" v-if="false">
  138. <!-- <el-upload class="upload-demo"
  139. :action="`http://cpaoa.xgccpm.com/api/public-modules-server/oss/file/webUpload/upload`"
  140. :on-remove="(file, fileList) => handleRemove(file, fileList, '', '')" :file-list="inputForm.files"
  141. :on-success="(response, file, fileList) => handleUploadSuccess(response, file, fileList, '', '')"
  142. :limit="3">
  143. <el-button size="small" type="primary">点击上传</el-button>
  144. <div slot="tip" class="el-upload__tip">只能上传不超过 3 个文件</div>
  145. <template slot="file" slot-scope="{ file }" v-if="shouldShowFile(file) || testFlag">
  146. <span @click="handleFileClick(file)">{{ file.name }}</span>
  147. <el-button type="text" icon="el-icon-close" @click="handleDelete(file)">✕</el-button>
  148. </template>
  149. </el-upload> -->
  150. <UploadComponent :uploadUrl="`${uploadUrl}/public-modules-server/oss/file/webUpload/upload`"
  151. @onRemove="(file, fileList, fileIndex) => handleRemove(file, fileList, fileIndex, '')"
  152. @onSuccess="(file, fileList) => handleUploadSuccess(file, fileList, '', '')"
  153. :fileList="inputForm.files" :limit="3" :isDelete="nodeFlag" :isUpload="nodeFlag">
  154. </UploadComponent>
  155. </u-form-item>
  156. </u--form>
  157. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules"
  158. ref="inputForm" v-else-if="nodeFlag">
  159. <u-form-item label="采购编号" borderBottom prop="purchaseNo">
  160. <u--input placeholder='自动生成' v-model="inputForm.purchaseNo" disabled></u--input>
  161. </u-form-item>
  162. <u-form-item label="采购名称" borderBottom prop="purchaseSketch" :required="true">
  163. <u--input placeholder='请填写采购名称' disabled v-model="inputForm.purchaseSketch"></u--input>
  164. </u-form-item>
  165. <u-form-item label="经办人" borderBottom prop="handledBy">
  166. <u--input placeholder='' v-model="inputForm.handledBy" disabled></u--input>
  167. </u-form-item>
  168. <u-form-item label="经办人部门" borderBottom prop="handledByOfficeName">
  169. <u--input placeholder='' v-model="inputForm.handledByOfficeName" disabled></u--input>
  170. </u-form-item>
  171. <u-form-item label="采购申请时间" borderBottom prop="purchaseDate" :required="true">
  172. <el-date-picker :disabled="true" v-model="inputForm.purchaseDate" type="date" placeholder="请选择采购申请时间"
  173. style="width:100%" size="default" placement="bottom-start" clearable>
  174. </el-date-picker>
  175. </u-form-item>
  176. <u-form-item label="采购方式" borderBottom prop="purchaseMode" :required="true">
  177. <jp-picker placeholder='请选择采购方式' v-model="inputForm.purchaseMode" :disabled="true" rangeKey="label"
  178. rangeValue="value" :range="[
  179. { label: '办公室采购', value: '1' },
  180. { label: '自行采购', value: '2' },
  181. ]"></jp-picker>
  182. </u-form-item>
  183. <u-form-item label="备注" borderBottom prop="remarks">
  184. <u--textarea placeholder='请填写备注信息' :disabled="true" :rows="5" :maxlength="500"
  185. v-model="inputForm.remarks"></u--textarea>
  186. </u-form-item>
  187. <el-row :gutter="15" :key="index_experience" v-for="(item, index_experience) in this.inputForm.detailInfos">
  188. <el-col :span="24">
  189. <u-form-item label="">
  190. <el-divider content-position="left"> 采购详情 {{ index_experience + 1 }}</el-divider>
  191. </u-form-item>
  192. </el-col>
  193. <el-col :span="24">
  194. <u-form-item label="采购人" :prop="'detailInfos[' + index_experience + '].purchaserAgent'"
  195. :required="true" :rules="[
  196. ]">
  197. <el-input v-model="inputForm.detailInfos[index_experience].purchaserAgent" :disabled="true"
  198. placeholder="请选择采购人" @focus="openUserPullForm(index_experience)" clearable></el-input>
  199. </u-form-item>
  200. <u-form-item label="采购人部门" :prop="'detailInfos[' + index_experience + '].procurementOffice'"
  201. :required="true" :rules="[
  202. ]">
  203. <el-input v-model="inputForm.detailInfos[index_experience].procurementOffice" :disabled="true"
  204. placeholder="" clearable></el-input>
  205. </u-form-item>
  206. <u-form-item label="采购类型" :prop="'detailInfos[' + index_experience + '].procurementType'"
  207. :required="true" :rules="[
  208. ]">
  209. <el-input v-model="inputForm.detailInfos[index_experience].procurementType" :disabled="true"
  210. placeholder="请选择采购类型" @focus="showPicker(index_experience)" clearable></el-input>
  211. </u-form-item>
  212. <psi-goods-selector :row-index="index_experience" :disabled="true" :input-form="inputForm"
  213. row-path="detailInfos" :value-fields="['tradeName']" prop-field="tradeName" label="商品名称"
  214. placeholder="请选择商品名称" title="选择商品" search-placeholder="搜索商品名称" empty-text="暂无可选商品"
  215. :show-stock="false" :require-parent="true" parent-id-field="procurementTypeId"
  216. parent-name-field="procurementType" parent-required-text="请先选择采购类型"
  217. @selected="handleGoodsSelected"></psi-goods-selector>
  218. <!-- <u-form-item label="商品名称" :prop="'detailInfos[' + index_experience + '].tradeName'" -->
  219. <!-- :rules="[-->
  220. <!-- ]">-->
  221. <!-- <el-input v-model="inputForm.detailInfos[index_experience].tradeName" placeholder="请选择物品名称" @focus="showGoods(index_experience)" clearable></el-input>-->
  222. <!-- </u-form-item>-->
  223. <u-form-item label="商品单价(元)" :prop="'detailInfos[' + index_experience + '].tradePrice'" :rules="[
  224. ]">
  225. <el-input @change="changeValue" :disabled="true"
  226. v-model="inputForm.detailInfos[index_experience].tradePrice" placeholder="请输入商品单价(元)"
  227. clearable></el-input>
  228. </u-form-item>
  229. <u-form-item label="商品数量" :prop="'detailInfos[' + index_experience + '].tradeNumber'" :rules="[
  230. ]">
  231. <el-input @change="changeValue" v-model="inputForm.detailInfos[index_experience].tradeNumber"
  232. :disabled="true" placeholder="请输入商品数量" clearable></el-input>
  233. </u-form-item>
  234. <u-form-item label="商品总价" :prop="'detailInfos[' + index_experience + '].priceSum'" :rules="[
  235. ]">
  236. <el-input v-model="inputForm.detailInfos[index_experience].priceSum" :disabled="true"
  237. placeholder="请输入商品总价" clearable></el-input>
  238. </u-form-item>
  239. <u-form-item label="品牌" :prop="'detailInfos[' + index_experience + '].brand'">
  240. <el-input v-model="inputForm.detailInfos[index_experience].brand" :disabled="true"></el-input>
  241. </u-form-item>
  242. <u-form-item label="规格" :prop="'detailInfos[' + index_experience + '].specification'">
  243. <el-input v-model="inputForm.detailInfos[index_experience].specification" :disabled="true"></el-input>
  244. </u-form-item>
  245. <u-form-item label="单位" :prop="'detailInfos[' + index_experience + '].company'" :rules="[
  246. ]">
  247. <el-input v-model="inputForm.detailInfos[index_experience].company" :disabled="true"
  248. placeholder="请输入单位" clearable></el-input>
  249. </u-form-item>
  250. <u-form-item label="备注" :prop="'detailInfos[' + index_experience + '].remarks'" :rules="[
  251. ]">
  252. <el-input v-model="inputForm.detailInfos[index_experience].remarks" :disabled="true"
  253. placeholder="请输入备注" clearable></el-input>
  254. </u-form-item>
  255. <u-form-item label="文件上传" v-if="false">
  256. <!-- <el-upload :disabled="true" class="upload-demo"
  257. :action="`http://cpaoa.xgccpm.com/api/public-modules-server/oss/file/webUpload/upload`"
  258. :on-remove="(file, fileList) => handleRemove(file, fileList, index_experience, 'detail')"
  259. :file-list="inputForm.detailInfos[index_experience].fileInfoLost"
  260. :on-success="(response, file, fileList) => handleUploadSuccess( file, fileList, index_experience, 'detail')"
  261. :limit="3">
  262. <el-button size="small" :disabled="true" type="primary">点击上传</el-button>
  263. <div slot="tip" class="el-upload__tip">只能上传不超过 3 个文件</div>
  264. <template slot="file" slot-scope="{ file }"
  265. v-if="shouldShowFile(file, index_experience, 'detail') || testFlag">
  266. <span @click="handleFileClick(file)">{{ file.name }}</span>
  267. <el-button type="text" icon="el-icon-close"
  268. @click="handleDelete(file, index_experience, 'detail')">✕</el-button>
  269. </template>
  270. </el-upload> -->
  271. <UploadComponent :uploadUrl="`${uploadUrl}/public-modules-server/oss/file/webUpload/upload`"
  272. @onRemove="(file, fileList, fileIndex) => handleRemove(file, fileList, index_experience, fileIndex, 'detail')"
  273. @onSuccess="(file, fileList) => handleUploadSuccess(file, fileList, index_experience, 'detail')"
  274. :fileList="inputForm.detailInfos[index_experience].fileInfoLost" :limit="3"
  275. :isDelete="nodeFlag" :isUpload="nodeFlag">
  276. </UploadComponent>
  277. </u-form-item>
  278. </el-col>
  279. <el-col :span="24" style="text-align: center">
  280. <u-form-item label="">
  281. <el-button style="width: 100%" :disabled="true" type="danger"
  282. @click="removeRow(index_experience)" plain>删除采购详情 {{ index_experience + 1 }}</el-button>
  283. </u-form-item>
  284. </el-col>
  285. </el-row>
  286. <u-form-item label="">
  287. <el-button style="width: 100%" type="primary" :disabled="true" @click="addRow()"
  288. plain>新增采购详情</el-button>
  289. </u-form-item>
  290. <u-form-item label="附件" v-if="false">
  291. <!-- <el-upload :disabled="true" class="upload-demo"
  292. :action="`http://cpaoa.xgccpm.com/api/public-modules-server/oss/file/webUpload/upload`"
  293. :on-remove="(file, fileList) => handleRemove(file, fileList, '', '')" :file-list="inputForm.files"
  294. :on-success="(response, file, fileList) => handleUploadSuccess(response, file, fileList, '', '')"
  295. :limit="3">
  296. <el-button size="small" :disabled="true" type="primary">点击上传</el-button>
  297. <div slot="tip" class="el-upload__tip">只能上传不超过 3 个文件</div>
  298. <template slot="file" slot-scope="{ file }" v-if="shouldShowFile(file) || testFlag">
  299. <span @click="handleFileClick(file)">{{ file.name }}</span>
  300. <el-button type="text" icon="el-icon-close" @click="handleDelete(file)">✕</el-button>
  301. </template>
  302. </el-upload> -->
  303. <UploadComponent :uploadUrl="`${uploadUrl}/public-modules-server/oss/file/webUpload/upload`"
  304. @onRemove="(file, fileList, fileIndex) => handleRemove(file, fileList, '', fileIndex, '')"
  305. @onSuccess="(file, fileList) => handleUploadSuccess(file, fileList, '', '')"
  306. :fileList="inputForm.files" :limit="3" :isDelete="nodeFlag" :isUpload="nodeFlag">
  307. </UploadComponent>
  308. </u-form-item>
  309. </u--form>
  310. <user-select ref="userPicker" @input="handleEvent"></user-select>
  311. <ba-tree-picker ref="treePicker" :multiple='false' @select-change="selectChange" title="类型选择"
  312. :localdata="listData" valueKey="value" textKey="label" childrenKey="children" />
  313. </view>
  314. </template>
  315. <script>
  316. import userSelect from '@/components/user-select/user-select-radio.vue'
  317. import OSSService from "@/api/sys/OSSService"
  318. import PsiGoodsSelector from '../components/PsiGoodsSelector.vue';
  319. import MaterialTypeService from '@/api/psi/MaterialTypeService'
  320. import MaterialManagementService from '@/api/psi/MaterialManagementService'
  321. import CommonApi from '@/api/common/CommonApi'
  322. import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue"
  323. import { mapState, mapMutations, mapActions } from 'vuex'
  324. import registerService from '@/api/human/register/RegisterService'
  325. import UploadComponent from '@/pages/common/UploadComponent.vue';
  326. import upload from '@/utils/upload.js'
  327. export default {
  328. components: {
  329. userSelect,
  330. baTreePicker,
  331. PsiGoodsSelector,
  332. UploadComponent
  333. },
  334. computed: mapState({
  335. userInfo: (state) => state.user.userInfo,
  336. avatar: (state) => state.user.avatar
  337. }),
  338. data() {
  339. return {
  340. uploadUrl: upload.UPLOAD_URL,
  341. showFileList: [], // 控制每个文件是否显示的数组
  342. showFileList2: [], // 控制每个文件是否显示的数组
  343. testFlag: false,
  344. nodeFlag: false,
  345. loading: false,
  346. listData: [],
  347. fileList3: [],
  348. materialList: [],
  349. inputForm: {
  350. tradeTotalPrice: '',
  351. fileInfoLost: [],
  352. purchaseNo: '',
  353. purchaseSketch: '',
  354. handledBy: '',
  355. handledById: '',
  356. handledByOffice: '',
  357. handledByOfficeName: '',
  358. userId: '',
  359. purchaseDate: '',
  360. purchaseMode: '',
  361. remarks: '',
  362. detailInfos: [],
  363. files: [], // 附件信息
  364. procInsId: '',
  365. processDefinitionId: '',
  366. status: ''
  367. },
  368. rules: {
  369. 'purchaseDate': [
  370. {
  371. required: true,
  372. message: '采购申请时间不能为空',
  373. trigger: ['blur', 'change']
  374. }
  375. ],
  376. 'purchaseSketch': [
  377. {
  378. required: true,
  379. message: '采购名称不能为空',
  380. trigger: ['blur', 'change']
  381. }
  382. ],
  383. 'purchaseMode': [
  384. {
  385. required: true,
  386. message: '采购方式不能为空',
  387. trigger: ['blur', 'change']
  388. }
  389. ],
  390. }
  391. }
  392. },
  393. materialTypeService: null,
  394. materialManagementService: null,
  395. ossService: null,
  396. commonApi: null,
  397. // 页面加载时执行
  398. created() {
  399. this.ensureServices()
  400. this.materialTypeService.cgList().then((data) => {
  401. this.materialList = data
  402. }).catch((e) => {
  403. throw e
  404. })
  405. this.inputForm.handledBy = this.userInfo.name
  406. this.inputForm.handledById = this.userInfo.id
  407. this.inputForm.userId = this.userInfo.id
  408. this.inputForm.handledByOffice = this.userInfo.officeDTO.id
  409. this.inputForm.handledByOfficeName = this.userInfo.officeDTO.name
  410. if (!this.inputForm.purchaseSketch) {
  411. this.inputForm.purchaseSketch = `${this.inputForm.handledBy} ${this.formatDate(new Date())} 申请`
  412. }
  413. // 监听事件
  414. uni.$on('eventName', (data) => {
  415. // 在这里处理传递过来的数据
  416. //循环遍历采购详情,估计index将用户id与用户名称放入到采购人里面
  417. this.inputForm.detailInfos.forEach((detail, index) => {
  418. if (index === parseInt(data.index)) {
  419. detail.purchaserAgent = data.name
  420. detail.purchaserAgentId = data.id
  421. detail.procurementOffice = data.officeDTO.name
  422. }
  423. })
  424. });
  425. },
  426. props: {
  427. businessId: {
  428. type: String,
  429. default: ''
  430. },
  431. formReadOnly: {
  432. type: Boolean,
  433. default: false
  434. },
  435. status: {
  436. type: String,
  437. default: ''
  438. }
  439. },
  440. watch: {
  441. 'businessId': {
  442. handler(newVal) {
  443. if (this.businessId) {
  444. this.init(this.businessId)
  445. } else {
  446. this.$nextTick(() => {
  447. // this.$refs.inputForm.reset()
  448. })
  449. }
  450. },
  451. immediate: true,
  452. deep: false
  453. }
  454. },
  455. methods: {
  456. ensureServices() {
  457. if (!this.commonApi) {
  458. this.commonApi = new CommonApi()
  459. }
  460. if (!this.materialTypeService) {
  461. this.materialTypeService = new MaterialTypeService()
  462. }
  463. if (!this.materialManagementService) {
  464. this.materialManagementService = new MaterialManagementService()
  465. }
  466. if (!this.ossService) {
  467. this.ossService = new OSSService()
  468. }
  469. },
  470. // 显示选择器
  471. showPicker(index) {
  472. this.$refs.treePicker._show(index);
  473. },
  474. //鐩戝惉閫夋嫨
  475. selectChange(ids, names, index) {
  476. this.$set(this.inputForm.detailInfos, index, {
  477. ...this.inputForm.detailInfos[index],
  478. procurementType: names,
  479. procurementTypeId: ids[0],
  480. tradeName: '',
  481. goodsName: '',
  482. tradePrice: '',
  483. tradeNumber: '',
  484. priceSum: '',
  485. company: '',
  486. brand: '',
  487. specification: '',
  488. spec: '1',
  489. surplusNumber: ''
  490. });
  491. },
  492. handleGoodsSelected({ index, item }) {
  493. const tradeName = item.tradeName || item.name || ''
  494. const categoryId = this.inputForm.detailInfos[index] && this.inputForm.detailInfos[index].procurementTypeId
  495. const exists = this.inputForm.detailInfos.some((detail, detailIndex) => {
  496. if (String(detailIndex) === String(index)) {
  497. return false
  498. }
  499. return String(detail.procurementTypeId || '') === String(categoryId || '') &&
  500. String(detail.tradeName || '') === String(tradeName || '')
  501. })
  502. if (exists) {
  503. uni.showToast({
  504. title: '同种商品只能选择一次',
  505. icon: 'none'
  506. })
  507. return
  508. }
  509. this.$set(this.inputForm.detailInfos, index, {
  510. ...this.inputForm.detailInfos[index],
  511. tradeName,
  512. goodsName: tradeName,
  513. brand: item.brand || '',
  514. specification: item.specification || '',
  515. company: item.company || this.inputForm.detailInfos[index].company || '',
  516. spec: '1',
  517. surplusNumber: item.currentInventory || item.tradeNumber || item.surplusNumber || ''
  518. });
  519. },
  520. init(id) {
  521. this.ensureServices()
  522. this.nodeFlag = true
  523. this.inputForm.id = id
  524. if (id) {
  525. console.log(id);
  526. this.materialManagementService.findById(id).then((data) => {
  527. if (this.status === 'testSee') {
  528. this.nodeFlag = true
  529. } else {
  530. this.commonApi.getTaskNameByProcInsId(data.procInsId).then((data) => {
  531. if (this.isNotEmpty(data)) {
  532. if (data === '发起人重新申请' || this.isEmpty(data)) {
  533. this.nodeFlag = false
  534. } else {
  535. this.nodeFlag = true
  536. }
  537. }
  538. })
  539. }
  540. this.inputForm = this.recover(this.inputForm, data)
  541. this.inputForm.purchaseDate = new Date(data.purchaseDate);
  542. if (this.inputForm.files) {
  543. this.inputForm.files.forEach((item, index) => {
  544. this.$set(this.showFileList, index, true);
  545. })
  546. }
  547. this.inputForm.detailInfos.forEach((item, index) => {
  548. if (this.isNotEmpty(item.fileInfoLost)) {
  549. this.fileList3[index] = []
  550. item.fileInfoLost.forEach((item, index2) => {
  551. this.fileList3[index].push(item)
  552. this.$set(this.showFileList2, index2, true);
  553. })
  554. }
  555. this.inputForm.detailInfos[index].priceSum = parseFloat(parseFloat(this.inputForm.detailInfos[index].tradePrice)
  556. * parseFloat(this.inputForm.detailInfos[index].tradeNumber)).toFixed(2)
  557. })
  558. this.calculateTradeTotalPrice()
  559. })
  560. }
  561. },
  562. buildTree(nodes, parentId = '0') {
  563. const tree = [];
  564. for (const node of nodes) {
  565. if (String(node.infoType || node.info_type || '') === '1') {
  566. continue
  567. }
  568. if (node.parentId === parentId) {
  569. const children = this.buildTree(nodes, node.id);
  570. if (children.length) {
  571. node.children = children;
  572. }
  573. tree.push(node);
  574. }
  575. }
  576. return tree;
  577. },
  578. formatDate(date) {
  579. const dateNew = new Date(date); // 将日期字符串转换为 Date 对象
  580. const year = dateNew.getFullYear();
  581. const month = (dateNew.getMonth() + 1).toString().padStart(2, '0');
  582. const day = dateNew.getDate().toString().padStart(2, '0');
  583. return `${year}-${month}-${day}`;
  584. },
  585. isEmpty(value) {
  586. let result = false;
  587. if (value == null || value == undefined) {
  588. result = true;
  589. }
  590. if (typeof value == 'string' && (value.replace(/\s+/g, "") == "" || value == "")) {
  591. result = true;
  592. }
  593. if (typeof value == "object" && value instanceof Array && value.length === 0) {
  594. result = true;
  595. }
  596. return result;
  597. },
  598. isNotEmpty(value) {
  599. return !this.isEmpty(value)
  600. },
  601. /**
  602. * 判断是否为空
  603. */
  604. isNull(val) {
  605. if (val instanceof Array) {
  606. if (val.length === 0) return true;
  607. } else if (val instanceof Object) {
  608. if (JSON.stringify(val) === "{}") return true;
  609. } else {
  610. if (
  611. val === "null" ||
  612. val == null ||
  613. val === "undefined" ||
  614. val === undefined ||
  615. val === ""
  616. )
  617. return true;
  618. return false;
  619. }
  620. return false;
  621. },
  622. addRow() {
  623. // 点击新增按钮时,向表格中添加一行空数据
  624. this.inputForm.detailInfos.push({
  625. purchaserAgent: this.userInfo.name,
  626. purchaserAgentId: this.userInfo.id,
  627. procurementOffice: this.userInfo.officeDTO.name,
  628. deptId: this.userInfo.officeDTO.id,
  629. procurementType: '',
  630. procurementTypeId: '',
  631. tradeName: '',
  632. goodsName: '',
  633. tradePrice: '',
  634. tradeNumber: '',
  635. priceSum: '',
  636. company: '',
  637. brand: '',
  638. specification: '',
  639. spec: '1',
  640. surplusNumber: '',
  641. remarks: '',
  642. fileInfoLost: []
  643. });
  644. let valueData = this.materialList;
  645. // 将扁平数据转换为树形结构
  646. const result = this.buildTree(valueData);
  647. this.listData = result
  648. },
  649. calculateTradeTotalPrice() {
  650. this.inputForm.tradeTotalPrice = this.inputForm.detailInfos.reduce((total, item) => {
  651. return total + parseFloat(item.priceSum || 0);
  652. }, 0).toFixed(2)
  653. },
  654. removeRow(index) {
  655. // 点击删除按钮时,从表格中移除指定行
  656. // this.tableData.splice(index, 1);
  657. this.inputForm.detailInfos.splice(index, 1);
  658. },
  659. formatDateNew(date) {
  660. const year = date.getFullYear();
  661. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  662. const day = date.getDate().toString().padStart(2, '0');
  663. const hours = date.getHours().toString().padStart(2, '0');
  664. const minutes = date.getMinutes().toString().padStart(2, '0');
  665. const seconds = date.getSeconds().toString().padStart(2, '0');
  666. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  667. },
  668. // 采购人下拉弹窗
  669. openUserPullForm(index) {
  670. // 点击 "采购人" 输入框时打开userPullForm页面,传入index用于区分不同的行
  671. // uni.navigateTo({
  672. // url: '/pages/materialManagement/collect/UserPullForm?index=' + index // userPullForm页面的路径
  673. // });
  674. this.$refs.userPicker.open(index, "");
  675. },
  676. handleEvent(data, index, type) {
  677. // 在这里处理子组件传递过来的数据
  678. this.inputForm.detailInfos[index].purchaserAgentId = data.id
  679. this.inputForm.detailInfos[index].purchaserAgent = data.label
  680. this.inputForm.detailInfos[index].procurementOffice = data.parentLabel
  681. this.inputForm.detailInfos[index].deptId = data.parentId
  682. // 进行进一步处理...
  683. },
  684. handleUploadSuccess(file, fileList, index, type) {
  685. if (type === 'detail') {
  686. // 将格式化后的数据设置到 detailInfos 的 fileInfoLost 属性中
  687. this.inputForm.detailInfos[index].fileInfoLost = fileList;
  688. // 遍历 fileList,找到上传成功的文件,设置对应索引的 showFileList2 为 true
  689. fileList.forEach((item, i) => {
  690. if (item === file) {
  691. this.$set(this.showFileList2, i, true);
  692. }
  693. });
  694. } else {
  695. // this.inputForm.files = fileList
  696. fileList.forEach((item, index) => {
  697. if (item === file) {
  698. this.$set(this.showFileList, index, true);
  699. }
  700. });
  701. console.log(this.inputForm.files);
  702. }
  703. // 强制更新视图
  704. this.$forceUpdate();
  705. },
  706. handleRemove(file, fileList, lineIndex, fileindex, type) {
  707. // 处理移除文件逻辑
  708. // file 是移除的文件
  709. // fileList 是当前文件列表
  710. if (type === 'detail') {
  711. this.inputForm.detailInfos[lineIndex].fileInfoLost.splice(fileindex, 1);
  712. this.showFileList2.splice(fileindex, 1); // 从showFileList中移除对应的元素
  713. } else {
  714. this.inputForm.files.splice(fileindex, 1);
  715. this.showFileList.splice(fileindex, 1); // 从showFileList中移除对应的元素
  716. }
  717. // 如果你想要更新文件列表,可以在这里更新 inputForm.fileInfoLost
  718. // this.inputForm.fileInfoLost = fileList;
  719. },
  720. saveForm(callback) {
  721. return new Promise((resolve, reject) => {
  722. // 表单规则验证
  723. // ...
  724. let errors = [];
  725. if (this.isNotEmpty(this.inputForm.purchaseDate)) {
  726. this.inputForm.purchaseDate = this.formatDate(this.inputForm.purchaseDate);
  727. }
  728. if (this.isEmpty(this.inputForm.detailInfos)) {
  729. errors.push('至少填写一条采购详情信息');
  730. } else {
  731. let i = this.inputForm.detailInfos.length;
  732. for (let j = 0; j < i; j++) {
  733. let k = j + 1
  734. if (this.isEmpty(this.inputForm.detailInfos[j].purchaserAgent)) {
  735. this.$message.error('采购详情第' + k + '行请选择采购人')
  736. this.loading = false
  737. return
  738. }
  739. if (this.isEmpty(this.inputForm.detailInfos[j].procurementType)) {
  740. this.$message.error('采购详情第' + k + '行请选择采购类型')
  741. this.loading = false
  742. return
  743. }
  744. if (this.isEmpty(this.inputForm.detailInfos[j].tradeName)) {
  745. this.$message.error('采购详情第' + k + '行请填写商品名称')
  746. this.loading = false
  747. return
  748. }
  749. }
  750. for (let j = 0; j < i; j++) {
  751. for (let k = j + 1; k < i; k++) {
  752. if (this.inputForm.detailInfos[j].procurementType === this.inputForm.detailInfos[k].procurementType) { // 如果采购类型相同
  753. if (this.inputForm.detailInfos[j].tradeName === this.inputForm.detailInfos[k].tradeName) { // 如果商品名称相同
  754. this.$message.warning(`采购详情中,同种采购类型的商品名称只能输入一条`)
  755. this.loading = false
  756. throw new Error('采购详情中,同种采购类型的商品名称只能输入一条')
  757. }
  758. }
  759. }
  760. }
  761. }
  762. // 计算总价
  763. this.calculateTradeTotalPrice()
  764. if (errors.length > 0) {
  765. // 存在错误,显示提示信息
  766. errors.forEach(error => {
  767. uni.showToast({
  768. title: error,
  769. icon: 'none',
  770. duration: 2000
  771. });
  772. });
  773. reject('Form validation failed');
  774. } else {
  775. // 所有验证通过,执行保存操作
  776. this.$refs.inputForm.validate().then(() => {
  777. uni.showLoading();
  778. this.inputForm.status = '1';
  779. this.materialManagementService.save(this.inputForm).then(data => {
  780. callback(data.businessTable, data.businessId);
  781. resolve('Form saved successfully');
  782. }).catch(error => {
  783. reject('Save operation failed');
  784. });
  785. }).catch(() => {
  786. reject('Form validation failed');
  787. });
  788. }
  789. });
  790. },
  791. // 修改状态
  792. async updateStatusById(type, callback) {
  793. if (type === 'reject' || type === 'reback') {
  794. this.materialManagementService.findById(this.inputForm.id).then((data) => {
  795. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  796. this.loading = false
  797. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  798. throw new Error()
  799. } else {
  800. if (type === 'reject') {
  801. // 驳回
  802. this.inputForm.status = '4'
  803. }
  804. if (type === 'reback') {
  805. // 撤回
  806. this.inputForm.status = '3'
  807. }
  808. if (type === 'reject' || type === 'reback') {
  809. let param = { status: this.inputForm.status, id: this.inputForm.id }
  810. this.materialManagementService.updateStatusById(param).then(() => {
  811. this.loading = false
  812. callback()
  813. })
  814. }
  815. }
  816. })
  817. } else if (type === 'hold') {
  818. this.materialManagementService.findById(this.inputForm.id).then((data) => {
  819. if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
  820. this.loading = false
  821. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  822. throw new Error()
  823. } else {
  824. // 终止
  825. let param = { status: '1', id: this.inputForm.id }
  826. this.materialManagementService.updateStatusById(param).then(() => {
  827. this.loading = false
  828. callback()
  829. })
  830. }
  831. })
  832. }
  833. },
  834. reapplyForm(callback) {
  835. this.loading = true
  836. this.materialManagementService.findById(this.inputForm.id).then((data) => {
  837. if (data.status !== '4') { // 审核状态不是“驳回”,就弹出提示
  838. this.loading = false
  839. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  840. throw new Error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  841. } else {
  842. this.startFormTrue(callback)
  843. }
  844. })
  845. },
  846. // 送审
  847. async startFormTrue(callback) {
  848. if (this.isNotEmpty(this.inputForm.purchaseDate)) {
  849. this.inputForm.purchaseDate = this.formatDate(this.inputForm.purchaseDate);
  850. }
  851. this.$refs.inputForm.validate().then(res => {
  852. this.inputForm.status = '2'
  853. this.calculateTradeTotalPrice()
  854. this.materialManagementService.save(this.inputForm).then((data) => {
  855. this.inputForm.id = data.businessId
  856. callback(data.businessTable, data.businessId, this.inputForm)
  857. this.$refs.inputForm.resetFields()
  858. this.loading = false
  859. }).catch(() => {
  860. this.$refs.inputForm.resetFields()
  861. }).catch((e) => {
  862. })
  863. })
  864. },
  865. // 通过
  866. async agreeForm(callback) {
  867. if (this.isNotEmpty(this.inputForm.purchaseDate)) {
  868. this.inputForm.purchaseDate = this.formatDate(this.inputForm.purchaseDate);
  869. }
  870. this.$refs.inputForm.validate().then(res => {
  871. this.calculateTradeTotalPrice()
  872. this.commonApi.getTaskNameByProcInsId(this.inputForm.procInsId).then((data) => {
  873. if (this.isNotEmpty(data)) {
  874. if (data === '领导审批') {
  875. this.inputForm.status = '5'
  876. }
  877. }
  878. this.materialManagementService.save(this.inputForm).then((data) => {
  879. callback(data.businessTable, data.businessId, this.inputForm)
  880. this.$refs.inputForm.resetFields()
  881. this.loading = false
  882. }).catch(() => {
  883. this.loading = false
  884. this.$refs.inputForm.resetFields()
  885. })
  886. })
  887. })
  888. },
  889. // 值改变事件
  890. changeValue() {
  891. let i = this.inputForm.detailInfos.length
  892. for (let j = 0; j < i; j++) {
  893. if (this.isNotEmpty(this.inputForm.detailInfos[j].tradePrice)) {
  894. if (this.isNotEmpty(this.inputForm.detailInfos[j].tradeNumber)) {
  895. // parseFloat(item.account).toFixed(2)
  896. this.inputForm.detailInfos[j].priceSum = parseFloat(parseFloat(this.inputForm.detailInfos[j].tradePrice) * parseFloat(this.inputForm.detailInfos[j].tradeNumber)).toFixed(2)
  897. } else {
  898. this.inputForm.detailInfos[j].priceSum = ''
  899. }
  900. } else {
  901. this.inputForm.detailInfos[j].priceSum = ''
  902. }
  903. }
  904. this.calculateTradeTotalPrice()
  905. },
  906. async handleFileClick(file) {
  907. await this.ossService.getTemporaryUrl(file.url).then((data) => {
  908. file.lsUrl = data
  909. })
  910. if (this.isImage(file.name)) {
  911. // 如果是图片文件,则执行放大显示图片的逻辑
  912. this.handleImageClick(file);
  913. } else {
  914. // window.open(file.lsUrl, '_blank')
  915. window.location.href = file.lsUrl
  916. // 如果不是图片文件,则执行其他操作,比如下载文件等
  917. }
  918. },
  919. // 判断文件是否是图片类型
  920. isImage(fileName) {
  921. const ext = fileName.toLowerCase().split('.').pop(); // 获取文件的后缀名
  922. return ['jpg', 'jpeg', 'png', 'gif', 'bmp'].includes(ext); // 判断后缀名是否是图片类型
  923. },
  924. handleImageClick(file) {
  925. // 在点击图片时执行放大显示的逻辑
  926. this.$alert(`<img src="${file.lsUrl}" style="max-width: 100%; max-height: 100%;" />`, '图片详情', {
  927. dangerouslyUseHTMLString: true,
  928. customClass: 'custom-alert'
  929. });
  930. },
  931. handleDelete(file, lineIndex, type) {
  932. // 处理删除文件的逻辑
  933. if (type === 'detail') {
  934. const index = this.inputForm.detailInfos[lineIndex].fileInfoLost.indexOf(file);
  935. if (index !== -1) {
  936. this.inputForm.detailInfos[lineIndex].fileInfoLost.splice(index, 1);
  937. this.showFileList2.splice(index, 1); // 从showFileList中移除对应的元素
  938. }
  939. } else {
  940. // 从文件列表中移除文件
  941. const index = this.inputForm.files.indexOf(file);
  942. if (index !== -1) {
  943. this.inputForm.files.splice(index, 1);
  944. this.showFileList.splice(index, 1); // 从showFileList中移除对应的元素
  945. }
  946. }
  947. },
  948. shouldShowFile(file, index, type) {
  949. if (type === 'detail') {
  950. if (this.inputForm.detailInfos[index].fileInfoLost && this.inputForm.detailInfos[index].fileInfoLost.length > 0) {
  951. // 返回一个布尔值,确定是否显示上传成功后的文件
  952. return this.showFileList2[this.inputForm.detailInfos[index].fileInfoLost.indexOf(file)];
  953. }
  954. } else {
  955. if (this.inputForm.files && this.inputForm.files.length > 0) {
  956. // 返回一个布尔值,确定是否显示上传成功后的文件
  957. return this.showFileList[this.inputForm.files.indexOf(file)];
  958. }
  959. }
  960. return false; // 默认返回 false 或者其他适当的
  961. },
  962. onInputCode(index, event, type) {
  963. const inputValue = event
  964. const formattedValue = this.formatInput(inputValue);
  965. if (type === 'tradePrice') {
  966. this.$set(this.inputForm.detailInfos[index], 'tradePrice', formattedValue)
  967. }
  968. if (type === 'tradeNumber') {
  969. this.$set(this.inputForm.detailInfos[index], 'tradeNumber', formattedValue)
  970. }
  971. if (this.isNotEmpty(this.inputForm.detailInfos[index].tradePrice && this.inputForm.detailInfos[index].tradeNumber)) {
  972. let priceSum =
  973. parseFloat(parseFloat(this.inputForm.detailInfos[index].tradePrice) * parseFloat(this.inputForm.detailInfos[index].tradeNumber)).toFixed(2)
  974. this.$set(this.inputForm.detailInfos[index], 'priceSum', priceSum)
  975. }
  976. this.calculateTradeTotalPrice()
  977. },
  978. // 通用的输入限制和格式化方法
  979. formatInput(inputValue, decimalLimit = 2) {
  980. console.log('inputValue', inputValue)
  981. // 如果输入值不是数字或者不是有效的小数,则返回空字符串
  982. if (!/^\d*\.?\d*$/.test(inputValue)) {
  983. return '';
  984. }
  985. // 只保留数字和一个小数点
  986. let value = inputValue.replace(/[^\d.]/g, '');
  987. // 只允许一个小数点
  988. const dotIndex = value.indexOf('.');
  989. if (dotIndex !== -1) {
  990. const substr = value.substr(dotIndex + 1);
  991. if (substr.indexOf('.') !== -1) {
  992. value = value.substr(0, dotIndex + 1) + substr.replace(/\./g, '');
  993. }
  994. }
  995. // 限制小数位数为指定的decimalLimit位数
  996. if (dotIndex !== -1) {
  997. const integerPart = value.substring(0, dotIndex);
  998. const decimalPart = value.substring(dotIndex + 1);
  999. if (decimalPart.length > decimalLimit) {
  1000. uni.showToast({
  1001. title: '商品数量小数点后只能输入两位,请正确输入!',
  1002. icon: 'none',
  1003. duration: 2000
  1004. });
  1005. return ''; // 返回空字符串
  1006. }
  1007. value = integerPart + '.' + decimalPart;
  1008. }
  1009. return value;
  1010. },
  1011. }
  1012. }
  1013. </script>
  1014. <style>
  1015. .cu-form-group .title {
  1016. min-width: calc(4em + 40px);
  1017. }
  1018. .custom-alert {
  1019. max-width: 80% !important;
  1020. max-height: 80% !important;
  1021. }
  1022. /* 样式示例,您可能需要根据实际情况调整 */
  1023. .upload-demo {
  1024. width: 40%;
  1025. }
  1026. </style>