add.vue 83 KB

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