add.vue 86 KB

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