add.vue 82 KB

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