add.vue 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868
  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="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. let errorList = JSON.parse(err.message).rowList
  952. console.log(errorList)
  953. this.gainRed(errorList)
  954. this.$modal.closeLoading();
  955. })
  956. } else if (this.sonPageStu == 'edit') {
  957. let list = []
  958. list.push(...this.basicForm.puDemandItemList, ...this.delDemandItemList)
  959. // 深拷贝一下参数对象
  960. let param = JSON.parse(JSON.stringify(this.basicForm))
  961. console.log('深拷贝对象',param);
  962. param.puDemandItemList = list
  963. // this.basicForm.puDemandItemList.push(...this.delDemandItemList)
  964. editDemand(param).then(res => {
  965. if (res.code === 200) {
  966. this.$modal.notifySuccess(res.msg);
  967. this.$modal.closeLoading();
  968. this.back()
  969. }
  970. }).catch(err => {
  971. let errorList = JSON.parse(err.message).rowList
  972. console.log(errorList)
  973. this.gainRed(errorList)
  974. this.$modal.closeLoading();
  975. })
  976. }
  977. } else {
  978. let masStr = ''
  979. Object.values(data).forEach(errList => {
  980. console.log('data',data)
  981. console.log(errList)
  982. // 将子表下标加入进入标识字段
  983. this.basicForm.puDemandItemList.forEach((item,index) => {
  984. item.rightIndex = index
  985. })
  986. console.log('所有列表', this.basicForm.puDemandItemList)
  987. // 将校验未通过的项与整个表格数据进行过滤对比,得出校验通过的数据
  988. let rightList = this.basicForm.puDemandItemList.filter((item, index) => {
  989. return errList.find(item2 => {
  990. return item2.rowIndex !== item.rightIndex
  991. })
  992. })
  993. console.log('xxx',rightList)
  994. rightList.forEach(items => {
  995. if (this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${items.rightIndex+1})`)) {
  996. this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${items.rightIndex+1})`).style.background = ''
  997. }
  998. })
  999. errList.forEach(params => {
  1000. let { rowIndex, column, rules } = params
  1001. rules.forEach(rule => {
  1002. masStr += `第 ${rowIndex + 1} 行${rule.message};`
  1003. })
  1004. if (this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${rowIndex+1})`)) {
  1005. this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${rowIndex+1})`).style.background = '#f34b4bb8'
  1006. }
  1007. })
  1008. })
  1009. this.$modal.notifyError(masStr);
  1010. }
  1011. })
  1012. } else {
  1013. // 校验加弹窗
  1014. const jiaoyan = []
  1015. for(let key in obj) {
  1016. jiaoyan.push(obj[key][0].message);
  1017. }
  1018. this.$modal.notifyWarning(jiaoyan[0]);
  1019. return false
  1020. }
  1021. })
  1022. } else {
  1023. this.$modal.notifyWarning("明细信息不能为空!");
  1024. }
  1025. },
  1026. // 后端校验标红方法
  1027. gainRed(errList) {
  1028. // 将子表下标加入进入标识字段
  1029. this.basicForm.puDemandItemList.forEach((item,index) => {
  1030. item.rightIndex = index
  1031. })
  1032. console.log('所有列表', this.basicForm.puDemandItemList)
  1033. // 将校验未通过的项与整个表格数据进行过滤对比,得出校验通过的数据
  1034. let rightList = this.basicForm.puDemandItemList.filter((item, index) => {
  1035. return errList.find(item2 => {
  1036. return item2.rowIndex !== item.rightIndex
  1037. })
  1038. })
  1039. console.log('xxx',rightList)
  1040. rightList.forEach(items => {
  1041. if (this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${items.rightIndex+1})`)) {
  1042. this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${items.rightIndex+1})`).style.background = ''
  1043. }
  1044. })
  1045. errList.forEach(item => {
  1046. if (this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${item/10})`)) {
  1047. this.$refs.table.$el.querySelector(`.elx-body--row:nth-of-type(${item/10})`).style.background = '#f34b4bb8'
  1048. }
  1049. })
  1050. },
  1051. submit() {
  1052. this.$modal.loading("提交中...");
  1053. submitDemand(this.basicForm).then(res => {
  1054. if (res.code === 200) {
  1055. this.$modal.notifySuccess("提交成功");
  1056. this.$modal.closeLoading();
  1057. this.back()
  1058. }
  1059. }).catch(err => {
  1060. let errorList = JSON.parse(err.message).rowList
  1061. console.log(errorList)
  1062. this.gainRed(errorList)
  1063. this.$modal.closeLoading();
  1064. })
  1065. },
  1066. // 增行
  1067. addLine() {
  1068. const newLine = {...this.sonModel}
  1069. newLine.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1070. newLine.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1071. newLine.demandCustomer = this.basicForm.customer
  1072. newLine.demandCustomerName = this.basicForm.customerName
  1073. this.basicForm.puDemandItemList.push(newLine)
  1074. // 补单需求状态改变
  1075. if (this.basicForm.billType == 'BDXQ') {
  1076. this.BDZT = false
  1077. } else {
  1078. this.BDZT = true
  1079. }
  1080. },
  1081. delLine(index, row) {
  1082. console.log('删除行:', index)
  1083. console.log('改变行:', row)
  1084. row.delFlag = '2'
  1085. let delList = []
  1086. delList = this.basicForm.puDemandItemList.filter(item => {
  1087. return item.delFlag == '2'
  1088. })
  1089. this.basicForm.puDemandItemList = this.basicForm.puDemandItemList.filter(item => {
  1090. return item.delFlag == '0'
  1091. })
  1092. this.delDemandItemList.push(...delList)
  1093. console.log('删除的数组',this.delDemandItemList)
  1094. },
  1095. back() {
  1096. console.log('打印人员信息看看', this.$store.state)
  1097. this.$emit('jugislist', true)
  1098. this.$emit('refresh')
  1099. },
  1100. // 如果需要回显则调用详情接口
  1101. getDetails(row) {
  1102. getDemandDetail(row.id).then(res => {
  1103. if (res.code === 200) {
  1104. // this.basicForm = res.data
  1105. let reciveForm = res.data
  1106. let params = {...{id: row.id}, ...{pageNum:1, pageSize: 10}}
  1107. getDemandSonDetail(params).then(res => {
  1108. if (res.code === 200) {
  1109. reciveForm.puDemandItemList = res.data
  1110. console.log('reciveForm',reciveForm)
  1111. this.basicForm = reciveForm
  1112. if(this.basicForm.org) { this.reBackRefer('ORG_PARAM', this.basicForm.org) }
  1113. if(this.basicForm.customer) { this.reBackRefer('CUSTOMER_PARAM', this.basicForm.customer) }
  1114. if(this.basicForm.customerPrincipal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.customerPrincipal, '客户负责人') }
  1115. if(this.basicForm.demandPersonal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.demandPersonal, '需求人员') }
  1116. if(this.basicForm.demandDept) { this.reBackRefer('DEPT_PARAM', this.basicForm.demandDept) }
  1117. // 详情时将收货仓库id赋值给stordocId
  1118. // 如果业务类型为补单需求,则明细内补单供应商编码可以编辑
  1119. if(this.basicForm.billType == 'BDXQ') {
  1120. this.BDZT = false
  1121. this.isBDXQ = true
  1122. } else {
  1123. this.BDZT = true
  1124. this.isBDXQ = false
  1125. }
  1126. }
  1127. }).then(() => {
  1128. this.loading = false
  1129. }).catch(err => {
  1130. this.loading = false
  1131. })
  1132. }
  1133. })
  1134. },
  1135. // 单元格标红
  1136. cellClassName({row, column, rowIndex, columnIndex}) {
  1137. if(this.basicForm.isCustomerSpecified == 'N' && column.title == "需求可用周期" && Number(row.demandPeriod) > 1.5 && Number(row.qty) > Number(row.minOrderQty)) {
  1138. return 'success-row';
  1139. }
  1140. },
  1141. handleSelectionChange(selection) {
  1142. this.ids = selection.map(item =>{
  1143. return item.id
  1144. })
  1145. console.log('选中数组', this.ids)
  1146. },
  1147. rowSelect(row) {
  1148. this.$refs.table.toggleRowSelection(row);
  1149. },
  1150. // 点击预留单展示
  1151. showReserved() {
  1152. this.dialog.config = true
  1153. },
  1154. // 修改是否让页面显示与隐藏的事件
  1155. updateReserved (val) {
  1156. this.dialog.config = val
  1157. },
  1158. // 回显参照框
  1159. reBackRefer(type, id, title) {
  1160. getRefer({type: type, id: id}).then(res => {
  1161. if(type == 'ORG_PARAM') {
  1162. this.orgOptions = res.rows
  1163. }
  1164. if (type == 'CUSTOMER_PARAM') {
  1165. this.customerOptions = res.rows
  1166. }
  1167. if (type == 'CONTACTS_PARAM' && title == '需求人员') {
  1168. this.personOptions = res.rows
  1169. }
  1170. if (type == 'CONTACTS_PARAM' && title == '客户负责人') {
  1171. this.manOptions = res.rows
  1172. }
  1173. if (type == 'DEPT_PARAM') {
  1174. this.deptOptions = res.rows
  1175. }
  1176. })
  1177. },
  1178. chooseOrg(type, isPage, title) {
  1179. this.referCondition.type = type
  1180. this.referCondition.isPage = isPage
  1181. this.referCondition.title = title
  1182. this.$refs.refer.init(this.referCondition)
  1183. },
  1184. selectionsToInput(selection) {
  1185. if(this.referCondition.type == 'ORG_PARAM' && this.referCondition.title == '选择组织') {
  1186. this.orgOptions = selection
  1187. this.basicForm.org = selection[0].id
  1188. this.basicForm.orgName = selection[0].name
  1189. }
  1190. if(this.referCondition.type == 'CUSTOMER_PARAM' && this.referCondition.title == '选择客户') {
  1191. this.customerOptions = selection
  1192. this.basicForm.customer = selection[0].id
  1193. this.basicForm.customerName = selection[0].name
  1194. this.basicForm.customerCode = selection[0].code
  1195. if(this.basicForm.puDemandItemList.length !== 0) {
  1196. this.basicForm.puDemandItemList.forEach(item => {
  1197. item.demandCustomerName = this.basicForm.customerName
  1198. item.demandCustomer = this.basicForm.customer
  1199. item.status = ''
  1200. item.buyerName = ''
  1201. item.buyer = ''
  1202. item.reservedProportion = ''
  1203. item.reservedPeriod = ''
  1204. item.reservedQty = ''
  1205. item.averageQtyMonth = ''
  1206. item.demandPeriod = ''
  1207. item.forecastClassify = ''
  1208. item.onemonthAvgVolume = ''
  1209. item.threemonthAvgVolume = ''
  1210. item.puFreight = ''
  1211. item.superiorAllotQty = ''
  1212. item.resDemandQty = ''
  1213. item.executeQty = ''
  1214. item.deliveryWarehouseName = ''
  1215. item.deliveryWarehouse = ''
  1216. item.deliveryAllocationName = ''
  1217. item.deliveryAllocation = ''
  1218. item.lastWarehouseName = ''
  1219. item.lastAllocationName = ''
  1220. item.availableQty = ''
  1221. item.lastStockOrgName = ''
  1222. item.centralWarehouseQty = ''
  1223. item.allotCode = ''
  1224. item.deliveryAddress = ''
  1225. item.deliveryAddressName = ''
  1226. item.contacts = ''
  1227. item.contactsPhone = ''
  1228. item.address = ''
  1229. })
  1230. }
  1231. }
  1232. if(this.referCondition.type == 'CONTACTS_PARAM' && this.referCondition.title == '需求人员') {
  1233. this.personOptions = selection
  1234. this.basicForm.demandPersonal = selection[0].code
  1235. this.basicForm.demandPersonalName = selection[0].name
  1236. }
  1237. if(this.referCondition.type == 'CONTACTS_PARAM' && this.referCondition.title == '采购员') {
  1238. this.purchaseManOptions = selection
  1239. this.adjust.purchaseMan = selection[0].code
  1240. this.adjust.purchaseManName = selection[0].name
  1241. }
  1242. if(this.referCondition.type == 'WAREHOUSE_PARAM' && this.referCondition.title == '收货仓库') {
  1243. this.adjust.warehouse = selection[0].id
  1244. this.adjust.warehouseName = selection[0].name
  1245. this.adjust.allocation = ''
  1246. this.adjust.allocationName = ''
  1247. }
  1248. if(this.referCondition.type == 'ALLOCATION_PARAM' && this.referCondition.title == '收货货位') {
  1249. this.adjust.allocation = selection[0].id
  1250. this.adjust.allocationName = selection[0].name
  1251. }
  1252. if(this.referCondition.type == 'ADDRESS_PARAM' && this.referCondition.title == '收货地址') {
  1253. this.adjust.deliveryAddressName = selection[0].name
  1254. this.adjust.deliveryAddress = selection[0].code
  1255. this.adjust.contacts = selection[0].contactsName
  1256. this.adjust.contactsPhone = selection[0].contactsPhone
  1257. this.adjust.address = selection[0].address
  1258. }
  1259. if(this.referCondition.type == 'DEPT_PARAM') {
  1260. this.deptOptions = selection
  1261. this.basicForm.demandDept = selection[0].id
  1262. this.basicForm.demandDeptName = selection[0].name
  1263. }
  1264. if(this.referCondition.title == '选择收货仓库') {
  1265. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouse = selection[0].id
  1266. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouseName = selection[0].name
  1267. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocation = null
  1268. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = null
  1269. }
  1270. if(this.referCondition.title == '选择收货货位') {
  1271. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocation = selection[0].id
  1272. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = selection[0].name
  1273. }
  1274. if(this.referCondition.title == '选择补单供应商') {
  1275. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplier = selection[0].id
  1276. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplierName = selection[0].name
  1277. }
  1278. if(this.referCondition.title == '选择收货地址') {
  1279. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddressName = selection[0].name
  1280. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddress = selection[0].code
  1281. this.basicForm.puDemandItemList[this.tableIndex].contacts = selection[0].contactsName
  1282. this.basicForm.puDemandItemList[this.tableIndex].contactsPhone = selection[0].contactsPhone
  1283. this.basicForm.puDemandItemList[this.tableIndex].address = selection[0].address
  1284. }
  1285. },
  1286. // 粘贴来的数据
  1287. async pasteMe(e, scope, index) {
  1288. this.$modal.loading("正在处理数据...");
  1289. e.preventDefault() //阻止默认粘贴事件
  1290. let source = e.clipboardData.getData("Text");
  1291. console.log('scope', scope.column.property)
  1292. // 首先对源头进行解析
  1293. let rows = source.split("\r\n"); // 拆成一个数组
  1294. // 数组去除空字符串
  1295. rows = rows.filter(item => {
  1296. return item && item.trim()
  1297. })
  1298. if (rows.length < 100) {
  1299. // 粘贴物料编码
  1300. if(scope.column.property == 'materialCode') {
  1301. await getRefer({ type: 'MATERIAL_PARAM', materialCodeList: rows }).then(res => {
  1302. this.$modal.closeLoading();
  1303. if (res.code === 200) {
  1304. let rowList = res.rows
  1305. let newLine = []
  1306. for (let i = 0; i<rowList.length; i++) {
  1307. let line = {...this.sonModel}
  1308. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1309. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1310. line.demandCustomer = this.basicForm.customer
  1311. line.demandCustomerName = this.basicForm.customerName
  1312. line.materialCode = rowList[i].code
  1313. line.material = rowList[i].id
  1314. line.materialName = rowList[i].name
  1315. line.classifyId = rowList[i].classifyId
  1316. line.materialClassifyOneName = rowList[i].oneClass
  1317. line.materialClassifyTwoName = rowList[i].twoClass
  1318. line.materialClassifyThreeName = rowList[i].threeClass
  1319. line.materialClassifyFourName = rowList[i].fourClass
  1320. line.specification = rowList[i].specification
  1321. line.model = rowList[i].model
  1322. line.unit = rowList[i].unitId
  1323. line.unitName = rowList[i].unitIdName
  1324. line.registrant = rowList[i].registrant
  1325. line.manufacturerName = rowList[i].manufacturerIdName
  1326. line.puPeriod = rowList[i].deliveryPeriod
  1327. line.expiry = rowList[i].usefulLife
  1328. line.expiryUnit = rowList[i].expiryUnitIdName
  1329. // line.minPackage = rowList[i].usefulLife
  1330. line.minPackage = rowList[i].minPackQty
  1331. line.minOrderQty = rowList[i].minOrderQty
  1332. line.minBatch = rowList[i].minBatchQty
  1333. line.safeStock = rowList[i].safeStock
  1334. line.purOrgName = rowList[i].purchasingOrganizationName
  1335. line.puOrg = rowList[i].purchasingOrganization
  1336. // 物料存储条件和运输条件
  1337. line.transportationCondition = rowList[i].transportationCondition
  1338. line.storageCondition = rowList[i].storageCondition
  1339. newLine.push(line)
  1340. console.log('临时数组', newLine)
  1341. }
  1342. // 删除指定下标
  1343. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1344. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  1345. }
  1346. }).then(() => {
  1347. this.$refs.table.doLayout()
  1348. }).catch(err => {
  1349. this.$modal.closeLoading();
  1350. })
  1351. // 粘贴实际业务需求量
  1352. }else if(scope.column.property == 'qty') {
  1353. console.log('复制内容:', rows)
  1354. let newLine = []
  1355. if(this.basicForm.puDemandItemList.length <= 1) {
  1356. for (let i = 0; i<rows.length; i++) {
  1357. let line = {...this.sonModel}
  1358. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1359. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1360. line.demandCustomer = this.basicForm.customer
  1361. line.demandCustomerName = this.basicForm.customerName
  1362. line.qty = rows[i]
  1363. newLine.push(line)
  1364. }
  1365. // 删除指定下标
  1366. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1367. this.$modal.notifySuccess("共粘贴" + rows.length + '条数据');
  1368. this.$refs.table.doLayout()
  1369. this.$modal.closeLoading();
  1370. } else {
  1371. for(let i = index , j = 0; i < this.basicForm.puDemandItemList.length; i++, j++) {
  1372. this.basicForm.puDemandItemList[i].qty = rows[j]
  1373. }
  1374. this.$refs.table.doLayout()
  1375. this.$modal.closeLoading();
  1376. }
  1377. // 粘贴补单供应商
  1378. }else if(scope.column.property == 'additionalSupplierName') {
  1379. await getRefer({ type: 'SUPPLIER_PARAM', searchList: rows }).then(res => {
  1380. this.$modal.closeLoading();
  1381. if (res.code === 200) {
  1382. let rowList = res.rows
  1383. let newLine = []
  1384. for (let i = 0; i<rowList.length; i++) {
  1385. let line = {...this.sonModel}
  1386. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1387. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1388. line.demandCustomer = this.basicForm.customer
  1389. line.demandCustomerName = this.basicForm.customerName
  1390. line.additionalSupplier = rowList[i].id
  1391. line.additionalSupplierName = rowList[i].name
  1392. newLine.push(line)
  1393. console.log('临时数组', newLine)
  1394. }
  1395. if(this.basicForm.puDemandItemList.length <= 1) {
  1396. // 删除指定下标
  1397. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1398. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  1399. } else {
  1400. for(let i = index , j = 0; i < this.basicForm.puDemandItemList.length; i++, j++) {
  1401. this.basicForm.puDemandItemList[i].additionalSupplier = newLine[j].additionalSupplier
  1402. this.basicForm.puDemandItemList[i].additionalSupplierName = newLine[j].additionalSupplierName
  1403. }
  1404. this.$refs.table.doLayout()
  1405. this.$modal.closeLoading();
  1406. }
  1407. }
  1408. }).then(() => {
  1409. this.$refs.table.doLayout()
  1410. }).catch(err => {
  1411. this.$modal.closeLoading();
  1412. })
  1413. }else if(scope.column.property == 'deliveryAddressName') {
  1414. await getRefer({ type: 'ADDRESS_PARAM', searchList: rows }).then(res => {
  1415. this.$modal.closeLoading();
  1416. if (res.code === 200) {
  1417. let rowList = res.rows
  1418. let newLine = []
  1419. for (let i = 0; i<rowList.length; i++) {
  1420. let line = {...this.sonModel}
  1421. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1422. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1423. line.demandCustomer = this.basicForm.customer
  1424. line.demandCustomerName = this.basicForm.customerName
  1425. line.deliveryAddressName = rowList[i].name
  1426. line.deliveryAddress = rowList[i].code
  1427. line.contacts = rowList[i].contactsName
  1428. line.contactsPhone = rowList[i].contactsPhone
  1429. line.address = rowList[i].address
  1430. newLine.push(line)
  1431. console.log('临时数组', newLine)
  1432. }
  1433. if(this.basicForm.puDemandItemList.length <= 1) {
  1434. // 删除指定下标
  1435. this.basicForm.puDemandItemList.splice(index,this.basicForm.puDemandItemList.length - index,...newLine)
  1436. this.$modal.notifySuccess("共粘贴" + rowList.length + '条数据');
  1437. } else {
  1438. for(let i = index , j = 0; i < this.basicForm.puDemandItemList.length; i++, j++) {
  1439. this.basicForm.puDemandItemList[i].deliveryAddressName = newLine[j].deliveryAddressName
  1440. this.basicForm.puDemandItemList[i].deliveryAddress = newLine[j].deliveryAddress
  1441. this.basicForm.puDemandItemList[i].contacts = newLine[j].contacts
  1442. this.basicForm.puDemandItemList[i].contactsPhone = newLine[j].contactsPhone
  1443. this.basicForm.puDemandItemList[i].address = newLine[j].address
  1444. }
  1445. this.$refs.table.doLayout()
  1446. this.$modal.closeLoading();
  1447. }
  1448. }
  1449. }).then(() => {
  1450. this.$refs.table.doLayout()
  1451. }).catch(err => {
  1452. this.$modal.closeLoading();
  1453. })
  1454. }
  1455. } else {
  1456. this.$modal.notifyWarning("复制长度不能超过100!");
  1457. this.$modal.closeLoading();
  1458. }
  1459. },
  1460. // 明细行选择物料编码带出数据
  1461. chooseMaterial(index) {
  1462. console.log("🚀 ~ file: add.vue:790 ~ chooseMaterial ~ index:", index)
  1463. this.tableIndex = index
  1464. // 传0只展示同步NC了的物料
  1465. this.$refs.materialRefer.init(0)
  1466. },
  1467. selectMaterial(selection) {
  1468. console.log('选中的物料', selection)
  1469. if (selection.length <= 1) {
  1470. // 选择新物料时先清空行内其他信息
  1471. this.basicForm.puDemandItemList[this.tableIndex].reservedProportion = null
  1472. this.basicForm.puDemandItemList[this.tableIndex].reservedPeriod = null
  1473. this.basicForm.puDemandItemList[this.tableIndex].reservedQty = null
  1474. this.basicForm.puDemandItemList[this.tableIndex].qty = null
  1475. this.basicForm.puDemandItemList[this.tableIndex].deliveryDate = null
  1476. this.basicForm.puDemandItemList[this.tableIndex].remark = null
  1477. this.basicForm.puDemandItemList[this.tableIndex].resDemandQty = null
  1478. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouse = null
  1479. this.basicForm.puDemandItemList[this.tableIndex].deliveryWarehouseName = null
  1480. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocation = null
  1481. this.basicForm.puDemandItemList[this.tableIndex].deliveryAllocationName = null
  1482. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplier = null
  1483. this.basicForm.puDemandItemList[this.tableIndex].additionalSupplierName = null
  1484. this.basicForm.puDemandItemList[this.tableIndex].periodUnit = null
  1485. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddressName = null
  1486. this.basicForm.puDemandItemList[this.tableIndex].deliveryAddress = null
  1487. this.basicForm.puDemandItemList[this.tableIndex].contacts = null
  1488. this.basicForm.puDemandItemList[this.tableIndex].contactsPhone = null
  1489. this.basicForm.puDemandItemList[this.tableIndex].address = null
  1490. this.basicForm.puDemandItemList[this.tableIndex].priceType = 'order'
  1491. this.basicForm.puDemandItemList[this.tableIndex].lastWarehouseName = null
  1492. this.basicForm.puDemandItemList[this.tableIndex].lastWarehouse = null
  1493. this.basicForm.puDemandItemList[this.tableIndex].lastAllocation = null
  1494. this.basicForm.puDemandItemList[this.tableIndex].lastAllocationName = null
  1495. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyOne = null
  1496. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyTwo = null
  1497. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyThree = null
  1498. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyFour = null
  1499. this.basicForm.puDemandItemList[this.tableIndex].lastStockOrg = null
  1500. this.basicForm.puDemandItemList[this.tableIndex].lastStockOrgName = null
  1501. this.basicForm.puDemandItemList[this.tableIndex].buyer = null
  1502. this.basicForm.puDemandItemList[this.tableIndex].buyerName = null
  1503. // 通过选择物料查询采购员
  1504. queryMan(selection[0].id).then(res => {
  1505. if(res.code === 200 && res.rows.length !== 0) {
  1506. this.basicForm.puDemandItemList[this.tableIndex].buyer = res.rows[0].buyer
  1507. this.basicForm.puDemandItemList[this.tableIndex].buyerName = res.rows[0].buyerName
  1508. }
  1509. })
  1510. this.basicForm.puDemandItemList[this.tableIndex].materialCode = selection[0].code
  1511. this.basicForm.puDemandItemList[this.tableIndex].material = selection[0].id
  1512. this.basicForm.puDemandItemList[this.tableIndex].materialName = selection[0].name
  1513. this.basicForm.puDemandItemList[this.tableIndex].classifyId = selection[0].classifyId
  1514. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyOneName = selection[0].oneClass
  1515. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyTwoName = selection[0].twoClass
  1516. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyThreeName = selection[0].threeClass
  1517. this.basicForm.puDemandItemList[this.tableIndex].materialClassifyFourName = selection[0].fourClass
  1518. this.basicForm.puDemandItemList[this.tableIndex].specification = selection[0].specification
  1519. this.basicForm.puDemandItemList[this.tableIndex].model = selection[0].model
  1520. this.basicForm.puDemandItemList[this.tableIndex].unit = selection[0].unitId
  1521. this.basicForm.puDemandItemList[this.tableIndex].unitName = selection[0].unitIdName
  1522. this.basicForm.puDemandItemList[this.tableIndex].registrant = selection[0].registrant
  1523. this.basicForm.puDemandItemList[this.tableIndex].manufacturerName = selection[0].manufacturerIdName
  1524. this.basicForm.puDemandItemList[this.tableIndex].puPeriod = selection[0].deliveryPeriod
  1525. this.basicForm.puDemandItemList[this.tableIndex].expiry = selection[0].usefulLife
  1526. this.basicForm.puDemandItemList[this.tableIndex].expiryUnit = selection[0].expiryUnitIdName
  1527. // this.basicForm.puDemandItemList[this.tableIndex].minPackage = selection[0].usefulLife
  1528. this.basicForm.puDemandItemList[this.tableIndex].minPackage = selection[0].minPackQty
  1529. this.basicForm.puDemandItemList[this.tableIndex].minOrderQty = selection[0].minOrderQty
  1530. this.basicForm.puDemandItemList[this.tableIndex].minBatch = selection[0].minBatchQty
  1531. this.basicForm.puDemandItemList[this.tableIndex].safeStock = selection[0].safeStock
  1532. this.basicForm.puDemandItemList[this.tableIndex].purOrgName = selection[0].purchasingOrganizationName
  1533. this.basicForm.puDemandItemList[this.tableIndex].puOrg = selection[0].purchasingOrganization
  1534. // 物料存储条件和运输条件
  1535. this.basicForm.puDemandItemList[this.tableIndex].transportationCondition = selection[0].transportationCondition
  1536. this.basicForm.puDemandItemList[this.tableIndex].storageCondition = selection[0].storageCondition
  1537. // 选中骨科耗材时候的物料,需求客户不必填
  1538. } else {
  1539. console.log('xxxxx', selection)
  1540. let newLine = []
  1541. for (let i = 0;i<selection.length;i++) {
  1542. let line = {...this.sonModel}
  1543. line.isUrgency = (this.basicForm.billType == 'JJXQ' ? 'Y' : 'N')
  1544. line.isReplenishment = (this.basicForm.billType == 'BDXQ' ? 'Y' : 'N')
  1545. line.demandCustomer = this.basicForm.customer
  1546. line.demandCustomerName = this.basicForm.customerName
  1547. // 通过选择物料查询采购员
  1548. queryMan(selection[i].id).then(res => {
  1549. if (res.code === 200 && res.rows.length !== 0) {
  1550. line.buyer = res.rows[0].buyer
  1551. line.buyerName = res.rows[0].buyerName
  1552. }
  1553. })
  1554. line.materialCode = selection[i].code
  1555. line.material = selection[i].id
  1556. line.materialName = selection[i].name
  1557. line.classifyId = selection[i].classifyId
  1558. line.materialClassifyOneName = selection[i].oneClass
  1559. line.materialClassifyTwoName = selection[i].twoClass
  1560. line.materialClassifyThreeName = selection[i].threeClass
  1561. line.materialClassifyFourName = selection[i].fourClass
  1562. line.specification = selection[i].specification
  1563. line.model = selection[i].model
  1564. line.unit = selection[i].unitId
  1565. line.unitName = selection[i].unitIdName
  1566. line.registrant = selection[i].registrant
  1567. line.manufacturerName = selection[i].manufacturerIdName
  1568. line.puPeriod = selection[i].deliveryPeriod
  1569. line.expiry = selection[i].usefulLife
  1570. line.expiryUnit = selection[i].expiryUnitIdName
  1571. // line.minPackage = selection[i].usefulLife
  1572. line.minPackage = selection[i].minPackQty
  1573. line.minOrderQty = selection[i].minOrderQty
  1574. line.minBatch = selection[i].minBatchQty
  1575. line.safeStock = selection[i].safeStock
  1576. line.purOrgName = selection[i].purchasingOrganizationName
  1577. line.puOrg = selection[i].purchasingOrganization
  1578. // 物料存储条件和运输条件
  1579. line.transportationCondition = selection[i].transportationCondition
  1580. line.storageCondition = selection[i].storageCondition
  1581. // this.basicForm.puDemandItemList.push(line)
  1582. newLine.push(line)
  1583. }
  1584. // 删除指定下标
  1585. this.basicForm.puDemandItemList.splice(this.tableIndex,1,...newLine)
  1586. // this.basicForm.puDemandItemList.splice(this.tableIndex,1)
  1587. }
  1588. },
  1589. // 明细行选择参照
  1590. chooseDept(index, type, isPage, title) {
  1591. this.tableIndex = index
  1592. this.referCondition.type = type
  1593. this.referCondition.isPage = isPage
  1594. this.referCondition.title = title
  1595. this.$refs.refer.init(this.referCondition)
  1596. },
  1597. // 明细行选择仓库需要先确认采购组织
  1598. chooseCangKu(index, type, isPage, title, pkOrg) {
  1599. this.tableIndex = index
  1600. this.referCondition.type = type
  1601. this.referCondition.isPage = isPage
  1602. this.referCondition.title = title
  1603. if(pkOrg) {
  1604. this.referCondition.pkOrg = pkOrg
  1605. this.$refs.refer.init(this.referCondition)
  1606. } else {
  1607. this.$modal.notifyWarning("请先确认默认采购组织");
  1608. }
  1609. },
  1610. // 明细行选择货位先确认仓库
  1611. choosehuoWei(index, type, isPage, title, stordocId) {
  1612. this.tableIndex = index
  1613. this.referCondition.type = type
  1614. this.referCondition.isPage = isPage
  1615. this.referCondition.title = title
  1616. // 选择收货货位前先选择收货仓库
  1617. if(stordocId) {
  1618. this.referCondition.stordocId = stordocId
  1619. this.$refs.refer.init(this.referCondition)
  1620. } else {
  1621. this.$modal.notifyWarning("请先选择收货仓库");
  1622. }
  1623. },
  1624. // 明细行清空收货仓库,货位,收货地址档案等
  1625. clearHang(index, title) {
  1626. if (title == '选择收货仓库') {
  1627. this.basicForm.puDemandItemList[index].deliveryWarehouseName = null
  1628. this.basicForm.puDemandItemList[index].deliveryWarehouse = null
  1629. this.basicForm.puDemandItemList[index].deliveryAllocationName = null
  1630. this.basicForm.puDemandItemList[index].deliveryAllocation = null
  1631. }
  1632. if (title == '选择收货货位') {
  1633. this.basicForm.puDemandItemList[index].deliveryAllocationName = null
  1634. this.basicForm.puDemandItemList[index].deliveryAllocation = null
  1635. }
  1636. if (title == '选择收货地址') {
  1637. this.basicForm.puDemandItemList[index].deliveryAddressName = null
  1638. this.basicForm.puDemandItemList[index].deliveryAddress = null
  1639. this.basicForm.puDemandItemList[index].contacts = null
  1640. this.basicForm.puDemandItemList[index].contactsPhone = null
  1641. this.basicForm.puDemandItemList[index].address = null
  1642. }
  1643. if (title == '选择补单供应商') {
  1644. this.basicForm.puDemandItemList[index].additionalSupplierName = null
  1645. this.basicForm.puDemandItemList[index].additionalSupplier = null
  1646. }
  1647. },
  1648. // 清除需求客户将明细行内也清空
  1649. cleanCustomer() {
  1650. this.basicForm.customer = ''
  1651. this.basicForm.customerName = ''
  1652. this.basicForm.customerCode = ''
  1653. if (this.basicForm.puDemandItemList.length !== 0) {
  1654. this.basicForm.puDemandItemList.forEach(item => {
  1655. item.demandCustomerName = ''
  1656. item.demandCustomer = ''
  1657. item.status = ''
  1658. item.buyerName = ''
  1659. item.buyer = ''
  1660. item.reservedProportion = ''
  1661. item.reservedPeriod = ''
  1662. item.reservedQty = ''
  1663. item.averageQtyMonth = ''
  1664. item.demandPeriod = ''
  1665. item.forecastClassify = ''
  1666. item.onemonthAvgVolume = ''
  1667. item.threemonthAvgVolume = ''
  1668. item.puFreight = ''
  1669. item.superiorAllotQty = ''
  1670. item.resDemandQty = ''
  1671. item.executeQty = ''
  1672. item.deliveryWarehouseName = ''
  1673. item.deliveryWarehouse = ''
  1674. item.deliveryAllocationName = ''
  1675. item.deliveryAllocation = ''
  1676. item.lastWarehouseName = ''
  1677. item.lastAllocationName = ''
  1678. item.availableQty = ''
  1679. item.lastStockOrgName = ''
  1680. item.centralWarehouseQty = ''
  1681. item.allotCode = ''
  1682. item.deliveryAddress = ''
  1683. item.deliveryAddressName = ''
  1684. item.contacts = ''
  1685. item.contactsPhone = ''
  1686. item.address = ''
  1687. })
  1688. }
  1689. },
  1690. // 批量调整
  1691. adjustPl() {
  1692. if(this.ids.length == 0) {
  1693. this.$modal.notifyWarning('请至少选择一项数据进行操作!')
  1694. } else {
  1695. this.adjust.open = true
  1696. }
  1697. },
  1698. // 批量调整确认
  1699. confirmAdjust() {
  1700. console.log('data', this.adjust)
  1701. this.basicForm.puDemandItemList.forEach(item => {
  1702. this.ids.some(val => {
  1703. if(val == item.id) {
  1704. if(this.adjust.purchaseMan) {
  1705. item.buyer = this.adjust.purchaseMan
  1706. item.buyerName = this.adjust.purchaseManName
  1707. }
  1708. if(this.adjust.priceType) {
  1709. item.priceType = this.adjust.priceType
  1710. }
  1711. if(this.adjust.warehouseName) {
  1712. item.deliveryWarehouse = this.adjust.warehouse
  1713. item.deliveryWarehouseName = this.adjust.warehouseName
  1714. item.deliveryAllocation = this.adjust.allocation
  1715. item.deliveryAllocationName = this.adjust.allocationName
  1716. }
  1717. // if(this.adjust.allocationName) {
  1718. // item.deliveryAllocation = this.adjust.allocation
  1719. // item.deliveryAllocationName = this.adjust.allocationName
  1720. // }
  1721. if(this.adjust.remark) {
  1722. item.remark = this.adjust.remark
  1723. }
  1724. if(this.adjust.deliveryAddressName) {
  1725. item.deliveryAddressName = this.adjust.deliveryAddressName
  1726. item.deliveryAddress = this.adjust.deliveryAddress
  1727. item.contacts = this.adjust.contacts
  1728. item.contactsPhone = this.adjust.contactsPhone
  1729. item.address = this.adjust.address
  1730. }
  1731. }
  1732. this.adjust.open = false
  1733. })
  1734. })
  1735. },
  1736. // 批量调整选择货位
  1737. adjustHuoWei(type, isPage, title, stordocId) {
  1738. this.referCondition.type = type
  1739. this.referCondition.isPage = isPage
  1740. this.referCondition.title = title
  1741. // 选择收货货位前先选择收货仓库
  1742. if (stordocId) {
  1743. this.referCondition.stordocId = stordocId
  1744. this.$refs.refer.init(this.referCondition)
  1745. } else {
  1746. this.$modal.notifyWarning("请先选择收货仓库");
  1747. }
  1748. },
  1749. // 关闭清空批量调整数据
  1750. closeEvent() {
  1751. this.adjust = {
  1752. open: false,
  1753. priceType: '',
  1754. purchaseMan: '',
  1755. purchaseManName: '',
  1756. warehouse: '',
  1757. warehouseName: '',
  1758. allocation: '',
  1759. allocationName: '',
  1760. remark: '',
  1761. deliveryAddress: '',
  1762. deliveryAddressName: '',
  1763. contacts: '',
  1764. contactsPhone: '',
  1765. address: ''
  1766. }
  1767. },
  1768. // 必选标识
  1769. addRedStar(h, { column }) {
  1770. return [
  1771. h('span', { style: 'color: #F56C6C' }, '*'),
  1772. h('span', ' ' + column.label)
  1773. ];
  1774. },
  1775. // 表格表头标星
  1776. anotherRedStar(h, { column }) {
  1777. if(this.isBDXQ) {
  1778. return [
  1779. h('span', { style: 'color: #F56C6C' }, '*'),
  1780. h('span', ' ' + column.label)
  1781. ];
  1782. } else {
  1783. return [
  1784. h('span', ' ' + column.label)
  1785. ];
  1786. }
  1787. },
  1788. // 流程跳转
  1789. jumpOA() {
  1790. toOA(this.$store.state.user.name, this.basicForm.flowId).then(res => {
  1791. if(res.code === 200) {
  1792. window.open(res.oaUrl)
  1793. }
  1794. })
  1795. },
  1796. }
  1797. }
  1798. </script>
  1799. <style lang="scss" scoped>
  1800. .btn_group {
  1801. // width: 100%;
  1802. // margin: 20px 0;
  1803. display: flex;
  1804. justify-content: space-between;
  1805. position: absolute;
  1806. top: 10px;right: 20px;
  1807. }
  1808. .btn_grooup {
  1809. margin-bottom: 10px;
  1810. display: flex;
  1811. justify-content: space-between;
  1812. }
  1813. .hang {
  1814. margin: auto;
  1815. }
  1816. .hang ::v-deep .el-form-item__content{
  1817. margin-left: 0px !important;
  1818. }
  1819. // .el-table ::v-deep .el-form-item__error{
  1820. // padding-top: 0;
  1821. // top: 70%
  1822. // }
  1823. ::v-deep .elx-body--row .success-row {
  1824. background-color: #f11616!important;
  1825. }
  1826. ::v-deep .uxbeautifyTableClass .elx-table--header-wrapper {
  1827. color: #606266;
  1828. }
  1829. .pltzTxt{
  1830. text-align: right;
  1831. font-size: medium;
  1832. padding-right: 2%;
  1833. }
  1834. .pltzIpt{
  1835. width: 90%;
  1836. }
  1837. </style>