add.vue 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814
  1. <template>
  2. <div id="addDemandList">
  3. <el-card style="position: relative;">
  4. <span>基本信息</span>
  5. <el-form :model="basicForm" :rules="basicRules" ref="basic" label-width="auto" :show-message="false">
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="业务类型" prop="billType" :rules="{ required: true, message: '请选择业务类型', trigger: 'blur' }">
  9. <el-select clearable v-model="basicForm.billType" @change="changeBillType" :disabled="sonDisable" size="mini" style="width: 200px">
  10. <el-option v-for=" dict in dict.type.sys_business" :key="dict.value" :label="dict.label" :value="dict.value">
  11. </el-option>
  12. </el-select>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="1.5">
  16. <el-form-item label="需求客户">
  17. <el-select clearable size="mini" v-model="basicForm.customer" :disabled="sonDisable" @clear="cleanCustomer" @focus="chooseOrg('CUSTOMER_PARAM', true, '选择客户')" style="width: 200px">
  18. <el-option v-for="item in customerOptions" :key="item.id" :label="item.name" :value="item.id" />
  19. </el-select>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="1.5">
  23. <el-form-item label="需求人员">
  24. <el-select clearable size="mini" v-model="basicForm.demandPersonal" :disabled="sonDisable" @focus="chooseOrg('CONTACTS_PARAM', true, '需求人员')" style="width: 200px">
  25. <el-option v-for="item in personOptions" :key="item.id" :label="item.name" :value="item.code" />
  26. </el-select>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-form-item label="需求部门">
  31. <el-select clearable v-model="basicForm.demandDept" size="mini" :disabled="sonDisable" @focus="chooseOrg('DEPT_PARAM', true, '需求部门')" style="width: 200px">
  32. <el-option
  33. v-for="item in deptOptions"
  34. :key="item.id"
  35. :label="item.name"
  36. :value="item.id">
  37. </el-option>
  38. </el-select>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="1.5">
  42. <el-form-item label="需求计划" prop="planType" :rules="{ required: true, message: '请选择需求计划', trigger: 'blur' }">
  43. <el-select :disabled="sonDisable" v-model="basicForm.planType" size="mini" style="width: 200px" @change="changeplanType()">
  44. <el-option v-for="dict in dict.type.sys_plan_type" :key="dict.value" :label="dict.label" :value="dict.value">
  45. </el-option>
  46. </el-select>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-form-item label="需求日期" prop="demandDate" :rules="{ required: true, message: '请选择需求日期', trigger: 'blur' }">
  51. <el-date-picker
  52. v-model="basicForm.demandDate"
  53. disabled
  54. clearable
  55. type="date"
  56. value-format="yyyy-MM-dd"
  57. @change="changeDemandDate"
  58. size="mini"
  59. style="width: 200px"
  60. >
  61. </el-date-picker>
  62. </el-form-item>
  63. </el-col>
  64. <el-col :span="1.5">
  65. <el-form-item label="制单日期" prop="createTime">
  66. <el-date-picker
  67. v-model="basicForm.createTime"
  68. disabled
  69. clearable
  70. type="date"
  71. value-format="yyyy-MM-dd"
  72. size="mini"
  73. style="width: 200px"
  74. >
  75. </el-date-picker>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-form-item label="是否客户指定">
  80. <el-select clearable @change="isCustomer" v-model="basicForm.isCustomerSpecified" :disabled="sonDisable" size="mini" style="width: 200px">
  81. <el-option v-for=" item in options" :key="item.value" :label="item.label" :value="item.value">
  82. </el-option>
  83. </el-select>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="1.5">
  87. <el-form-item label="备注">
  88. <el-input
  89. v-model.trim="basicForm.remark"
  90. size="mini"
  91. :disabled="sonDisable"
  92. clearable
  93. style="width: 200px"
  94. />
  95. </el-form-item>
  96. </el-col>
  97. <!-- <el-col :span="1.5">
  98. <el-form-item label="需求客户名称">
  99. <el-input disabled v-model="basicForm.customerName" size="mini" style="width: 200px"></el-input>
  100. </el-form-item>
  101. </el-col> -->
  102. <el-col :span="1.5">
  103. <el-form-item label="需求单号">
  104. <el-input
  105. v-model="basicForm.code"
  106. size="mini"
  107. disabled
  108. style="width: 200px"
  109. />
  110. </el-form-item>
  111. </el-col>
  112. <!-- <el-col :span="1.5">
  113. <el-form-item label="组织" prop="org" :rules="{ required: true, message: '请选择组织', trigger: 'blur' }">
  114. <el-select clearable size="mini" v-model="basicForm.org" :disabled="sonDisable" @focus="chooseOrg('ORG_PARAM', true, '选择组织')" style="width: 200px">
  115. <el-option v-for="item in orgOptions" :key="item.id" :label="item.name" :value="item.id" />
  116. </el-select>
  117. </el-form-item>
  118. </el-col> -->
  119. <el-col :span="1.5">
  120. <el-form-item label="单据状态">
  121. <el-select disabled v-model="basicForm.status" size="mini" style="width: 200px">
  122. <el-option v-for="dict in dict.type.sys_status" :key="dict.value" :label="dict.label" :value="dict.value">
  123. </el-option>
  124. </el-select>
  125. </el-form-item>
  126. </el-col>
  127. <el-col :span="1.5">
  128. <el-form-item label="客户负责人">
  129. <el-select disabled size="mini" v-model="basicForm.customerPrincipal" style="width: 200px">
  130. <el-option v-for="item in manOptions" :key="item.id" :label="item.name" :value="item.code"/>
  131. </el-select>
  132. </el-form-item>
  133. </el-col>
  134. <el-col :span="1.5">
  135. <el-form-item label="单据来源">
  136. <el-select v-model="basicForm.source" disabled size="mini" style="width: 200px">
  137. <el-option v-for="dict in dict.type.sys_bill_source" :key="dict.value" :label="dict.label" :value="dict.value">
  138. </el-option>
  139. </el-select>
  140. </el-form-item>
  141. </el-col>
  142. </el-row>
  143. <div class="btn_grooup">
  144. <span>明细信息</span>
  145. <div>
  146. <el-button type="primary" size="mini" @click="addLine" v-if="!sonDisable">增行</el-button>
  147. <el-button type="primary" size="mini" v-if="!sonDisable" @click.stop="adjustPl">批量调整</el-button>
  148. <el-button type="primary" size="mini" v-if="sonPageStu == 'check' || sonPageStu == 'edit'" @click="showReserved">货权预留单</el-button>
  149. </div>
  150. </div>
  151. <ux-grid
  152. v-loading="loading"
  153. :data="basicForm.puDemandItemList"
  154. border
  155. :cell-style="{ borderColor: '#c0c0c0' }"
  156. :header-cell-style="{ borderColor: '#c0c0c0' }"
  157. class="exporttable"
  158. height="410"
  159. max-height="410"
  160. style="font-size: 12px;"
  161. @selection-change="handleSelectionChange"
  162. :cell-class-name="cellClassName"
  163. ref="table"
  164. :rules="tableRules"
  165. show-header-overflow="tooltip"
  166. show-overflow="tooltip"
  167. keep-source
  168. beautifyTable
  169. :checkbox-config="{highlight: true, trigger: 'row'}"
  170. :edit-config="{trigger: 'click', mode: 'row'}"
  171. :validConfig="{autoPos: true}">
  172. >
  173. <ux-table-column resizable type="checkbox" fixed="left"/>
  174. <ux-table-column resizable title="序号" type="index" align="center" width="50px"/>
  175. <ux-table-column resizable title="行号" align="center" field="rowNo" width="50px">
  176. <template v-slot:edit="scope">
  177. {{ scope.row.rowNo = scope.rowIndex + 1 + "0" }}
  178. </template>
  179. </ux-table-column>
  180. <ux-table-column resizable title="默认采购组织" align="center" field="purOrgName" width="100px"/>
  181. <ux-table-column resizable title="需求客户" align="center" field="demandCustomerName" width="100px"/>
  182. <ux-table-column resizable title="行状态" align="center" field="status" :formatter="hangStatus" width="100px"/>
  183. <ux-table-column resizable title="物料编码" align="center" field="materialCode" width="150px" :render-header="addRedStar" :edit-render="{autofocus: '.el-input__inner'}">
  184. <template v-slot:edit="scope">
  185. <el-input clearable :disabled="sonDisable" size="mini" v-model="scope.row.materialCode" @paste.native="pasteMe($event, scope, scope.rowIndex)">
  186. <el-button size="mini" :disabled="sonDisable" slot="append" icon="el-icon-more" @click="chooseMaterial(scope.rowIndex)"></el-button>
  187. </el-input>
  188. </template>
  189. </ux-table-column>
  190. <ux-table-column resizable title="物料名称" align="center" field="materialName" width="100px"/>
  191. <ux-table-column resizable title="规格" align="center" field="specification" width="50px"/>
  192. <ux-table-column resizable title="型号" align="center" field="model" width="50px"/>
  193. <ux-table-column resizable title="单位" align="center" field="unitName" width="50px"/>
  194. <ux-table-column resizable title="生产厂家/代理人" align="center" field="manufacturerName" width="100px"/>
  195. <ux-table-column resizable title="最小包装" align="center" field="minPackage" width="80px"/>
  196. <ux-table-column resizable title="月均销量" align="center" field="averageQtyMonth" width="80px"/>
  197. <ux-table-column resizable title="需求可用周期" align="center" field="demandPeriod" width="80px"/>
  198. <ux-table-column resizable title="实际(业务)需求量" align="center" field="qty" width="150px" :render-header="addRedStar" edit-render>
  199. <template v-slot:edit="scope">
  200. <el-input type="number" min="0" clearable :disabled="sonDisable" size="mini" v-model="scope.row.qty" @input="getYLSL(scope)" @paste.native="pasteMe($event, scope, scope.rowIndex)"/>
  201. </template>
  202. </ux-table-column>
  203. <ux-table-column resizable title="紧急标识" align="center" field="isUrgency" width="100px" edit-render>
  204. <template v-slot:edit="scope">
  205. <el-switch
  206. v-model="scope.row.isUrgency"
  207. :disabled="sonDisable"
  208. active-value="Y"
  209. inactive-value="N"
  210. active-color="#13ce66"
  211. inactive-color="#a1a3a9">
  212. </el-switch>
  213. </template>
  214. <template v-slot="{ row }">{{ row.isUrgency == 'Y' ? '是' : '否' }}</template>
  215. </ux-table-column>
  216. <ux-table-column resizable title="收货仓库" align="center" field="deliveryWarehouseName" width="200px" edit-render>
  217. <template v-slot:edit="scope">
  218. <el-input clearable :disabled="sonDisable" size="mini" v-model="scope.row.deliveryWarehouseName" @clear="clearHang(scope.rowIndex, '选择收货仓库')">
  219. <el-button size="mini" :disabled="sonDisable" slot="append" icon="el-icon-more" @click="chooseCangKu(scope.rowIndex, 'WAREHOUSE_PARAM', true, '选择收货仓库', scope.row.puOrg)"></el-button>
  220. </el-input>
  221. </template>
  222. </ux-table-column>
  223. <ux-table-column resizable title="收货货位" align="center" field="deliveryAllocationName" width="200px" edit-render>
  224. <template v-slot:edit="scope">
  225. <el-input clearable :disabled="sonDisable" size="mini" v-model="scope.row.deliveryAllocationName" @clear="clearHang(scope.rowIndex, '选择收货货位')">
  226. <el-button size="mini" :disabled="sonDisable" slot="append" icon="el-icon-more" @click="choosehuoWei(scope.rowIndex, 'ALLOCATION_PARAM', true, '选择收货货位', scope.row.deliveryWarehouse)"></el-button>
  227. </el-input>
  228. </template>
  229. </ux-table-column>
  230. <ux-table-column resizable title="业务备注" align="center" field="remark" width="150px" edit-render>
  231. <template v-slot:edit="scope">
  232. <el-input clearable :disabled="sonDisable" size="mini" v-model="scope.row.remark"/>
  233. </template>
  234. </ux-table-column>
  235. <ux-table-column resizable title="物料一级分类" align="center" field="materialClassifyOneName" width="100px"/>
  236. <ux-table-column resizable title="物料二级分类" align="center" field="materialClassifyTwoName" width="100px"/>
  237. <ux-table-column resizable title="物料三级分类" align="center" field="materialClassifyThreeName" width="100px"/>
  238. <ux-table-column resizable title="物料四级分类" align="center" field="materialClassifyFourName" width="100px"/>
  239. <ux-table-column resizable title="最小批量" align="center" field="minBatch" width="100px"/>
  240. <ux-table-column resizable title="最小订货量" align="center" field="minOrderQty" width="100px"/>
  241. <ux-table-column resizable title="采购员" align="center" field="buyerName" width="100px"/>
  242. <!-- <ux-table-column resizable title="采购员" align="center" field="buyer"/> -->
  243. <ux-table-column resizable title="采购周期" align="center" field="puPeriod" width="100px"/>
  244. <ux-table-column resizable title="交货日期" align="center" field="deliveryDate" width="230px" edit-render>
  245. <template v-slot:edit="scope">
  246. <el-date-picker
  247. v-model="scope.row.deliveryDate"
  248. :disabled="sonDisable"
  249. clearable
  250. type="date"
  251. size="mini"
  252. value-format="yyyy-MM-dd"
  253. :picker-options="pickerOptionsEnd"
  254. placeholder="选择日期">
  255. </el-date-picker>
  256. </template>
  257. </ux-table-column>
  258. <ux-table-column resizable title="有效期" align="center" field="expiry" width="100px"/>
  259. <ux-table-column resizable title="有效期单位" align="center" field="expiryUnit" width="100px"/>
  260. <ux-table-column resizable title="安全库存" align="center" field="safeStock" width="100px"/>
  261. <ux-table-column resizable title="注册人" align="center" field="registrant" width="100px"/>
  262. <ux-table-column resizable title="预留比例" align="center" field="reservedProportion" width="120px" edit-render>
  263. <template v-slot:edit="scope">
  264. <el-select clearable :disabled="sonDisable" size="mini" v-model="scope.row.reservedProportion" @change="getYLSL(scope)" @clear="cleanYLSL(scope)">
  265. <el-option v-for=" dict in dict.type.sys_reserve_ratio" :key="dict.value" :label="dict.label" :value="dict.value">
  266. </el-option>
  267. </el-select>
  268. </template>
  269. </ux-table-column>
  270. <ux-table-column resizable title="预留周期" align="center" field="reservedPeriod" width="120px" edit-render>
  271. <template v-slot:edit="scope">
  272. <el-input type="number" min="0" clearable :disabled="sonDisable" size="mini" v-model="scope.row.reservedPeriod"></el-input>
  273. </template>
  274. </ux-table-column>
  275. <ux-table-column resizable title="预留数量" align="center" field="reservedQty" width="120px"/>
  276. <ux-table-column resizable title="集团预测分类" align="center" field="forecastClassify" width="120px"/>
  277. <ux-table-column resizable title="近一月需求" align="center" field="onemonthAvgVolume" width="100px"/>
  278. <ux-table-column resizable title="近三月需求" align="center" field="threemonthAvgVolume" width="100px"/>
  279. <ux-table-column resizable title="采购在途" align="center" field="puFreight" width="100px"/>
  280. <ux-table-column resizable title="补单标识" align="center" field="isReplenishment" width="100px" edit-render>
  281. <template v-slot:edit="scope">
  282. <el-switch
  283. v-model="scope.row.isReplenishment"
  284. disabled
  285. active-value="Y"
  286. inactive-value="N"
  287. active-color="#13ce66"
  288. inactive-color="#a1a3a9">
  289. </el-switch>
  290. </template>
  291. <template v-slot="{ row }">{{ row.isReplenishment == 'Y' ? '是' : '否' }}</template>
  292. </ux-table-column>
  293. <ux-table-column resizable title="补单供应商" align="center" field="additionalSupplierName" width="200px" :render-header="anotherRedStar" edit-render>
  294. <template v-slot:edit="scope">
  295. <el-input clearable :disabled="sonDisable || BDZT" size="mini" v-model="scope.row.additionalSupplierName" @clear="clearHang(scope.rowIndex, '选择补单供应商')" @paste.native="pasteMe($event, scope, scope.rowIndex)">
  296. <el-button size="mini" :disabled="sonDisable || BDZT" slot="append" icon="el-icon-more" @click="chooseDept(scope.rowIndex, 'SUPPLIER_PARAM', true, '选择补单供应商')"></el-button>
  297. </el-input>
  298. </template>
  299. </ux-table-column>
  300. <ux-table-column resizable title="末级供应库存组织" align="center" field="lastStockOrgName" width="180px"></ux-table-column>
  301. <ux-table-column resizable title="末级供应仓库" align="center" field="lastWarehouseName" width="150px"/>
  302. <ux-table-column resizable title="末级供应货位" align="center" field="lastAllocationName" width="150px"/>
  303. <ux-table-column resizable title="中心仓可用量" align="center" field="centralWarehouseQty" width="120px"/>
  304. <ux-table-column resizable title="调拨状态" align="center" field="statusAllot" width="100px" edit-render>
  305. <template v-slot:edit="scope">
  306. <el-switch
  307. v-model="scope.row.statusAllot"
  308. :disabled="sonDisable"
  309. active-value="Y"
  310. inactive-value="N"
  311. active-color="#13ce66"
  312. inactive-color="#a1a3a9">
  313. </el-switch>
  314. </template>
  315. <template v-slot="{ row }">{{ row.statusAllot == 'Y' ? '是' : '否' }}</template>
  316. </ux-table-column>
  317. <ux-table-column resizable title="调拨单号" align="center" field="allotCode"></ux-table-column>
  318. <ux-table-column resizable title="调拨占有量" align="center" field="allotQty" width="100px"/>
  319. <ux-table-column resizable title="最终净需求量" align="center" field="resDemandQty" width="120px"/>
  320. <ux-table-column resizable title="最终采购执行数量" align="center" field="executeQty" width="150px">
  321. <template v-slot:edit="scope">
  322. {{ scope.row.executeQty ? scope.row.executeQty : 0 }}
  323. </template>
  324. </ux-table-column>
  325. <ux-table-column resizable title="收货地址" align="center" field="deliveryAddressName" width="200px" edit-render>
  326. <template v-slot:edit="scope">
  327. <el-input clearable :disabled="sonDisable" size="mini" v-model="scope.row.deliveryAddressName" @clear="clearHang(scope.rowIndex, '选择收货地址')" @paste.native="pasteMe($event, scope, scope.rowIndex)">
  328. <el-button size="mini" :disabled="sonDisable" slot="append" icon="el-icon-more" @click="chooseDept(scope.rowIndex, 'ADDRESS_PARAM', true, '选择收货地址')"></el-button>
  329. </el-input>
  330. </template>
  331. </ux-table-column>
  332. <ux-table-column resizable title="联系人" align="center" field="contacts" width="100px"/>
  333. <ux-table-column resizable title="联系人电话" align="center" field="contactsPhone" width="150px"/>
  334. <ux-table-column resizable title="详细地址" align="center" field="address" width="150px"/>
  335. <ux-table-column resizable title="价格类型" align="center" field="priceType" width="120px" edit-render>
  336. <template v-slot:edit="scope">
  337. <el-select clearable :disabled="sonDisable" size="mini" v-model="scope.row.priceType">
  338. <el-option v-for=" dict in dict.type.sys_price_type" :key="dict.value" :label="dict.label" :value="dict.value">
  339. </el-option>
  340. </el-select>
  341. </template>
  342. <template v-slot="{ row }">{{ row.priceType == 'order' ? '订货价' : row.priceType == 'consignment' ? '寄售价' : row.priceType == 'adjusted' ? '调货价' : ''}}</template>
  343. </ux-table-column>
  344. <ux-table-column resizable title="是否客户指定" align="center" field="isCustomerSpecified" width="120px" edit-render>
  345. <template v-slot:edit="scope">
  346. <el-switch
  347. v-model="scope.row.isCustomerSpecified"
  348. disabled
  349. active-value="Y"
  350. inactive-value="N"
  351. active-color="#13ce66"
  352. inactive-color="#a1a3a9">
  353. </el-switch>
  354. </template>
  355. <template v-slot="{ row }">{{ row.isCustomerSpecified == 'Y' ? '是' : '否' }}</template>
  356. </ux-table-column>
  357. <!-- <ux-table-column resizable title="批号锁定标识" align="center" field="isBatchLock" width="100px">
  358. <template v-slot:edit="scope">
  359. <el-form-item class="hang">
  360. <el-switch
  361. v-model="scope.row.isBatchLock"
  362. :disabled="sonDisable"
  363. active-value="Y"
  364. inactive-value="N"
  365. active-color="#13ce66"
  366. inactive-color="#a1a3a9">
  367. </el-switch>
  368. </el-form-item>
  369. </template>
  370. </ux-table-column> -->
  371. <ux-table-column resizable title="采购备注" align="center" field="updateCause" width="100px"/>
  372. <ux-table-column resizable title="可用量" align="center" field="availableQty" width="100px"/>
  373. <ux-table-column
  374. fixed="right"
  375. title="操作"
  376. width="100px"
  377. align="center"
  378. >
  379. <template slot-scope="scope">
  380. <el-button type="text" size="mini" :disabled="sonDisable" @click="delLine(scope.rowIndex, scope.row)">删除</el-button>
  381. </template>
  382. </ux-table-column>
  383. </ux-grid>
  384. </el-form>
  385. <div class="btn_group">
  386. <el-button type="primary" size="mini" @click="jumpOA" v-if="sonPageStu == 'check' && (row.status == '1' || row.status == '2') && basicForm.flowId">流程跳转</el-button>
  387. <el-button type="primary" size="mini" @click="copy" v-if="sonPageStu == 'check'">复制</el-button>
  388. <el-button type="primary" size="mini" @click="editPage" v-if="sonPageStu == 'check' && row.status == '0'">编辑</el-button>
  389. <el-button type="primary" size="mini" @click="save" v-if="sonPageStu == 'add' || sonPageStu == 'edit'">保存</el-button>
  390. <el-button type="primary" size="mini" @click="submit" v-if="sonPageStu == 'check' && (row.status == '0' || row.status == '3')">提交</el-button>
  391. <el-button size="mini" plain @click="back">返回</el-button>
  392. </div>
  393. </el-card>
  394. <Reserved v-if="dialog.config" :isVisible="dialog.config" :info="row" @updateReserved="updateReserved"/>
  395. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  396. <popDialog ref="materialRefer" @doSubmit="selectMaterial" :single="false" />
  397. <!-- 批量调整参数 -->
  398. <el-dialog title="批量调整" :visible.sync="adjust.open" @close="closeEvent" width="38%">
  399. <el-row style="margin-bottom: 10px;">
  400. <el-col :span="6" class="pltzTxt">价格类型</el-col>
  401. <el-col :span="14">
  402. <el-select class="pltzIpt" clearable size="mini" v-model="adjust.priceType">
  403. <el-option v-for=" dict in dict.type.sys_price_type" :key="dict.value" :label="dict.label" :value="dict.value">
  404. </el-option>
  405. </el-select>
  406. </el-col>
  407. </el-row>
  408. <el-row style="margin-bottom: 10px;">
  409. <el-col :span="6" class="pltzTxt">采购员</el-col>
  410. <el-col :span="14">
  411. <el-select class="pltzIpt" clearable size="mini" v-model="adjust.purchaseMan" @focus="chooseOrg('CONTACTS_PARAM', true, '采购员')">
  412. <el-option v-for="item in purchaseManOptions" :key="item.id" :label="item.name" :value="item.code" />
  413. </el-select>
  414. </el-col>
  415. </el-row>
  416. <el-row style="margin-bottom: 10px;">
  417. <el-col :span="6" class="pltzTxt">收货仓库</el-col>
  418. <el-col :span="14">
  419. <el-input class="pltzIpt" clearable size="mini" v-model="adjust.warehouseName" @focus="chooseOrg('WAREHOUSE_PARAM', true, '收货仓库')">
  420. <el-button size="mini" slot="append" icon="el-icon-more" @click="chooseOrg('WAREHOUSE_PARAM', true, '收货仓库')"></el-button>
  421. </el-input>
  422. </el-col>
  423. </el-row>
  424. <el-row style="margin-bottom: 10px;">
  425. <el-col :span="6" class="pltzTxt">收货货位</el-col>
  426. <el-col :span="14">
  427. <el-input class="pltzIpt" clearable size="mini" v-model="adjust.allocationName" @focus="adjustHuoWei('ALLOCATION_PARAM', true, '收货货位', adjust.warehouse)">
  428. <el-button size="mini" slot="append" icon="el-icon-more" @click="adjustHuoWei('ALLOCATION_PARAM', true, '收货货位', adjust.warehouse)"></el-button>
  429. </el-input>
  430. </el-col>
  431. </el-row>
  432. <el-row style="margin-bottom: 10px;">
  433. <el-col :span="6" class="pltzTxt">业务备注</el-col>
  434. <el-col :span="14">
  435. <el-input class="pltzIpt" clearable size="mini" v-model="adjust.remark"/>
  436. </el-col>
  437. </el-row>
  438. <el-row style="margin-bottom: 10px;">
  439. <el-col :span="6" class="pltzTxt">收货地址</el-col>
  440. <el-col :span="14">
  441. <el-input class="pltzIpt" clearable size="mini" v-model="adjust.deliveryAddressName">
  442. <el-button size="mini" slot="append" icon="el-icon-more" @click="chooseOrg('ADDRESS_PARAM', true, '收货地址')"></el-button>
  443. </el-input>
  444. </el-col>
  445. </el-row>
  446. <el-row style="margin-bottom: 10px;">
  447. <el-col :span="6" class="pltzTxt">收货地址编码</el-col>
  448. <el-col :span="14">
  449. <el-input class="pltzIpt" disabled clearable size="mini" v-model="adjust.deliveryAddress"/>
  450. </el-col>
  451. </el-row>
  452. <el-row style="margin-bottom: 10px;">
  453. <el-col :span="6" class="pltzTxt">联系人</el-col>
  454. <el-col :span="14">
  455. <el-input class="pltzIpt" disabled clearable size="mini" v-model="adjust.contacts"/>
  456. </el-col>
  457. </el-row>
  458. <el-row style="margin-bottom: 10px;">
  459. <el-col :span="6" class="pltzTxt">联系人电话</el-col>
  460. <el-col :span="14">
  461. <el-input class="pltzIpt" disabled clearable size="mini" v-model="adjust.contactsPhone"/>
  462. </el-col>
  463. </el-row>
  464. <el-row style="margin-bottom: 10px;">
  465. <el-col :span="6" class="pltzTxt">详细地址</el-col>
  466. <el-col :span="14">
  467. <el-input class="pltzIpt" disabled clearable size="mini" v-model="adjust.address"/>
  468. </el-col>
  469. </el-row>
  470. <div slot="footer">
  471. <el-button size="mini" type="primary" @click="confirmAdjust">确 认</el-button>
  472. <el-button size="mini" @click="adjust.open = false">取 消</el-button>
  473. </div>
  474. </el-dialog>
  475. </div>
  476. </template>
  477. <script>
  478. import Reserved from './reserved.vue'
  479. import Refers from '@/components/Refers/refers.vue'
  480. import {addDemand,getDemandDetail, getDemandSonDetail, editDemand, submitDemand, queryMan, toOA } from '@/api/purchase/purchaseDemand.js'
  481. // 用于回显参照框数据
  482. import {getRefer} from '@/api/purchase/basic.js'
  483. // 明细行选择物料参照
  484. import popDialog from '@/components/PopDialog/index.vue'
  485. import ElTableInfiniteScroll from "el-table-infinite-scroll";
  486. import 'regenerator-runtime/runtime'
  487. export default {
  488. directives: {
  489. "el-table-infinite-scroll": ElTableInfiniteScroll,
  490. },
  491. name: 'addDemandList',
  492. props: ['pageStu','row', 'disable'],
  493. dicts: ['sys_processing_mode', 'sys_plan_type', 'sys_status', 'sys_bill_source', 'sys_business','sys_reserve_ratio', 'sys_period_unit', 'sys_price_type'],
  494. components: {
  495. Reserved,
  496. Refers,
  497. popDialog
  498. },
  499. model: {
  500. prop: 'isList',
  501. event: 'jugislist'
  502. },
  503. data() {
  504. return {
  505. loading: true,
  506. // 不能直接改变props传来的值
  507. sonPageStu: this.pageStu,
  508. sonDisable: this.disable,
  509. // BDZT是补单供应商是否可以编辑条件
  510. BDZT: true,
  511. dialog: {
  512. config: false
  513. },
  514. basicForm: {
  515. code: '',
  516. org: '',
  517. orgName: '',
  518. demandBusinessType: '1',
  519. status: '0',
  520. customer: '',
  521. customerName: '',
  522. customerCode: '',
  523. customerPrincipal: '',
  524. demandPersonal: '',
  525. demandPersonalName: '',
  526. demandDept: '',
  527. demandDeptName: '',
  528. planType: 'ZJH',
  529. demandDate: '',
  530. source: '4',
  531. billType: 'ZQBH',
  532. isCustomerSpecified: 'N',
  533. isProcess: '',
  534. isMonthleyCalculate: '',
  535. createTime: this.parseTime(new Date().getTime()),
  536. remark: '',
  537. puDemandItemList: []
  538. },
  539. delDemandItemList: [],
  540. options: [{
  541. value: 'Y', label: '是',
  542. }, {
  543. value: 'N', label: '否'
  544. }],
  545. basicRules: {},
  546. tableList: [],
  547. referCondition: {
  548. type: '',
  549. isPage: true,
  550. title: '',
  551. },
  552. // referCondition: {
  553. // type: '',
  554. // isPage: true,
  555. // title: '',
  556. // },
  557. tableIndex: null,
  558. ids: [],
  559. orgOptions: [],
  560. manOptions: [],
  561. personOptions: [],
  562. deptOptions: [],
  563. customerOptions: [],
  564. pickerOptionsEnd: {
  565. disabledDate: (time) => {
  566. return time.getTime() < new Date(this.basicForm.demandDate).getTime() - 8.64e7
  567. }
  568. },
  569. isBDXQ: false,
  570. isYl: false,
  571. // 批量调整参数
  572. adjust: {
  573. open: false,
  574. priceType: '',
  575. purchaseMan: '',
  576. purchaseManName: '',
  577. warehouse: '',
  578. warehouseName: '',
  579. allocation: '',
  580. allocationName: '',
  581. remark:'',
  582. deliveryAddress: '',
  583. deliveryAddressName: '',
  584. contacts: '',
  585. contactsPhone: '',
  586. address: ''
  587. },
  588. purchaseManOptions: [],
  589. sonModel: {
  590. rowNo: null,
  591. contacts: null,
  592. id: null,
  593. demandId: null,
  594. status: null,
  595. materialCategory: null,
  596. buyer: null,
  597. buyerName: null,
  598. mateiralClassifyOne: null,
  599. materialClassifyOneName: null,
  600. materialClassifyTwo: null,
  601. materialClassifyTwoName: null,
  602. materialClassifyThree: null,
  603. materialClassifyThreeName: null,
  604. materialClassifyFour: null,
  605. materialClassifyFourName: null,
  606. materialCode: null,
  607. material: null,
  608. materialName: null,
  609. classifyId: null,
  610. specification: null,
  611. unit: null,
  612. unitName: null,
  613. manufacturerName: null,
  614. registrant: null,
  615. puPeriod: null,
  616. expiryUnit: null,
  617. expiry: null,
  618. minPackage: null,
  619. minOrderQty: null,
  620. minBatch: null,
  621. safeStock: null,
  622. averageQtyMonth: null,
  623. qty: null,
  624. adjustmentPersonal: null,
  625. adjustmentTime: null,
  626. manualRegulation: null,
  627. updateCause: null,
  628. reservedProportion: null,
  629. reservedPeriod: null,
  630. reservedQty: null,
  631. demandPeriod: null,
  632. forecastClassify: null,
  633. onemonthAvgVolume: null,
  634. threemonthAvgVolume: null,
  635. puFreight: null,
  636. deliveryDate: null,
  637. isUrgency: 'N',
  638. isReplenishment: 'N',
  639. isBatchLock: 'N',
  640. isCustomerSpecified: '',
  641. remark: null,
  642. puRemark: null,
  643. lastWarehouseQty: null,
  644. resDemandQty: null,
  645. lastWarehouse: null,
  646. lastWarehouseName: null,
  647. deliveryWarehouse: null,
  648. deliveryWarehouseName: null,
  649. lastAllocation: null,
  650. lastAllocationName: null,
  651. deliveryAllocation: null,
  652. deliveryAllocationName: null,
  653. passageOn: null,
  654. puOrg: null,
  655. purOrgName: null,
  656. lastStockQty: null,
  657. superiorCenterQty: null,
  658. superiorAllotQty: null,
  659. availableQty: null,
  660. statusAllot: 'N',
  661. additionalSupplier: null,
  662. additionalSupplierName: null,
  663. periodUnit: null,
  664. demandCustomer: null,
  665. demandCustomerName: null,
  666. lastStockOrg: null,
  667. lastStockOrgName: null,
  668. superiorStockOrg: null,
  669. superiorStockOrgName: null,
  670. allotCode: null,
  671. deliveryAddress: null,
  672. deliveryAddressName: null,
  673. contacts: null,
  674. contactsPhone: null,
  675. address: null,
  676. source: null,
  677. priceType: 'order',
  678. puManagerApprover: null,
  679. puManagerApproverName: null,
  680. processTime: null,
  681. affirmer: null,
  682. tenantId: null,
  683. revision: null,
  684. createBy: null,
  685. createByName: null,
  686. createTime: null,
  687. updateBy: null,
  688. updateByName: null,
  689. updateTime: null,
  690. delFlag: 0,
  691. // 新增字段
  692. model: null,
  693. storageCondition: null,
  694. transportationCondition: null,
  695. },
  696. // 无限滚动配置
  697. loadDisabled: true,
  698. page: 0,
  699. total: 5,
  700. // 表格校验规则
  701. tableRules: {
  702. materialCode : [{required: true, message: '物料编码必填'}],
  703. qty: [{required: true, message: '实际业务需求量必填'}],
  704. },
  705. }
  706. },
  707. created() {
  708. if(this.pageStu == 'check') {
  709. console.log('数据', this.row)
  710. this.getDetails(this.row)
  711. } else if(this.pageStu == 'edit') {
  712. this.getDetails(this.row)
  713. } else if (this.pageStu == 'add') {
  714. // 新增时判断需求日期
  715. this.dafaultDate()
  716. this.loading = false
  717. this.basicForm.demandPersonal = this.$store.state.user.name
  718. this.basicForm.demandPersonalName = this.$store.state.user.nickName
  719. this.basicForm.demandDept = this.$store.state.user.deptId
  720. this.basicForm.demandDeptName = this.$store.state.user.deptName
  721. if (this.basicForm.demandPersonal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.demandPersonal, '需求人员') }
  722. if (this.basicForm.demandDept) { this.reBackRefer('DEPT_PARAM', this.basicForm.demandDept) }
  723. }
  724. },
  725. methods: {
  726. // 默认需求日期根据当天星期几判断
  727. dafaultDate() {
  728. // 获取当前时间
  729. let date = new Date()
  730. //获取当前时间的年份转为字符串
  731. let year = date.getFullYear().toString()
  732. //获取月份,由于月份从0开始,此处要加1,判断是否小于10,如果是在字符串前面拼接'0'
  733. let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1).toString() : (date.getMonth() + 1).toString() //'04'
  734. //获取天,判断是否小于10,如果是在字符串前面拼接'0'
  735. let da = date.getDate() < 10 ? '0' + date.getDate().toString() : date.getDate().toString() //'12'
  736. let today = year + '-' + month + '-' + da
  737. console.log('今天日期',today)
  738. let weekDay = date.getDay()
  739. console.log('今天星期几', weekDay)
  740. // 改变需求计划的判断写这里面了
  741. if (this.basicForm.planType == 'JJXQ') {
  742. this.basicForm.demandDate = today
  743. } else {
  744. if (weekDay == 0) {this.basicForm.demandDate = this.getNextDate(today, 2)}
  745. else if (weekDay == 1) {this.basicForm.demandDate = this.getNextDate(today, 1)}
  746. else if (weekDay == 2) {this.basicForm.demandDate = today}
  747. else if (weekDay == 3) {this.basicForm.demandDate = this.getNextDate(today, 6)}
  748. else if (weekDay == 4) {this.basicForm.demandDate = this.getNextDate(today, 5)}
  749. else if (weekDay == 5) {this.basicForm.demandDate = this.getNextDate(today, 4)}
  750. else if (weekDay == 6) {this.basicForm.demandDate = this.getNextDate(today, 3)}
  751. // console.log(this.getNextDate(today, 2))
  752. }
  753. },
  754. // 获取某天日期的下一天,默认为第二天 默认输出格式为yyyy-mm-dd
  755. getNextDate(date, day = 1, format = '{y}-{m}-{d}') {
  756. if (date) {
  757. date = date.match(/\d+/g).join('-'); // 格式为2022年09月19日处理
  758. const nDate = new Date(date);
  759. nDate.setDate(nDate.getDate() + day);
  760. const formatObj = {
  761. y: nDate.getFullYear(),
  762. m: nDate.getMonth() + 1,
  763. d: nDate.getDate(),
  764. };
  765. return format.replace(/{([ymd])+}/g, (result, key) => {
  766. const value = formatObj[key];
  767. return value.toString().padStart(2, '0');
  768. });
  769. } else {
  770. console.log('date格式不正确');
  771. }
  772. },
  773. // 改变需求计划改变需求日期
  774. changeplanType() {
  775. this.dafaultDate()
  776. },
  777. // 无限滚动加载配置
  778. load() {
  779. if (this.loadDisabled) return;
  780. this.page++;
  781. if (this.page <= this.total) {
  782. this.basicForm.puDemandItemList = this.basicForm.puDemandItemList.concat(this.basicForm.puDemandItemList);
  783. }
  784. if (this.page === this.total) {
  785. this.loadDisabled = true;
  786. }
  787. },
  788. // 改变单据日期时清空子表的调拨日期
  789. changeDemandDate() {
  790. this.basicForm.puDemandItemList.forEach(item => {
  791. item.deliveryDate = null
  792. })
  793. },
  794. // 更改业务类型调整明细行内补单或紧急标识
  795. changeBillType() {
  796. if (this.basicForm.billType == 'BDXQ' && this.basicForm.puDemandItemList.length != 0) {
  797. this.isBDXQ = true
  798. this.BDZT = false
  799. this.basicForm.puDemandItemList.forEach(item => {item.isReplenishment = 'Y'})
  800. } else {
  801. this.isBDXQ = false
  802. this.BDZT = true
  803. this.basicForm.puDemandItemList.forEach(item => {
  804. item.isReplenishment = 'N'
  805. item.additionalSupplier = null
  806. item.additionalSupplierName = null
  807. })
  808. }
  809. if (this.basicForm.billType == 'JJXQ' && this.basicForm.puDemandItemList.length != 0) {
  810. this.basicForm.puDemandItemList.forEach(item => {item.isUrgency = 'Y'})
  811. } else {
  812. this.basicForm.puDemandItemList.forEach(item => { item.isUrgency = 'N' })
  813. }
  814. },
  815. // 改变是否客户指定
  816. isCustomer() {
  817. if (this.basicForm.isCustomerSpecified == 'Y' && this.basicForm.puDemandItemList.length != 0) {
  818. this.basicForm.puDemandItemList.forEach(item => {item.isCustomerSpecified = 'Y'})
  819. } else {
  820. this.basicForm.puDemandItemList.forEach(item => {item.isCustomerSpecified = 'N'})
  821. }
  822. },
  823. hangStatus(row) {
  824. switch (row.row.status) {
  825. case '0':
  826. return '需补货'
  827. case '1':
  828. return '待计划确认'
  829. case '2':
  830. return '计划已确认'
  831. case '3':
  832. return '计划已审核'
  833. case '4':
  834. return '行关闭'
  835. case '5':
  836. return '总供应可满足'
  837. }
  838. },
  839. // 获取预留数量
  840. getYLSL(scope) {
  841. if (scope.row.reservedProportion) {
  842. scope.row.reservedQty = Math.ceil(scope.row.reservedProportion.replace('%', '') / 100 * scope.row.qty)
  843. }
  844. // 如果选择预留比例,预留周期必填
  845. // if(scope.row.reservedQty && scope.row.reservedQty !== 0) {
  846. // this.isYl = true
  847. // } else {
  848. // this.isYl = false
  849. // }
  850. },
  851. // 清空
  852. cleanYLSL(scope) {
  853. scope.row.reservedQty = ''
  854. scope.row.reservedPeriod = ''
  855. },
  856. copy() {
  857. this.$modal.notifySuccess("复制成功");
  858. this.sonPageStu = 'add'
  859. this.sonDisable = false
  860. // this.getDetails(this.row)
  861. this.basicForm.id = ''
  862. this.basicForm.code = ''
  863. this.basicForm.createBy = ''
  864. this.basicForm.source = '4'
  865. this.basicForm.isCustomerSpecified = 'N'
  866. this.basicForm.demandPersonal = this.$store.state.user.name
  867. this.basicForm.demandPersonalName = this.$store.state.user.nickName
  868. this.basicForm.demandDept = this.$store.state.user.deptId
  869. this.basicForm.demandDeptName = this.$store.state.user.deptName
  870. // 复制时判断需求日期
  871. this.dafaultDate()
  872. if (this.basicForm.demandPersonal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.demandPersonal, '需求人员') }
  873. if (this.basicForm.demandDept) { this.reBackRefer('DEPT_PARAM', this.basicForm.demandDept) }
  874. this.basicForm.puDemandItemList.forEach(item => {
  875. item.status = ''
  876. item.buyerName = ''
  877. item.buyer = ''
  878. item.reservedProportion = ''
  879. item.reservedPeriod = ''
  880. item.reservedQty = ''
  881. item.averageQtyMonth = ''
  882. item.demandPeriod = ''
  883. item.forecastClassify = ''
  884. item.onemonthAvgVolume = ''
  885. item.threemonthAvgVolume = ''
  886. item.puFreight = ''
  887. item.superiorAllotQty = ''
  888. item.resDemandQty = ''
  889. item.executeQty = ''
  890. item.deliveryWarehouseName = ''
  891. item.deliveryWarehouse = ''
  892. item.deliveryAllocationName = ''
  893. item.deliveryAllocation = ''
  894. item.lastWarehouseName = ''
  895. item.lastAllocationName = ''
  896. item.availableQty = ''
  897. item.lastStockOrgName = ''
  898. item.centralWarehouseQty = ''
  899. item.allotCode = ''
  900. item.allotQty = ''
  901. item.deliveryAddress = ''
  902. item.deliveryAddressName = ''
  903. item.contacts = ''
  904. item.contactsPhone = ''
  905. item.address = ''
  906. item.statusAllot = 'N'
  907. })
  908. },
  909. editPage() {
  910. this.sonPageStu = 'edit'
  911. this.sonDisable = false
  912. },
  913. handleData() {
  914. console.log('222')
  915. // 复制新增把id,需求单号,创建人置为空,子表去掉id
  916. this.basicForm.id = ''
  917. this.basicForm.code = ''
  918. this.basicForm.createBy = ''
  919. this.basicForm.source = '4'
  920. if (this.basicForm.puDemandItemList.length !== 0) {
  921. this.basicForm.puDemandItemList.forEach(item => {
  922. if (item.id) {
  923. delete item.id
  924. }
  925. if (item.demandId) {
  926. delete item.demandId
  927. }
  928. if (item.allotCode) {
  929. delete item.allotCode
  930. }
  931. })
  932. }
  933. },
  934. async save() {
  935. if(this.basicForm.puDemandItemList.length !== 0) {
  936. this.$refs['basic'].validate((valid, obj) => {
  937. if(valid) {
  938. // 加上表格校验
  939. this.$refs.table.fullValidate().then(data=> {
  940. if(!data) {
  941. this.$modal.loading("保存中...");
  942. if(this.sonPageStu == 'add') {
  943. this.handleData()
  944. addDemand(this.basicForm).then(res => {
  945. if (res.code === 200) {
  946. this.$modal.notifySuccess(res.msg);
  947. this.$modal.closeLoading();
  948. this.back()
  949. }
  950. }).catch(err => {
  951. this.$modal.closeLoading();
  952. })
  953. } else if (this.sonPageStu == 'edit') {
  954. let list = []
  955. list.push(...this.basicForm.puDemandItemList, ...this.delDemandItemList)
  956. // 深拷贝一下参数对象
  957. let param = JSON.parse(JSON.stringify(this.basicForm))
  958. console.log('深拷贝对象',param);
  959. param.puDemandItemList = list
  960. // this.basicForm.puDemandItemList.push(...this.delDemandItemList)
  961. editDemand(param).then(res => {
  962. if (res.code === 200) {
  963. this.$modal.notifySuccess(res.msg);
  964. this.$modal.closeLoading();
  965. this.back()
  966. }
  967. }).catch(err => {
  968. this.$modal.closeLoading();
  969. })
  970. }
  971. } else {
  972. let masStr = ''
  973. Object.values(data).forEach(errList => {
  974. console.log('data',data)
  975. console.log(errList)
  976. errList.forEach(params => {
  977. let { rowIndex, column, rules } = params
  978. rules.forEach(rule => {
  979. masStr += `第 ${rowIndex + 1} 行${rule.message};`
  980. })
  981. this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${rowIndex+1})`).style.background = '#f34b4bb8'
  982. })
  983. })
  984. this.$modal.notifyError(masStr);
  985. }
  986. })
  987. } else {
  988. // 校验加弹窗
  989. const jiaoyan = []
  990. for(let key in obj) {
  991. jiaoyan.push(obj[key][0].message);
  992. }
  993. this.$modal.notifyWarning(jiaoyan[0]);
  994. return false
  995. }
  996. })
  997. } else {
  998. this.$modal.notifyWarning("明细信息不能为空!");
  999. }
  1000. },
  1001. submit() {
  1002. this.$modal.loading("提交中...");
  1003. submitDemand(this.basicForm).then(res => {
  1004. if (res.code === 200) {
  1005. this.$modal.notifySuccess("提交成功");
  1006. this.$modal.closeLoading();
  1007. this.back()
  1008. }
  1009. }).catch(err => {
  1010. this.$modal.closeLoading();
  1011. })
  1012. },
  1013. // 增行
  1014. addLine() {
  1015. const newLine = {...this.sonModel}
  1016. newLine.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1017. newLine.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1018. newLine.demandCustomer = this.basicForm.customer
  1019. newLine.demandCustomerName = this.basicForm.customerName
  1020. this.basicForm.puDemandItemList.push(newLine)
  1021. // 补单需求状态改变
  1022. if (this.basicForm.billType == 'BDXQ') {
  1023. this.BDZT = false
  1024. } else {
  1025. this.BDZT = true
  1026. }
  1027. },
  1028. delLine(index, row) {
  1029. console.log('删除行:', index)
  1030. console.log('改变行:', row)
  1031. row.delFlag = '2'
  1032. let delList = []
  1033. delList = this.basicForm.puDemandItemList.filter(item => {
  1034. return item.delFlag == '2'
  1035. })
  1036. this.basicForm.puDemandItemList = this.basicForm.puDemandItemList.filter(item => {
  1037. return item.delFlag == '0'
  1038. })
  1039. this.delDemandItemList.push(...delList)
  1040. console.log('删除的数组',this.delDemandItemList)
  1041. },
  1042. back() {
  1043. console.log('打印人员信息看看', this.$store.state)
  1044. this.$emit('jugislist', true)
  1045. this.$emit('refresh')
  1046. },
  1047. // 如果需要回显则调用详情接口
  1048. getDetails(row) {
  1049. getDemandDetail(row.id).then(res => {
  1050. if (res.code === 200) {
  1051. // this.basicForm = res.data
  1052. let reciveForm = res.data
  1053. let params = {...{id: row.id}, ...{pageNum:1, pageSize: 10}}
  1054. getDemandSonDetail(params).then(res => {
  1055. if (res.code === 200) {
  1056. reciveForm.puDemandItemList = res.data
  1057. console.log('reciveForm',reciveForm)
  1058. this.basicForm = reciveForm
  1059. if(this.basicForm.org) { this.reBackRefer('ORG_PARAM', this.basicForm.org) }
  1060. if(this.basicForm.customer) { this.reBackRefer('CUSTOMER_PARAM', this.basicForm.customer) }
  1061. if(this.basicForm.customerPrincipal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.customerPrincipal, '客户负责人') }
  1062. if(this.basicForm.demandPersonal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.demandPersonal, '需求人员') }
  1063. if(this.basicForm.demandDept) { this.reBackRefer('DEPT_PARAM', this.basicForm.demandDept) }
  1064. // 详情时将收货仓库id赋值给stordocId
  1065. // 如果业务类型为补单需求,则明细内补单供应商编码可以编辑
  1066. if(this.basicForm.billType == 'BDXQ') {
  1067. this.BDZT = false
  1068. this.isBDXQ = true
  1069. } else {
  1070. this.BDZT = true
  1071. this.isBDXQ = false
  1072. }
  1073. }
  1074. }).then(() => {
  1075. this.loading = false
  1076. }).catch(err => {
  1077. this.loading = false
  1078. })
  1079. }
  1080. })
  1081. },
  1082. // 单元格标红
  1083. cellClassName({row, column, rowIndex, columnIndex}) {
  1084. if(this.basicForm.isCustomerSpecified == 'N' && column.title == "需求可用周期" && Number(row.demandPeriod) > 1.5 && Number(row.qty) > Number(row.minOrderQty)) {
  1085. return 'success-row';
  1086. }
  1087. },
  1088. handleSelectionChange(selection) {
  1089. this.ids = selection.map(item =>{
  1090. return item.id
  1091. })
  1092. console.log('选中数组', this.ids)
  1093. },
  1094. rowSelect(row) {
  1095. this.$refs.table.toggleRowSelection(row);
  1096. },
  1097. // 点击预留单展示
  1098. showReserved() {
  1099. this.dialog.config = true
  1100. },
  1101. // 修改是否让页面显示与隐藏的事件
  1102. updateReserved (val) {
  1103. this.dialog.config = val
  1104. },
  1105. // 回显参照框
  1106. reBackRefer(type, id, title) {
  1107. getRefer({type: type, id: id}).then(res => {
  1108. if(type == 'ORG_PARAM') {
  1109. this.orgOptions = res.rows
  1110. }
  1111. if (type == 'CUSTOMER_PARAM') {
  1112. this.customerOptions = res.rows
  1113. }
  1114. if (type == 'CONTACTS_PARAM' && title == '需求人员') {
  1115. this.personOptions = res.rows
  1116. }
  1117. if (type == 'CONTACTS_PARAM' && title == '客户负责人') {
  1118. this.manOptions = res.rows
  1119. }
  1120. if (type == 'DEPT_PARAM') {
  1121. this.deptOptions = res.rows
  1122. }
  1123. })
  1124. },
  1125. chooseOrg(type, isPage, title) {
  1126. this.referCondition.type = type
  1127. this.referCondition.isPage = isPage
  1128. this.referCondition.title = title
  1129. this.$refs.refer.init(this.referCondition)
  1130. },
  1131. selectionsToInput(selection) {
  1132. if(this.referCondition.type == 'ORG_PARAM' && this.referCondition.title == '选择组织') {
  1133. this.orgOptions = selection
  1134. this.basicForm.org = selection[0].id
  1135. this.basicForm.orgName = selection[0].name
  1136. }
  1137. if(this.referCondition.type == 'CUSTOMER_PARAM' && this.referCondition.title == '选择客户') {
  1138. this.customerOptions = selection
  1139. this.basicForm.customer = selection[0].id
  1140. this.basicForm.customerName = selection[0].name
  1141. this.basicForm.customerCode = selection[0].code
  1142. if(this.basicForm.puDemandItemList.length !== 0) {
  1143. this.basicForm.puDemandItemList.forEach(item => {
  1144. item.demandCustomerName = this.basicForm.customerName
  1145. item.demandCustomer = this.basicForm.customer
  1146. item.status = ''
  1147. item.buyerName = ''
  1148. item.buyer = ''
  1149. item.reservedProportion = ''
  1150. item.reservedPeriod = ''
  1151. item.reservedQty = ''
  1152. item.averageQtyMonth = ''
  1153. item.demandPeriod = ''
  1154. item.forecastClassify = ''
  1155. item.onemonthAvgVolume = ''
  1156. item.threemonthAvgVolume = ''
  1157. item.puFreight = ''
  1158. item.superiorAllotQty = ''
  1159. item.resDemandQty = ''
  1160. item.executeQty = ''
  1161. item.deliveryWarehouseName = ''
  1162. item.deliveryWarehouse = ''
  1163. item.deliveryAllocationName = ''
  1164. item.deliveryAllocation = ''
  1165. item.lastWarehouseName = ''
  1166. item.lastAllocationName = ''
  1167. item.availableQty = ''
  1168. item.lastStockOrgName = ''
  1169. item.centralWarehouseQty = ''
  1170. item.allotCode = ''
  1171. item.deliveryAddress = ''
  1172. item.deliveryAddressName = ''
  1173. item.contacts = ''
  1174. item.contactsPhone = ''
  1175. item.address = ''
  1176. })
  1177. }
  1178. }
  1179. if(this.referCondition.type == 'CONTACTS_PARAM' && this.referCondition.title == '需求人员') {
  1180. this.personOptions = selection
  1181. this.basicForm.demandPersonal = selection[0].code
  1182. this.basicForm.demandPersonalName = selection[0].name
  1183. }
  1184. if(this.referCondition.type == 'CONTACTS_PARAM' && this.referCondition.title == '采购员') {
  1185. this.purchaseManOptions = selection
  1186. this.adjust.purchaseMan = selection[0].code
  1187. this.adjust.purchaseManName = selection[0].name
  1188. }
  1189. if(this.referCondition.type == 'WAREHOUSE_PARAM' && this.referCondition.title == '收货仓库') {
  1190. this.adjust.warehouse = selection[0].id
  1191. this.adjust.warehouseName = selection[0].name
  1192. this.adjust.allocation = ''
  1193. this.adjust.allocationName = ''
  1194. }
  1195. if(this.referCondition.type == 'ALLOCATION_PARAM' && this.referCondition.title == '收货货位') {
  1196. this.adjust.allocation = selection[0].id
  1197. this.adjust.allocationName = selection[0].name
  1198. }
  1199. if(this.referCondition.type == 'ADDRESS_PARAM' && this.referCondition.title == '收货地址') {
  1200. this.adjust.deliveryAddressName = selection[0].name
  1201. this.adjust.deliveryAddress = selection[0].code
  1202. this.adjust.contacts = selection[0].contactsName
  1203. this.adjust.contactsPhone = selection[0].contactsPhone
  1204. this.adjust.address = selection[0].address
  1205. }
  1206. if(this.referCondition.type == 'DEPT_PARAM') {
  1207. this.deptOptions = selection
  1208. this.basicForm.demandDept = selection[0].id
  1209. this.basicForm.demandDeptName = selection[0].name
  1210. }
  1211. if(this.referCondition.title == '选择收货仓库') {
  1212. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouse = selection[0].id
  1213. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouseName = selection[0].name
  1214. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocation = null
  1215. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = null
  1216. }
  1217. if(this.referCondition.title == '选择收货货位') {
  1218. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocation = selection[0].id
  1219. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = selection[0].name
  1220. }
  1221. if(this.referCondition.title == '选择补单供应商') {
  1222. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplier = selection[0].id
  1223. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplierName = selection[0].name
  1224. }
  1225. if(this.referCondition.title == '选择收货地址') {
  1226. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddressName = selection[0].name
  1227. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddress = selection[0].code
  1228. this.basicForm.puDemandItemList[this.tableIndex].contacts = selection[0].contactsName
  1229. this.basicForm.puDemandItemList[this.tableIndex].contactsPhone = selection[0].contactsPhone
  1230. this.basicForm.puDemandItemList[this.tableIndex].address = selection[0].address
  1231. }
  1232. },
  1233. // 粘贴来的数据
  1234. async pasteMe(e, scope, index) {
  1235. this.$modal.loading("正在处理数据...");
  1236. e.preventDefault() //阻止默认粘贴事件
  1237. let source = e.clipboardData.getData("Text");
  1238. console.log('scope', scope.column.property)
  1239. // 首先对源头进行解析
  1240. let rows = source.split("\r\n"); // 拆成一个数组
  1241. // 数组去除空字符串
  1242. rows = rows.filter(item => {
  1243. return item && item.trim()
  1244. })
  1245. if (rows.length < 100) {
  1246. // 粘贴物料编码
  1247. if(scope.column.property == 'materialCode') {
  1248. await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
  1249. this.$modal.closeLoading();
  1250. if (res.code === 200) {
  1251. let rowList = res.rows
  1252. let newLine = []
  1253. for (let i = 0; i<rowList.length; i++) {
  1254. let line = {...this.sonModel}
  1255. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1256. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1257. line.demandCustomer = this.basicForm.customer
  1258. line.demandCustomerName = this.basicForm.customerName
  1259. line.materialCode = rowList[i].code
  1260. line.material = rowList[i].id
  1261. line.materialName = rowList[i].name
  1262. line.classifyId = rowList[i].classifyId
  1263. line.materialClassifyOneName = rowList[i].oneClass
  1264. line.materialClassifyTwoName = rowList[i].twoClass
  1265. line.materialClassifyThreeName = rowList[i].threeClass
  1266. line.materialClassifyFourName = rowList[i].fourClass
  1267. line.specification = rowList[i].specification
  1268. line.model = rowList[i].model
  1269. line.unit = rowList[i].unitId
  1270. line.unitName = rowList[i].unitIdName
  1271. line.registrant = rowList[i].registrant
  1272. line.manufacturerName = rowList[i].manufacturerIdName
  1273. line.puPeriod = rowList[i].deliveryPeriod
  1274. line.expiry = rowList[i].usefulLife
  1275. line.expiryUnit = rowList[i].expiryUnitIdName
  1276. // line.minPackage = rowList[i].usefulLife
  1277. line.minPackage = rowList[i].minPackQty
  1278. line.minOrderQty = rowList[i].minOrderQty
  1279. line.minBatch = rowList[i].minBatchQty
  1280. line.safeStock = rowList[i].safeStock
  1281. line.purOrgName = rowList[i].purchasingOrganizationName
  1282. line.puOrg = rowList[i].purchasingOrganization
  1283. // 物料存储条件和运输条件
  1284. line.transportationCondition = rowList[i].transportationCondition
  1285. line.storageCondition = rowList[i].storageCondition
  1286. newLine.push(line)
  1287. console.log('临时数组', newLine)
  1288. }
  1289. // 删除指定下标
  1290. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1291. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  1292. }
  1293. }).then(() => {
  1294. this.$refs.table.doLayout()
  1295. }).catch(err => {
  1296. this.$modal.closeLoading();
  1297. })
  1298. // 粘贴实际业务需求量
  1299. }else if(scope.column.property == 'qty') {
  1300. console.log('复制内容:', rows)
  1301. let newLine = []
  1302. if(this.basicForm.puDemandItemList.length <= 1) {
  1303. for (let i = 0; i<rows.length; i++) {
  1304. let line = {...this.sonModel}
  1305. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1306. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1307. line.demandCustomer = this.basicForm.customer
  1308. line.demandCustomerName = this.basicForm.customerName
  1309. line.qty = rows[i]
  1310. newLine.push(line)
  1311. }
  1312. // 删除指定下标
  1313. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1314. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  1315. this.$refs.table.doLayout()
  1316. this.$modal.closeLoading();
  1317. } else {
  1318. for(let i = index , j = 0; i < this.basicForm.puDemandItemList.length; i++, j++) {
  1319. this.basicForm.puDemandItemList[i].qty = rows[j]
  1320. }
  1321. this.$refs.table.doLayout()
  1322. this.$modal.closeLoading();
  1323. }
  1324. // 粘贴补单供应商
  1325. }else if(scope.column.property == 'additionalSupplierName') {
  1326. await getRefer({ type: 'SUPPLIER_PARAM', searchList: rows }).then(res => {
  1327. this.$modal.closeLoading();
  1328. if (res.code === 200) {
  1329. let rowList = res.rows
  1330. let newLine = []
  1331. for (let i = 0; i<rowList.length; i++) {
  1332. let line = {...this.sonModel}
  1333. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1334. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1335. line.demandCustomer = this.basicForm.customer
  1336. line.demandCustomerName = this.basicForm.customerName
  1337. line.additionalSupplier = rowList[i].id
  1338. line.additionalSupplierName = rowList[i].name
  1339. newLine.push(line)
  1340. console.log('临时数组', newLine)
  1341. }
  1342. if(this.basicForm.puDemandItemList.length <= 1) {
  1343. // 删除指定下标
  1344. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1345. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  1346. } else {
  1347. for(let i = index , j = 0; i < this.basicForm.puDemandItemList.length; i++, j++) {
  1348. this.basicForm.puDemandItemList[i].additionalSupplier = newLine[j].additionalSupplier
  1349. this.basicForm.puDemandItemList[i].additionalSupplierName = newLine[j].additionalSupplierName
  1350. }
  1351. this.$refs.table.doLayout()
  1352. this.$modal.closeLoading();
  1353. }
  1354. }
  1355. }).then(() => {
  1356. this.$refs.table.doLayout()
  1357. }).catch(err => {
  1358. this.$modal.closeLoading();
  1359. })
  1360. }else if(scope.column.property == 'deliveryAddressName') {
  1361. await getRefer({ type: 'ADDRESS_PARAM', searchList: rows }).then(res => {
  1362. this.$modal.closeLoading();
  1363. if (res.code === 200) {
  1364. let rowList = res.rows
  1365. let newLine = []
  1366. for (let i = 0; i<rowList.length; i++) {
  1367. let line = {...this.sonModel}
  1368. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1369. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1370. line.demandCustomer = this.basicForm.customer
  1371. line.demandCustomerName = this.basicForm.customerName
  1372. line.deliveryAddressName = rowList[i].name
  1373. line.deliveryAddress = rowList[i].code
  1374. line.contacts = rowList[i].contactsName
  1375. line.contactsPhone = rowList[i].contactsPhone
  1376. line.address = rowList[i].address
  1377. newLine.push(line)
  1378. console.log('临时数组', newLine)
  1379. }
  1380. if(this.basicForm.puDemandItemList.length <= 1) {
  1381. // 删除指定下标
  1382. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1383. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  1384. } else {
  1385. for(let i = index , j = 0; i < this.basicForm.puDemandItemList.length; i++, j++) {
  1386. this.basicForm.puDemandItemList[i].deliveryAddressName = newLine[j].deliveryAddressName
  1387. this.basicForm.puDemandItemList[i].deliveryAddress = newLine[j].deliveryAddress
  1388. this.basicForm.puDemandItemList[i].contacts = newLine[j].contacts
  1389. this.basicForm.puDemandItemList[i].contactsPhone = newLine[j].contactsPhone
  1390. this.basicForm.puDemandItemList[i].address = newLine[j].address
  1391. }
  1392. this.$refs.table.doLayout()
  1393. this.$modal.closeLoading();
  1394. }
  1395. }
  1396. }).then(() => {
  1397. this.$refs.table.doLayout()
  1398. }).catch(err => {
  1399. this.$modal.closeLoading();
  1400. })
  1401. }
  1402. } else {
  1403. this.$modal.notifyWarning("复制长度不能超过100!");
  1404. this.$modal.closeLoading();
  1405. }
  1406. },
  1407. // 明细行选择物料编码带出数据
  1408. chooseMaterial(index) {
  1409. console.log("🚀 ~ file: add.vue:790 ~ chooseMaterial ~ index:", index)
  1410. this.tableIndex = index
  1411. // 传0只展示同步NC了的物料
  1412. this.$refs.materialRefer.init(0)
  1413. },
  1414. selectMaterial(selection) {
  1415. console.log('选中的物料', selection)
  1416. if (selection.length <= 1) {
  1417. // 选择新物料时先清空行内其他信息
  1418. this.basicForm.puDemandItemList[this.tableIndex].reservedProportion = null
  1419. this.basicForm.puDemandItemList[this.tableIndex].reservedPeriod = null
  1420. this.basicForm.puDemandItemList[this.tableIndex].reservedQty = null
  1421. this.basicForm.puDemandItemList[this.tableIndex].qty = null
  1422. this.basicForm.puDemandItemList[this.tableIndex].deliveryDate = null
  1423. this.basicForm.puDemandItemList[this.tableIndex].remark = null
  1424. this.basicForm.puDemandItemList[this.tableIndex].resDemandQty = null
  1425. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouse = null
  1426. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouseName = null
  1427. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocation = null
  1428. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = null
  1429. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplier = null
  1430. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplierName = null
  1431. this.basicForm.puDemandItemList[this.tableIndex].periodUnit = null
  1432. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddressName = null
  1433. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddress = null
  1434. this.basicForm.puDemandItemList[this.tableIndex].contacts = null
  1435. this.basicForm.puDemandItemList[this.tableIndex].contactsPhone = null
  1436. this.basicForm.puDemandItemList[this.tableIndex].address = null
  1437. this.basicForm.puDemandItemList[this.tableIndex].priceType = 'order'
  1438. this.basicForm.puDemandItemList[this.tableIndex].lastWarehouseName = null
  1439. this.basicForm.puDemandItemList[this.tableIndex].lastWarehouse = null
  1440. this.basicForm.puDemandItemList[this.tableIndex].lastAllocation = null
  1441. this.basicForm.puDemandItemList[this.tableIndex].lastAllocationName = null
  1442. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyOne = null
  1443. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyTwo = null
  1444. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyThree = null
  1445. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyFour = null
  1446. this.basicForm.puDemandItemList[this.tableIndex].lastStockOrg = null
  1447. this.basicForm.puDemandItemList[this.tableIndex].lastStockOrgName = null
  1448. this.basicForm.puDemandItemList[this.tableIndex].buyer = null
  1449. this.basicForm.puDemandItemList[this.tableIndex].buyerName = null
  1450. // 通过选择物料查询采购员
  1451. queryMan(selection[0].id).then(res => {
  1452. if(res.code === 200 && res.rows.length !== 0) {
  1453. this.basicForm.puDemandItemList[this.tableIndex].buyer = res.rows[0].buyer
  1454. this.basicForm.puDemandItemList[this.tableIndex].buyerName = res.rows[0].buyerName
  1455. }
  1456. })
  1457. this.basicForm.puDemandItemList[this.tableIndex].materialCode = selection[0].code
  1458. this.basicForm.puDemandItemList[this.tableIndex].material = selection[0].id
  1459. this.basicForm.puDemandItemList[this.tableIndex].materialName = selection[0].name
  1460. this.basicForm.puDemandItemList[this.tableIndex].classifyId = selection[0].classifyId
  1461. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyOneName = selection[0].oneClass
  1462. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyTwoName = selection[0].twoClass
  1463. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyThreeName = selection[0].threeClass
  1464. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyFourName = selection[0].fourClass
  1465. this.basicForm.puDemandItemList[this.tableIndex].specification = selection[0].specification
  1466. this.basicForm.puDemandItemList[this.tableIndex].model = selection[0].model
  1467. this.basicForm.puDemandItemList[this.tableIndex].unit = selection[0].unitId
  1468. this.basicForm.puDemandItemList[this.tableIndex].unitName = selection[0].unitIdName
  1469. this.basicForm.puDemandItemList[this.tableIndex].registrant = selection[0].registrant
  1470. this.basicForm.puDemandItemList[this.tableIndex].manufacturerName = selection[0].manufacturerIdName
  1471. this.basicForm.puDemandItemList[this.tableIndex].puPeriod = selection[0].deliveryPeriod
  1472. this.basicForm.puDemandItemList[this.tableIndex].expiry = selection[0].usefulLife
  1473. this.basicForm.puDemandItemList[this.tableIndex].expiryUnit = selection[0].expiryUnitIdName
  1474. // this.basicForm.puDemandItemList[this.tableIndex].minPackage = selection[0].usefulLife
  1475. this.basicForm.puDemandItemList[this.tableIndex].minPackage = selection[0].minPackQty
  1476. this.basicForm.puDemandItemList[this.tableIndex].minOrderQty = selection[0].minOrderQty
  1477. this.basicForm.puDemandItemList[this.tableIndex].minBatch = selection[0].minBatchQty
  1478. this.basicForm.puDemandItemList[this.tableIndex].safeStock = selection[0].safeStock
  1479. this.basicForm.puDemandItemList[this.tableIndex].purOrgName = selection[0].purchasingOrganizationName
  1480. this.basicForm.puDemandItemList[this.tableIndex].puOrg = selection[0].purchasingOrganization
  1481. // 物料存储条件和运输条件
  1482. this.basicForm.puDemandItemList[this.tableIndex].transportationCondition = selection[0].transportationCondition
  1483. this.basicForm.puDemandItemList[this.tableIndex].storageCondition = selection[0].storageCondition
  1484. // 选中骨科耗材时候的物料,需求客户不必填
  1485. } else {
  1486. console.log('xxxxx', selection)
  1487. let newLine = []
  1488. for (let i = 0;i<selection.length;i++) {
  1489. let line = {...this.sonModel}
  1490. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1491. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1492. line.demandCustomer = this.basicForm.customer
  1493. line.demandCustomerName = this.basicForm.customerName
  1494. // 通过选择物料查询采购员
  1495. queryMan(selection[i].id).then(res => {
  1496. if (res.code === 200 && res.rows.length !== 0) {
  1497. line.buyer = res.rows[0].buyer
  1498. line.buyerName = res.rows[0].buyerName
  1499. }
  1500. })
  1501. line.materialCode = selection[i].code
  1502. line.material = selection[i].id
  1503. line.materialName = selection[i].name
  1504. line.classifyId = selection[i].classifyId
  1505. line.materialClassifyOneName = selection[i].oneClass
  1506. line.materialClassifyTwoName = selection[i].twoClass
  1507. line.materialClassifyThreeName = selection[i].threeClass
  1508. line.materialClassifyFourName = selection[i].fourClass
  1509. line.specification = selection[i].specification
  1510. line.model = selection[i].model
  1511. line.unit = selection[i].unitId
  1512. line.unitName = selection[i].unitIdName
  1513. line.registrant = selection[i].registrant
  1514. line.manufacturerName = selection[i].manufacturerIdName
  1515. line.puPeriod = selection[i].deliveryPeriod
  1516. line.expiry = selection[i].usefulLife
  1517. line.expiryUnit = selection[i].expiryUnitIdName
  1518. // line.minPackage = selection[i].usefulLife
  1519. line.minPackage = selection[i].minPackQty
  1520. line.minOrderQty = selection[i].minOrderQty
  1521. line.minBatch = selection[i].minBatchQty
  1522. line.safeStock = selection[i].safeStock
  1523. line.purOrgName = selection[i].purchasingOrganizationName
  1524. line.puOrg = selection[i].purchasingOrganization
  1525. // 物料存储条件和运输条件
  1526. line.transportationCondition = selection[i].transportationCondition
  1527. line.storageCondition = selection[i].storageCondition
  1528. // this.basicForm.puDemandItemList.push(line)
  1529. newLine.push(line)
  1530. }
  1531. // 删除指定下标
  1532. this.basicForm.puDemandItemList.splice(this.tableIndex,1,...newLine)
  1533. // this.basicForm.puDemandItemList.splice(this.tableIndex,1)
  1534. }
  1535. },
  1536. // 明细行选择参照
  1537. chooseDept(index, type, isPage, title) {
  1538. this.tableIndex = index
  1539. this.referCondition.type = type
  1540. this.referCondition.isPage = isPage
  1541. this.referCondition.title = title
  1542. this.$refs.refer.init(this.referCondition)
  1543. },
  1544. // 明细行选择仓库需要先确认采购组织
  1545. chooseCangKu(index, type, isPage, title, pkOrg) {
  1546. this.tableIndex = index
  1547. this.referCondition.type = type
  1548. this.referCondition.isPage = isPage
  1549. this.referCondition.title = title
  1550. if(pkOrg) {
  1551. this.referCondition.pkOrg = pkOrg
  1552. this.$refs.refer.init(this.referCondition)
  1553. } else {
  1554. this.$modal.notifyWarning("请先确认默认采购组织");
  1555. }
  1556. },
  1557. // 明细行选择货位先确认仓库
  1558. choosehuoWei(index, type, isPage, title, stordocId) {
  1559. this.tableIndex = index
  1560. this.referCondition.type = type
  1561. this.referCondition.isPage = isPage
  1562. this.referCondition.title = title
  1563. // 选择收货货位前先选择收货仓库
  1564. if(stordocId) {
  1565. this.referCondition.stordocId = stordocId
  1566. this.$refs.refer.init(this.referCondition)
  1567. } else {
  1568. this.$modal.notifyWarning("请先选择收货仓库");
  1569. }
  1570. },
  1571. // 明细行清空收货仓库,货位,收货地址档案等
  1572. clearHang(index, title) {
  1573. if (title == '选择收货仓库') {
  1574. this.basicForm.puDemandItemList[index].deliveryWarehouseName = null
  1575. this.basicForm.puDemandItemList[index].deliveryWarehouse = null
  1576. this.basicForm.puDemandItemList[index].deliveryAllocationName = null
  1577. this.basicForm.puDemandItemList[index].deliveryAllocation = null
  1578. }
  1579. if (title == '选择收货货位') {
  1580. this.basicForm.puDemandItemList[index].deliveryAllocationName = null
  1581. this.basicForm.puDemandItemList[index].deliveryAllocation = null
  1582. }
  1583. if (title == '选择收货地址') {
  1584. this.basicForm.puDemandItemList[index].deliveryAddressName = null
  1585. this.basicForm.puDemandItemList[index].deliveryAddress = null
  1586. this.basicForm.puDemandItemList[index].contacts = null
  1587. this.basicForm.puDemandItemList[index].contactsPhone = null
  1588. this.basicForm.puDemandItemList[index].address = null
  1589. }
  1590. if (title == '选择补单供应商') {
  1591. this.basicForm.puDemandItemList[index].additionalSupplierName = null
  1592. this.basicForm.puDemandItemList[index].additionalSupplier = null
  1593. }
  1594. },
  1595. // 清除需求客户将明细行内也清空
  1596. cleanCustomer() {
  1597. this.basicForm.customer = ''
  1598. this.basicForm.customerName = ''
  1599. this.basicForm.customerCode = ''
  1600. if (this.basicForm.puDemandItemList.length !== 0) {
  1601. this.basicForm.puDemandItemList.forEach(item => {
  1602. item.demandCustomerName = ''
  1603. item.demandCustomer = ''
  1604. item.status = ''
  1605. item.buyerName = ''
  1606. item.buyer = ''
  1607. item.reservedProportion = ''
  1608. item.reservedPeriod = ''
  1609. item.reservedQty = ''
  1610. item.averageQtyMonth = ''
  1611. item.demandPeriod = ''
  1612. item.forecastClassify = ''
  1613. item.onemonthAvgVolume = ''
  1614. item.threemonthAvgVolume = ''
  1615. item.puFreight = ''
  1616. item.superiorAllotQty = ''
  1617. item.resDemandQty = ''
  1618. item.executeQty = ''
  1619. item.deliveryWarehouseName = ''
  1620. item.deliveryWarehouse = ''
  1621. item.deliveryAllocationName = ''
  1622. item.deliveryAllocation = ''
  1623. item.lastWarehouseName = ''
  1624. item.lastAllocationName = ''
  1625. item.availableQty = ''
  1626. item.lastStockOrgName = ''
  1627. item.centralWarehouseQty = ''
  1628. item.allotCode = ''
  1629. item.deliveryAddress = ''
  1630. item.deliveryAddressName = ''
  1631. item.contacts = ''
  1632. item.contactsPhone = ''
  1633. item.address = ''
  1634. })
  1635. }
  1636. },
  1637. // 批量调整
  1638. adjustPl() {
  1639. if(this.ids.length == 0) {
  1640. this.$modal.notifyWarning('请至少选择一项数据进行操作!')
  1641. } else {
  1642. this.adjust.open = true
  1643. }
  1644. },
  1645. // 批量调整确认
  1646. confirmAdjust() {
  1647. console.log('data', this.adjust)
  1648. this.basicForm.puDemandItemList.forEach(item => {
  1649. this.ids.some(val => {
  1650. if(val == item.id) {
  1651. if(this.adjust.purchaseMan) {
  1652. item.buyer = this.adjust.purchaseMan
  1653. item.buyerName = this.adjust.purchaseManName
  1654. }
  1655. if(this.adjust.priceType) {
  1656. item.priceType = this.adjust.priceType
  1657. }
  1658. if(this.adjust.warehouseName) {
  1659. item.deliveryWarehouse = this.adjust.warehouse
  1660. item.deliveryWarehouseName = this.adjust.warehouseName
  1661. item.deliveryAllocation = this.adjust.allocation
  1662. item.deliveryAllocationName = this.adjust.allocationName
  1663. }
  1664. // if(this.adjust.allocationName) {
  1665. // item.deliveryAllocation = this.adjust.allocation
  1666. // item.deliveryAllocationName = this.adjust.allocationName
  1667. // }
  1668. if(this.adjust.remark) {
  1669. item.remark = this.adjust.remark
  1670. }
  1671. if(this.adjust.deliveryAddressName) {
  1672. item.deliveryAddressName = this.adjust.deliveryAddressName
  1673. item.deliveryAddress = this.adjust.deliveryAddress
  1674. item.contacts = this.adjust.contacts
  1675. item.contactsPhone = this.adjust.contactsPhone
  1676. item.address = this.adjust.address
  1677. }
  1678. }
  1679. this.adjust.open = false
  1680. })
  1681. })
  1682. },
  1683. // 批量调整选择货位
  1684. adjustHuoWei(type, isPage, title, stordocId) {
  1685. this.referCondition.type = type
  1686. this.referCondition.isPage = isPage
  1687. this.referCondition.title = title
  1688. // 选择收货货位前先选择收货仓库
  1689. if (stordocId) {
  1690. this.referCondition.stordocId = stordocId
  1691. this.$refs.refer.init(this.referCondition)
  1692. } else {
  1693. this.$modal.notifyWarning("请先选择收货仓库");
  1694. }
  1695. },
  1696. // 关闭清空批量调整数据
  1697. closeEvent() {
  1698. this.adjust = {
  1699. open: false,
  1700. priceType: '',
  1701. purchaseMan: '',
  1702. purchaseManName: '',
  1703. warehouse: '',
  1704. warehouseName: '',
  1705. allocation: '',
  1706. allocationName: '',
  1707. remark: '',
  1708. deliveryAddress: '',
  1709. deliveryAddressName: '',
  1710. contacts: '',
  1711. contactsPhone: '',
  1712. address: ''
  1713. }
  1714. },
  1715. // 必选标识
  1716. addRedStar(h, { column }) {
  1717. return [
  1718. h('span', { style: 'color: #F56C6C' }, '*'),
  1719. h('span', ' ' + column.label)
  1720. ];
  1721. },
  1722. // 表格表头标星
  1723. anotherRedStar(h, { column }) {
  1724. if(this.isBDXQ) {
  1725. return [
  1726. h('span', { style: 'color: #F56C6C' }, '*'),
  1727. h('span', ' ' + column.label)
  1728. ];
  1729. } else {
  1730. return [
  1731. h('span', ' ' + column.label)
  1732. ];
  1733. }
  1734. },
  1735. // 流程跳转
  1736. jumpOA() {
  1737. toOA(this.$store.state.user.name, this.basicForm.flowId).then(res => {
  1738. if(res.code === 200) {
  1739. window.open(res.oaUrl)
  1740. }
  1741. })
  1742. },
  1743. }
  1744. }
  1745. </script>
  1746. <style lang="scss" scoped>
  1747. .btn_group {
  1748. // width: 100%;
  1749. // margin: 20px 0;
  1750. display: flex;
  1751. justify-content: space-between;
  1752. position: absolute;
  1753. top: 10px;right: 20px;
  1754. }
  1755. .btn_grooup {
  1756. margin-bottom: 10px;
  1757. display: flex;
  1758. justify-content: space-between;
  1759. }
  1760. .hang {
  1761. margin: auto;
  1762. }
  1763. .hang ::v-deep .el-form-item__content{
  1764. margin-left: 0px !important;
  1765. }
  1766. // .el-table ::v-deep .el-form-item__error{
  1767. // padding-top: 0;
  1768. // top: 70%
  1769. // }
  1770. ::v-deep .elx-body--row .success-row {
  1771. background-color: #f11616!important;
  1772. }
  1773. ::v-deep .uxbeautifyTableClass .elx-table--header-wrapper {
  1774. color: #606266;
  1775. }
  1776. .pltzTxt{
  1777. text-align: right;
  1778. font-size: medium;
  1779. padding-right: 2%;
  1780. }
  1781. .pltzIpt{
  1782. width: 90%;
  1783. }
  1784. </style>