inventoryTable.vue 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. :datasource="form.datasource"
  8. class="time-form"
  9. height="300"
  10. full-height="calc(100vh - 76px)"
  11. @columns-change="handleColumnChange"
  12. :cache-key="cacheKeyUrl"
  13. :selection.sync="selection"
  14. >
  15. <!-- 表头工具栏 -->
  16. <template v-slot:toolbar>
  17. <div class="headbox">
  18. <div>
  19. <el-button
  20. size="small"
  21. type="primary"
  22. icon="el-icon-plus"
  23. class="ele-btn-icon"
  24. @click="handParent('', -1)"
  25. >
  26. 新增
  27. </el-button>
  28. <el-button
  29. size="small"
  30. type="primary"
  31. icon="el-icon-plus"
  32. class="ele-btn-icon"
  33. v-if="isGoods"
  34. @click="handGoods(-1)"
  35. >
  36. 选择商品
  37. </el-button>
  38. <el-button
  39. size="small"
  40. type="primary"
  41. icon="el-icon-plus"
  42. class="ele-btn-icon"
  43. v-if="isTemporary"
  44. @click="handlAdd"
  45. >
  46. 新增临时产品
  47. </el-button>
  48. <el-button
  49. size="small"
  50. type="primary"
  51. class="ele-btn-icon"
  52. @click="save"
  53. v-if="isDrawer"
  54. >
  55. 保存
  56. </el-button>
  57. <setAllValue
  58. :disabled="!selection.length"
  59. title="客户期望交期"
  60. @success="setAllValueChange"
  61. valueKey="customerExpectDeliveryDeadline"
  62. />
  63. <setAllValue
  64. :disabled="!selection.length"
  65. title="生产交付交期"
  66. valueKey="produceDeliveryDeadline"
  67. @success="setAllValueChange"
  68. />
  69. </div>
  70. <div class="pricebox">
  71. <span class="amount">总计:{{ allPrice }}元</span>
  72. <el-form-item
  73. style="width: 300px"
  74. v-if="isDiscountTotalPrice"
  75. label="优惠后总金额:"
  76. prop="discountTotalPrice"
  77. :rules="{
  78. required: true,
  79. message: '请输入优惠后总金额',
  80. trigger: 'change'
  81. }"
  82. >
  83. <el-input
  84. type="number"
  85. :min="0"
  86. :max="allPrice"
  87. :disabled="!allPrice"
  88. v-model="form.discountTotalPrice"
  89. style="width: 180px"
  90. placeholder="请输入"
  91. @input="discountInputByOrder(form.discountTotalPrice)"
  92. >
  93. <template slot="append">元</template>
  94. </el-input>
  95. </el-form-item>
  96. </div>
  97. </div>
  98. </template>
  99. <template v-slot:productName="{ row, $index }">
  100. <el-form-item
  101. :prop="'datasource.' + $index + '.productName'"
  102. :rules="{
  103. required: true,
  104. message: '请输入',
  105. trigger: 'change'
  106. }"
  107. >
  108. <el-input
  109. :disabled="!!row.productCode"
  110. v-model="row.productName"
  111. placeholder="请输入"
  112. style="width: 60%; margin-right: 10px"
  113. ></el-input>
  114. <el-button
  115. size="small"
  116. type="primary"
  117. @click.native="handParent(row, $index)"
  118. >选择
  119. </el-button>
  120. </el-form-item>
  121. </template>
  122. <template v-slot:entrustedEnterpriseId="scope">
  123. <el-form-item prop="entrustedEnterpriseId">
  124. <el-select
  125. v-model="scope.row.entrustedEnterpriseId"
  126. clearable
  127. filterable
  128. >
  129. <el-option
  130. v-for="i in scope.row.entrustedEnterpriseIdList"
  131. :key="i.id"
  132. :value="i.id"
  133. :label="i.name"
  134. ></el-option>
  135. </el-select>
  136. </el-form-item>
  137. </template>
  138. <template v-slot:headerCustomerMark="{ column }">
  139. <span class="is-required">{{ column.label }}</span>
  140. </template>
  141. <template v-slot:customerMark="{ row, $index }">
  142. <el-form-item
  143. :prop="'datasource.' + $index + '.customerMark'"
  144. :rules="{
  145. required: isCustomerMark ? true : false,
  146. message: '请输入客户代号',
  147. trigger: 'change'
  148. }"
  149. >
  150. <el-input
  151. v-model="row.customerMark"
  152. :disabled="quoteType === 2"
  153. placeholder="请输入"
  154. ></el-input>
  155. </el-form-item>
  156. </template>
  157. <template v-slot:headerProductName="{ column }">
  158. <span class="is-required">{{ column.label }}</span>
  159. </template>
  160. <template v-slot:productCode="scope">
  161. <el-form-item :prop="'datasource.' + scope.$index + '.productCode'">
  162. <el-input v-model="scope.row.productCode" :disabled="true"></el-input>
  163. </el-form-item>
  164. </template>
  165. <template v-slot:productCategoryName="scope">
  166. <el-form-item
  167. :prop="'datasource.' + scope.$index + '.productCategoryName'"
  168. >
  169. <el-input v-model="scope.row.productCategoryName" disabled></el-input>
  170. </el-form-item>
  171. </template>
  172. <template v-slot:headerTotalCount="{ column }">
  173. <span :class="{ 'is-required': isTotalCount }">{{ column.label }}</span>
  174. </template>
  175. <template v-slot:headerTaxRate="{ column }">
  176. <span class="is-required">{{ column.label }}</span>
  177. </template>
  178. <template v-slot:totalPrice="scope">
  179. <el-form-item :prop="'datasource.' + scope.$index + '.totalPrice'">
  180. {{ (Number(scope.row.totalPrice) || 0).toFixed(2) }}元
  181. </el-form-item>
  182. </template>
  183. <template v-slot:productBrand="scope">
  184. <el-form-item :prop="'datasource.' + scope.$index + '.productBrand'">
  185. <el-input
  186. v-model="scope.row.productBrand"
  187. :disabled="!!scope.row.productCode"
  188. ></el-input>
  189. </el-form-item>
  190. </template>
  191. <template v-slot:modelType="scope">
  192. <el-form-item :prop="'datasource.' + scope.$index + '.modelType'">
  193. <el-input
  194. v-model="scope.row.modelType"
  195. :disabled="!!scope.row.productCode"
  196. ></el-input>
  197. </el-form-item>
  198. </template>
  199. <template v-slot:specification="scope">
  200. <el-form-item :prop="'datasource.' + scope.$index + '.specification'">
  201. <el-input
  202. v-model="scope.row.specification"
  203. :disabled="!!scope.row.productCode"
  204. ></el-input>
  205. </el-form-item>
  206. </template>
  207. <template v-slot:guaranteePeriod="scope">
  208. <div class="period">
  209. <div class="borderleftnone">
  210. <el-form-item
  211. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  212. :rules="{
  213. pattern: numberReg,
  214. message: '请输入有效期',
  215. trigger: 'blur'
  216. }"
  217. >
  218. <el-input
  219. v-model="scope.row.guaranteePeriod"
  220. @change="
  221. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  222. "
  223. placeholder="请输入"
  224. ></el-input>
  225. </el-form-item>
  226. </div>
  227. <div class="borderrightnone">
  228. <DictSelection
  229. dictName="质保期单位"
  230. clearable
  231. v-model="scope.row.guaranteePeriodUnitCode"
  232. @change="
  233. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  234. "
  235. :isOne="scope.$index === 0"
  236. >
  237. </DictSelection>
  238. </div>
  239. </div>
  240. </template>
  241. <template v-slot:measuringUnit="scope">
  242. <el-form-item :prop="'datasource.' + scope.$index + '.measuringUnit'">
  243. <el-input
  244. v-model="scope.row.measuringUnit"
  245. :disabled="!!scope.row.productCode"
  246. placeholder="请输入"
  247. ></el-input>
  248. </el-form-item>
  249. </template>
  250. <template v-slot:remark="scope">
  251. <el-form-item :prop="'datasource.' + scope.$index + '.remark'">
  252. <el-input
  253. v-model="scope.row.remark"
  254. type="textarea"
  255. placeholder="请输入"
  256. ></el-input>
  257. </el-form-item>
  258. </template>
  259. <template v-slot:singlePrice="scope">
  260. <el-form-item
  261. :prop="'datasource.' + scope.$index + '.singlePrice'"
  262. :rules="{
  263. required: quoteType !== 2 && isSinglePrice ? true : false,
  264. message: '请输入单价',
  265. trigger: 'change'
  266. }"
  267. >
  268. <el-input
  269. v-model="scope.row.singlePrice"
  270. placeholder="请输入"
  271. :disabled="quoteType === 2"
  272. @input="changeCount(scope.row, scope.$index)"
  273. type="number"
  274. >
  275. <template slot="append">元</template>
  276. </el-input>
  277. </el-form-item>
  278. </template>
  279. <template v-slot:taxRate="scope">
  280. <el-form-item
  281. :prop="'datasource.' + scope.$index + '.taxRate'"
  282. :rules="{
  283. required: isTaxRate == 1 ? true : false,
  284. message: '请输入税率',
  285. trigger: 'change'
  286. }"
  287. >
  288. <el-input
  289. v-model="scope.row.taxRate"
  290. placeholder="请输入"
  291. type="number"
  292. :disabled="quoteType === 2"
  293. @input="getNotaxSinglePrice"
  294. >
  295. <template slot="append">%</template>
  296. </el-input>
  297. </el-form-item>
  298. </template>
  299. <template v-slot:headerSinglePrice="{ column }">
  300. <span :class="isSinglePrice ? 'is-required' : ''">{{
  301. column.label
  302. }}</span>
  303. </template>
  304. <template v-slot:headerCustomerExpectDeliveryDeadline="{ column }">
  305. <span :class="isDate == 1 ? 'is-required' : ''">{{
  306. column.label
  307. }}</span>
  308. </template>
  309. <template v-slot:technicalAnswerName="{ row, $index }">
  310. <el-form-item :prop="'datasource.' + $index + '.technicalAnswerName'">
  311. <el-input
  312. v-model="row.technicalAnswerName"
  313. placeholder="请输入"
  314. @click.native="handHead(row, $index)"
  315. ></el-input>
  316. </el-form-item>
  317. </template>
  318. <template v-slot:technicalParams="scope">
  319. <el-form-item :prop="'datasource.' + scope.$index + '.technicalParams'">
  320. <el-input
  321. type="textarea"
  322. v-model="scope.row.technicalParams"
  323. placeholder="请输入"
  324. ></el-input>
  325. </el-form-item>
  326. </template>
  327. <template v-slot:technicalDrawings="scope">
  328. <el-form-item
  329. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  330. >
  331. <fileMain v-model="scope.row.technicalDrawings"></fileMain>
  332. </el-form-item>
  333. </template>
  334. <template v-slot:customerReqFiles="scope">
  335. <el-form-item
  336. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  337. >
  338. <fileMain v-model="scope.row.customerReqFiles"></fileMain>
  339. </el-form-item>
  340. </template>
  341. <template v-slot:industryArtFiles="scope">
  342. <el-form-item
  343. :prop="'datasource.' + scope.$index + '.industryArtFiles'"
  344. :rules="{
  345. required: false,
  346. message: '请输入',
  347. trigger: 'change'
  348. }"
  349. >
  350. <fileMain v-model="scope.row.industryArtFiles"></fileMain>
  351. </el-form-item>
  352. </template>
  353. <template v-slot:otherFiles="scope">
  354. <el-form-item :prop="'datasource.' + scope.$index + '. otherFiles'">
  355. <fileMain v-model="scope.row.otherFiles"></fileMain>
  356. </el-form-item>
  357. </template>
  358. <template v-slot:headerProduceDeliveryDeadline="{ column }">
  359. <span
  360. :class="isProduceDeliveryDeadline && isDate == 1 ? 'is-required' : ''"
  361. >{{ column.label }}</span
  362. >
  363. </template>
  364. <template v-slot:produceDeliveryDeadline="scope">
  365. <el-form-item
  366. :prop="'datasource.' + scope.$index + '.produceDeliveryDeadline'"
  367. :rules="{
  368. required: isProduceDeliveryDeadline && isDate == 1 ? true : false,
  369. message: '选择生产交付交期',
  370. trigger: 'change'
  371. }"
  372. >
  373. <el-date-picker
  374. style="width: 140px"
  375. value-format="yyyy-MM-dd"
  376. v-model="scope.row.produceDeliveryDeadline"
  377. @change="
  378. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  379. "
  380. type="date"
  381. placeholder="选择日期"
  382. >
  383. </el-date-picker>
  384. </el-form-item>
  385. </template>
  386. <template v-slot:customerExpectDeliveryDeadline="scope">
  387. <el-form-item
  388. v-if="scope.row.arrivalWay == 1 || !scope.row.arrivalWay"
  389. :rules="{
  390. required: isDate == 1 ? true : false,
  391. message:
  392. contractBookType == 1 ? '请选择客户期望交期' : '请选择交付日期',
  393. trigger: 'change'
  394. }"
  395. :prop="
  396. 'datasource.' + scope.$index + '.customerExpectDeliveryDeadline'
  397. "
  398. >
  399. <el-date-picker
  400. style="width: 140px"
  401. v-model="scope.row.customerExpectDeliveryDeadline"
  402. value-format="yyyy-MM-dd"
  403. @change="
  404. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  405. "
  406. type="date"
  407. placeholder="选择日期"
  408. >
  409. </el-date-picker>
  410. </el-form-item>
  411. <el-form-item v-if="scope.row.arrivalWay == 2">
  412. <el-link
  413. type="primary"
  414. :underline="false"
  415. @click.native="handleMethod(scope.row, scope.$index)"
  416. >
  417. 设置分批时间
  418. </el-link>
  419. </el-form-item>
  420. </template>
  421. <template v-slot:provenance="scope">
  422. <el-form-item :prop="'datasource.' + scope.$index + '.provenance'">
  423. <DictSelection
  424. dictName="产地"
  425. clearable
  426. v-model="scope.row.provenance"
  427. :disabled="quoteType === 2"
  428. collapse-tags
  429. multiple
  430. :isOne="scope.$index === 0"
  431. >
  432. </DictSelection>
  433. </el-form-item>
  434. </template>
  435. <template v-slot:guaranteePeriodDeadline="scope">
  436. <el-form-item
  437. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  438. >
  439. <el-date-picker
  440. style="width: 140px"
  441. v-model="scope.row.guaranteePeriodDeadline"
  442. type="date"
  443. value-format="yyyy-MM-dd"
  444. placeholder="选择日期"
  445. >
  446. </el-date-picker>
  447. </el-form-item>
  448. </template>
  449. <template v-slot:singleWeight="scope">
  450. <el-form-item :prop="'datasource.' + scope.$index + '.singleWeight'">
  451. <el-input
  452. v-model="scope.row.singleWeight"
  453. @input="changeCount(scope.row, scope.$index)"
  454. placeholder="请输入"
  455. >
  456. <template slot="append">
  457. {{ scope.row.weightUnit }}
  458. </template>
  459. </el-input>
  460. </el-form-item>
  461. </template>
  462. <template v-slot:technologyRouteName="scope">
  463. <el-form-item
  464. :prop="'datasource.' + scope.$index + '.technologyRouteName'"
  465. :rules="{
  466. required: false,
  467. message: '请选择',
  468. trigger: 'change'
  469. }"
  470. >
  471. <el-input
  472. v-model="scope.row.technologyRouteName"
  473. placeholder="请选择"
  474. @click.native="openVersion(scope.$index)"
  475. ></el-input>
  476. </el-form-item>
  477. </template>
  478. <template v-slot:pricingWay="scope">
  479. <el-form-item :prop="'datasource.' + scope.$index + '.pricingWay'">
  480. <el-select
  481. v-model="scope.row.pricingWay"
  482. placeholder="请选择"
  483. :rules="{
  484. required: true,
  485. message: '请选择计价方式',
  486. trigger: 'change'
  487. }"
  488. >
  489. <el-option
  490. v-for="item in pricingWayList"
  491. :key="item.id"
  492. :label="item.name"
  493. :value="item.id"
  494. @click.native="changeCount(scope.row, scope.$index)"
  495. >
  496. </el-option>
  497. </el-select>
  498. </el-form-item>
  499. </template>
  500. <template v-slot:headerPricingWay="{ column }">
  501. <span class="is-required">{{ column.label }}</span>
  502. </template>
  503. <template v-slot:taskName="scope">
  504. <el-form-item :prop="'datasource.' + scope.$index + '.taskName'">
  505. <el-input
  506. v-model="scope.row.taskName"
  507. placeholder="请选择"
  508. style="width: 60%; margin-right: 10px"
  509. disabled
  510. ></el-input>
  511. <el-button
  512. v-if="scope.row.productCode"
  513. size="small"
  514. type="primary"
  515. @click.native="handleTaskinstance(scope.row, scope.$index)"
  516. >选择
  517. </el-button>
  518. </el-form-item>
  519. </template>
  520. <template v-slot:arrivalWay="scope">
  521. <el-form-item :prop="'datasource.' + scope.$index + '.arrivalWay'">
  522. <el-select
  523. v-model="scope.row.arrivalWay"
  524. clearable
  525. style="width: 100%"
  526. >
  527. <el-option
  528. v-for="item in arrivalWayList"
  529. :key="item.value"
  530. :label="item.label"
  531. :value="item.value"
  532. >
  533. </el-option>
  534. </el-select>
  535. </el-form-item>
  536. </template>
  537. <template v-slot:batchNo="scope">
  538. <el-form-item
  539. :prop="'datasource.' + scope.$index + '.batchNo'"
  540. :rules="[
  541. {
  542. required: isBatchNo == 1 ? true : false,
  543. message: '请输入批号',
  544. trigger: 'blur'
  545. }
  546. ]"
  547. >
  548. <el-input
  549. v-model="scope.row.batchNo"
  550. placeholder="请输入"
  551. :disabled="quoteType === 2"
  552. v-no-chinese
  553. >
  554. </el-input>
  555. </el-form-item>
  556. </template>
  557. <template v-slot:headerBatchNo="{ column }">
  558. <span class="is-required">{{ column.label }}</span>
  559. </template>
  560. <template v-slot:orderNo="{ row, $index }">
  561. <el-form-item :prop="'datasource.' + $index + '.orderNo'">
  562. <el-select v-model="row.orderNo" style="width: 100%">
  563. <el-option
  564. :label="item.orderNo"
  565. :value="item.orderNo"
  566. @click.native="orderNoChange(row, item)"
  567. v-for="(item, index) in orderOption"
  568. :key="index"
  569. ></el-option>
  570. </el-select>
  571. </el-form-item>
  572. </template>
  573. <template v-slot:goodsLevel="{ row, $index }">
  574. <el-form-item :prop="'datasource.' + $index + '.goodsLevel'">
  575. <el-select
  576. v-model="row.goodsLevel"
  577. style="width: 100%"
  578. :disabled="quoteType === 2"
  579. >
  580. <el-option
  581. :label="item.label"
  582. :value="item.value"
  583. v-for="(item, index) in levelList"
  584. :key="index"
  585. ></el-option>
  586. </el-select>
  587. </el-form-item>
  588. </template>
  589. <template v-slot:goodsPriceType="{ row, $index }">
  590. <el-form-item :prop="'datasource.' + $index + '.goodsPriceType'">
  591. <DictSelection
  592. dictName="商品价格类型"
  593. clearable
  594. :disabled="quoteType === 2"
  595. v-model="row.goodsPriceType"
  596. @change="goodsPriceTypeChange(row, $index)"
  597. :isOne="$index === 0"
  598. >
  599. </DictSelection>
  600. </el-form-item>
  601. </template>
  602. <template v-slot:saleCount="scope">
  603. <el-form-item
  604. :prop="'datasource.' + scope.$index + '.' + countObj.countKey"
  605. :rules="{
  606. required: quoteType !== 2 && isTotalCount ? true : false,
  607. message: '请输入数量',
  608. trigger: 'change'
  609. }"
  610. >
  611. <el-input
  612. v-model="scope.row[countObj.countKey]"
  613. placeholder="请输入"
  614. type="number"
  615. :min="0"
  616. :disabled="quoteType === 2"
  617. @input="handleCountChange(scope.row, scope.$index)"
  618. >
  619. <template slot="append">
  620. <el-select
  621. v-model="scope.row[countObj.unitIdKey]"
  622. style="width: 80px"
  623. @change="changeCount(scope.row, scope.$index)"
  624. >
  625. <el-option
  626. :label="item.conversionUnit"
  627. :value="item.id"
  628. @click.native="packingChange(item, scope.$index)"
  629. v-for="(item, index) in scope.row.packageDispositionList"
  630. :key="index"
  631. ></el-option>
  632. </el-select>
  633. </template>
  634. </el-input>
  635. </el-form-item>
  636. </template>
  637. <!-- <template v-slot:saleUnit="scope">
  638. <el-form-item
  639. :prop="'datasource.' + scope.$index + '.' + countObj.unitIdKey"
  640. >
  641. <el-select
  642. v-model="scope.row[countObj.unitIdKey]"
  643. style="width: 100%"
  644. @change="changeCount(scope.row, scope.$index)"
  645. >
  646. <el-option
  647. :label="item.conversionUnit"
  648. :value="item.id"
  649. @click.native="packingChange(item, scope.$index)"
  650. v-for="(item, index) in scope.row.packageDispositionList"
  651. :key="index"
  652. ></el-option>
  653. </el-select>
  654. </el-form-item>
  655. </template> -->
  656. <template v-slot:modelKey="scope">
  657. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  658. <DictSelection
  659. dictName="物品机型"
  660. clearable
  661. :disabled="quoteType === 2"
  662. v-model="scope.row.modelKey"
  663. :isOne="scope.$index === 0"
  664. filterable
  665. allow-create
  666. default-first-option
  667. multiple
  668. >
  669. </DictSelection>
  670. </el-form-item>
  671. </template>
  672. <template v-slot:colorKey="scope">
  673. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  674. <DictSelection
  675. dictName="物品颜色"
  676. clearable
  677. v-model="scope.row.colorKey"
  678. :isOne="scope.$index === 0"
  679. filterable
  680. allow-create
  681. default-first-option
  682. multiple
  683. >
  684. </DictSelection>
  685. </el-form-item>
  686. </template>
  687. <!-- 生产加工类型特有列的模板 -->
  688. <template v-slot:thickNess="{ row, $index }">
  689. <el-form-item :prop="'datasource.' + $index + '.thickNess'">
  690. <el-input v-model="row.thickNess" placeholder="请输入">
  691. <template slot="append">mm</template></el-input
  692. >
  693. </el-form-item>
  694. </template>
  695. <template v-slot:squareNumber="{ row, $index }">
  696. <el-form-item :prop="'datasource.' + $index + '.squareNumber'">
  697. <el-input v-model="row.squareNumber" placeholder="请输入">
  698. <template slot="append">m²</template></el-input
  699. >
  700. </el-form-item>
  701. </template>
  702. <template v-slot:processingFeeBeforeTax="{ row, $index }">
  703. <el-form-item
  704. :prop="'datasource.' + $index + '.processingFeeBeforeTax'"
  705. >
  706. <el-input
  707. v-model="row.processingFeeBeforeTax"
  708. type="number"
  709. placeholder="请输入"
  710. @input="calculateIncludingTaxPrice(row, $index)"
  711. >
  712. <template slot="append">元</template>
  713. </el-input>
  714. </el-form-item>
  715. </template>
  716. <template v-slot:packagingFeeNotTaxed="{ row, $index }">
  717. <el-form-item :prop="'datasource.' + $index + '.packagingFeeNotTaxed'">
  718. <el-input
  719. v-model="row.packagingFeeNotTaxed"
  720. type="number"
  721. placeholder="请输入"
  722. @input="calculateIncludingTaxPrice(row, $index)"
  723. >
  724. <template slot="append">元</template>
  725. </el-input>
  726. </el-form-item>
  727. </template>
  728. <template v-slot:transportationFeeWithoutTax="{ row, $index }">
  729. <el-form-item
  730. :prop="'datasource.' + $index + '.transportationFeeWithoutTax'"
  731. >
  732. <el-input
  733. v-model="row.transportationFeeWithoutTax"
  734. type="number"
  735. placeholder="请输入"
  736. @input="calculateIncludingTaxPrice(row, $index)"
  737. >
  738. <template slot="append">元</template>
  739. </el-input>
  740. </el-form-item>
  741. </template>
  742. <!-- 新增未税小记列模板 -->
  743. <template v-slot:untaxedSubtotal="{ row, $index }">
  744. <el-form-item :prop="'datasource.' + $index + '.untaxedSubtotal'">
  745. {{ (Number(row.untaxedSubtotal) || 0).toFixed(2) }}元
  746. </el-form-item>
  747. </template>
  748. <template v-slot:extraTax="{ row, $index }">
  749. <el-form-item :prop="'datasource.' + $index + '.extraTax'">
  750. <el-input
  751. v-model="row.extraTax"
  752. type="number"
  753. placeholder="请输入"
  754. @input="calculateIncludingTaxPrice(row, $index)"
  755. >
  756. <template slot="append">%</template>
  757. </el-input>
  758. </el-form-item>
  759. </template>
  760. <!-- 含税单价改为含税小计 -->
  761. <template v-slot:includingTaxPrice="{ row, $index }">
  762. <el-form-item :prop="'datasource.' + $index + '.includingTaxPrice'">
  763. <el-input
  764. v-model="row.includingTaxPrice"
  765. type="number"
  766. placeholder="请输入"
  767. >
  768. <template slot="append">元</template>
  769. </el-input>
  770. </el-form-item>
  771. </template>
  772. <!-- 操作列 -->
  773. <template v-slot:action="scope">
  774. <el-popconfirm
  775. class="ele-action"
  776. title="确定要删除吗?"
  777. @confirm="remove(scope.$index)"
  778. >
  779. <template v-slot:reference>
  780. <el-link type="danger" :underline="false" icon="el-icon-delete">
  781. 删除
  782. </el-link>
  783. </template>
  784. </el-popconfirm>
  785. </template>
  786. </ele-pro-table>
  787. <product-list
  788. ref="productListRef"
  789. classType="1"
  790. :is-get-inventory-total="true"
  791. @changeParent="changeParent"
  792. :isSupplier="isSupplier"
  793. :isSalesRecord="isSalesRecord"
  794. ></product-list>
  795. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  796. <ProductionVersion
  797. ref="versionRefs"
  798. @changeProduct="changeProduct"
  799. ></ProductionVersion>
  800. <taskinstance-dialog
  801. ref="taskinstanceDialogRef"
  802. v-if="taskinstanceDialogFlag"
  803. @saveTaskInstance="saveTaskInstance"
  804. :visible.sync="taskinstanceDialogFlag"
  805. ></taskinstance-dialog>
  806. <timeDialog
  807. @chooseTime="chooseTime"
  808. ref="timeDialogRef"
  809. :isBatch="true"
  810. ></timeDialog>
  811. <selectStockLedgerDialog
  812. ref="selectStockLedgerDialogRef"
  813. @changeParent="replaceTable"
  814. :isSupplier="isSupplier"
  815. ></selectStockLedgerDialog>
  816. <commodityPriceListDialog
  817. ref="commodityPriceListDialogRef"
  818. @changeParent="changeParent"
  819. ></commodityPriceListDialog>
  820. </el-form>
  821. </template>
  822. <script>
  823. import { numberReg } from 'ele-admin';
  824. import productList from '@/BIZComponents/product-list.vue';
  825. import dictMixins from '@/mixins/dictMixins';
  826. import fileUpload from '@/components/upload/fileUpload';
  827. import headList from '@/BIZComponents/user-select/user-select.vue';
  828. import ProductionVersion from '@/components/ProductionVersion2/index.vue';
  829. import { getInventoryTotalAPI } from '@/api/wms';
  830. import { pricingWayList, lbjtList } from '@/enum/dict.js';
  831. import { changeCount, getAllPrice } from '@/BIZComponents/setProduct.js';
  832. import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
  833. import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
  834. import timeDialog from '@/components/timeDialog/index.vue';
  835. import { copyObj } from '@/utils/util';
  836. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  837. import setAllValue from '@/BIZComponents/setAllValue.vue'; //批量修改
  838. import tabMixins from '@/mixins/tableColumnsMixin';
  839. import commodityPriceListDialog from '@/views/commodityManagement/commodityPriceList/components/commodityPriceListDialog.vue';
  840. const dayjs = require('dayjs');
  841. import { levelList } from '@/enum/dict.js';
  842. import {
  843. getGoodsPriceByCondition,
  844. getGoodsByCategoryId
  845. } from '@/api/goodsManage/index';
  846. import { parameterGetByCode } from '@/api/main/index.js';
  847. export default {
  848. mixins: [dictMixins, tabMixins],
  849. components: {
  850. fileUpload,
  851. productList,
  852. headList,
  853. ProductionVersion,
  854. taskinstanceDialog,
  855. timeDialog,
  856. selectStockLedgerDialog,
  857. commodityPriceListDialog,
  858. setAllValue
  859. },
  860. props: {
  861. pageName: {
  862. default: '',
  863. type: String
  864. },
  865. isDiscountTotalPrice: {
  866. default: false,
  867. type: Boolean
  868. },
  869. quoteType: {
  870. type: Number,
  871. default: 1
  872. },
  873. isGuaranteePeriod: {
  874. default: true,
  875. type: Boolean
  876. },
  877. customerMark: {
  878. default: '',
  879. type: String
  880. },
  881. isContractId: {
  882. type: Boolean,
  883. default: false
  884. },
  885. isSinglePrice: {
  886. //单价必填
  887. type: Boolean,
  888. default: true
  889. },
  890. isTotalCount: {
  891. //数量必填
  892. type: Boolean,
  893. default: true
  894. },
  895. isCustomerMark: {
  896. //客户代号必填
  897. type: Boolean,
  898. default: false
  899. },
  900. isDiscount: {
  901. //折让
  902. type: Boolean,
  903. default: true
  904. },
  905. isProduceDeliveryDeadline: {
  906. //生产交付交期必填
  907. type: Boolean,
  908. default: false
  909. },
  910. isDrawer: {
  911. type: Boolean,
  912. default: false
  913. },
  914. isChangeCount: {
  915. //默认计算
  916. type: Boolean,
  917. default: true
  918. },
  919. contractBookType: {
  920. //合同类型 1销售 2采购
  921. type: [String, Number],
  922. default: 1
  923. },
  924. isTemporary: {
  925. //临时
  926. type: Boolean,
  927. default: false
  928. },
  929. isSupplier: {
  930. //供应商
  931. type: Boolean,
  932. default: false
  933. },
  934. isSalesRecord: {
  935. default: ''
  936. },
  937. isArrivalWay: {
  938. //分批到货时间
  939. type: Boolean,
  940. default: false
  941. },
  942. //订单类型
  943. needProduce: {
  944. type: [String, Number],
  945. default: 1
  946. },
  947. cacheKeyUrl: '',
  948. //是否显示订单编码
  949. isOrderNo: {
  950. type: Boolean,
  951. default: false
  952. },
  953. isBatchNo: {
  954. type: Boolean, //批次号是否必填
  955. default: false
  956. },
  957. orderOption: {
  958. default: () => {
  959. return [];
  960. }
  961. },
  962. //是否商品
  963. isGoods: {
  964. type: Boolean,
  965. default: false
  966. },
  967. // 是否税率必填
  968. isTaxRate: {
  969. type: [Number, String],
  970. default: 0
  971. },
  972. defTaxRate: {
  973. type: Number,
  974. default: undefined
  975. },
  976. countObj: {
  977. type: Object,
  978. default: () => {
  979. return {
  980. countKey: 'saleCount',
  981. unitKey: 'saleUnit',
  982. unitIdKey: 'saleUnitId'
  983. };
  984. }
  985. }
  986. },
  987. data() {
  988. const defaultForm = {
  989. key: null,
  990. endTime: '',
  991. isFirst: 0,
  992. name: '',
  993. startTime: '',
  994. workHour: '',
  995. guaranteePeriodUnitCode: '',
  996. technicalDrawings: [],
  997. arrivalWay: 1,
  998. // 生产加工类型特有字段
  999. thickNess: '',
  1000. squareNumber: '',
  1001. processingFeeBeforeTax: '',
  1002. packagingFeeNotTaxed: '',
  1003. transportationFeeWithoutTax: '',
  1004. extraTax: '',
  1005. includingTaxPrice: '',
  1006. // 新增未税小记字段
  1007. untaxedSubtotal: ''
  1008. };
  1009. return {
  1010. levelList,
  1011. taskinstanceDialogFlag: false,
  1012. allPrice: 0,
  1013. numberReg,
  1014. defaultForm,
  1015. form: {
  1016. datasource: [],
  1017. discountTotalPrice: 0
  1018. },
  1019. isDate: 1,
  1020. pricingWayList,
  1021. curIndex: '',
  1022. rules: {},
  1023. dictList: {},
  1024. arrivalWayList: [
  1025. { label: '一次性到货', value: 1 },
  1026. { label: '分批到货', value: 2 }
  1027. ],
  1028. columnsVersion: 1,
  1029. selection: []
  1030. };
  1031. },
  1032. computed: {
  1033. canHandl() {
  1034. return this.form.datasource.length;
  1035. },
  1036. columns() {
  1037. let columnsVersion = this.columnsVersion;
  1038. let orderColumn = {
  1039. width: 1,
  1040. show: false
  1041. };
  1042. if (this.isOrderNo) {
  1043. orderColumn = {
  1044. minWidth: 200,
  1045. prop: 'orderNo',
  1046. slot: 'orderNo',
  1047. label: '订单编码',
  1048. showOverflowTooltip: true,
  1049. align: 'center'
  1050. };
  1051. }
  1052. // 基础列定义
  1053. let baseColumns = [
  1054. {
  1055. width: 45,
  1056. type: 'index',
  1057. columnKey: 'index',
  1058. align: 'center',
  1059. fixed: 'left'
  1060. },
  1061. {
  1062. label: '选择',
  1063. width: 45,
  1064. type: 'selection',
  1065. columnKey: 'selection',
  1066. align: 'center',
  1067. fixed: 'left'
  1068. },
  1069. orderColumn,
  1070. {
  1071. width: 280,
  1072. prop: 'productName',
  1073. label: '名称',
  1074. slot: 'productName',
  1075. headerSlot: 'headerProductName',
  1076. align: 'center',
  1077. fixed: 'left'
  1078. },
  1079. {
  1080. width: 120,
  1081. prop: 'productCode',
  1082. label: '编码',
  1083. slot: 'productCode',
  1084. align: 'center'
  1085. },
  1086. {
  1087. width: 120,
  1088. prop: 'specification',
  1089. label: '规格',
  1090. slot: 'specification',
  1091. align: 'center'
  1092. },
  1093. {
  1094. minWidth: 240,
  1095. prop: 'taskName',
  1096. label: '工序',
  1097. slot: 'taskName',
  1098. align: 'center'
  1099. },
  1100. this.isCustomerMark
  1101. ? {
  1102. minWidth: 120,
  1103. prop: 'entrustedEnterpriseId',
  1104. label: '受托企业',
  1105. slot: 'entrustedEnterpriseId',
  1106. show: this.isCustomerMark,
  1107. align: 'center'
  1108. }
  1109. : {
  1110. width: 1
  1111. },
  1112. {
  1113. width: 250,
  1114. prop: 'saleCount',
  1115. label: '数量',
  1116. slot: 'saleCount',
  1117. headerSlot: this.isTotalCount ? 'headerTotalCount' : '',
  1118. align: 'center'
  1119. },
  1120. // {
  1121. // width: 150,
  1122. // prop: 'saleUnit',
  1123. // label: '单位',
  1124. // slot: 'saleUnit',
  1125. // align: 'center'
  1126. // }
  1127. ];
  1128. // 当quoteType为2时添加生产加工相关列
  1129. if (this.quoteType === 2) {
  1130. baseColumns.push(
  1131. {
  1132. width: 150,
  1133. prop: 'thickNess',
  1134. label: '厚度',
  1135. slot: 'thickNess',
  1136. align: 'center'
  1137. },
  1138. {
  1139. width: 150,
  1140. prop: 'squareNumber',
  1141. label: '平方数',
  1142. slot: 'squareNumber',
  1143. align: 'center'
  1144. },
  1145. {
  1146. width: 150,
  1147. prop: 'processingFeeBeforeTax',
  1148. label: '加工费(未税)',
  1149. slot: 'processingFeeBeforeTax',
  1150. align: 'center'
  1151. },
  1152. {
  1153. width: 150,
  1154. prop: 'packagingFeeNotTaxed',
  1155. label: '包装费(未税)',
  1156. slot: 'packagingFeeNotTaxed',
  1157. align: 'center'
  1158. },
  1159. {
  1160. width: 150,
  1161. prop: 'transportationFeeWithoutTax',
  1162. label: '运输费(未税)',
  1163. slot: 'transportationFeeWithoutTax',
  1164. align: 'center'
  1165. },
  1166. {
  1167. width: 150,
  1168. prop: 'untaxedSubtotal',
  1169. label: '未税小计',
  1170. slot: 'additionalTaxRate_untaxed',
  1171. align: 'center'
  1172. },
  1173. {
  1174. width: 150,
  1175. prop: 'extraTax',
  1176. label: '税率(%)',
  1177. slot: 'extraTax',
  1178. align: 'center'
  1179. },
  1180. {
  1181. width: 150,
  1182. prop: 'includingTaxPrice',
  1183. label: '含税小计',
  1184. slot: 'includingTaxPrice',
  1185. align: 'center'
  1186. }
  1187. );
  1188. }
  1189. // 价格相关列
  1190. const priceColumns = [
  1191. {
  1192. width: 160,
  1193. prop: 'customerExpectDeliveryDeadline',
  1194. label: this.contractBookType == 1 ? '客户期望交期' : '交付日期',
  1195. slot: 'customerExpectDeliveryDeadline',
  1196. headerSlot:
  1197. this.isDate == 1 ? 'headerCustomerExpectDeliveryDeadline' : '',
  1198. align: 'center'
  1199. },
  1200. {
  1201. width: 180,
  1202. prop: 'singleWeight',
  1203. label: '单重',
  1204. slot: 'singleWeight',
  1205. headerSlot: 'headerSingleWeight',
  1206. align: 'center',
  1207. show: this.quoteType !== 2
  1208. },
  1209. // {
  1210. // width: 120,
  1211. // prop: 'weightUnit',
  1212. // label: '重量单位',
  1213. // slot: 'weightUnit',
  1214. // align: 'center',
  1215. // show: this.quoteType !== 2
  1216. // },
  1217. {
  1218. minWidth: 120,
  1219. prop: 'goodsLevel',
  1220. label: '物品级别',
  1221. slot: 'goodsLevel',
  1222. align: 'center',
  1223. show: this.quoteType !== 2
  1224. },
  1225. {
  1226. width: 200,
  1227. prop: 'totalCount',
  1228. label: '计量数量',
  1229. headerSlot: 'headerTotalCount',
  1230. align: 'center',
  1231. formatter: (_row, _column, cellValue) => {
  1232. if (_row.totalCount) {
  1233. return _row.totalCount + ' ' + _row.measuringUnit;
  1234. }
  1235. },
  1236. show: this.quoteType !== 2
  1237. },
  1238. {
  1239. width: 200,
  1240. prop: 'customerMark',
  1241. label: this.contractBookType == 1 ? '客户代号' : '供应商代号',
  1242. slot: 'customerMark',
  1243. headerSlot: this.isCustomerMark ? 'headerCustomerMark' : '',
  1244. align: 'center',
  1245. show: this.quoteType !== 2
  1246. },
  1247. {
  1248. minWidth: 160,
  1249. prop: 'productionCodes',
  1250. label: '生产编号',
  1251. align: 'center',
  1252. show: this.quoteType !== 2 // 仅当quoteType不是2时显示
  1253. },
  1254. {
  1255. width: 200,
  1256. prop: 'productCategoryName',
  1257. label: '类型',
  1258. slot: 'productCategoryName',
  1259. align: 'center',
  1260. show: this.quoteType !== 2
  1261. },
  1262. {
  1263. width: 120,
  1264. prop: 'packingSpecification',
  1265. align: 'center',
  1266. label: '包装规格',
  1267. showOverflowTooltip: true,
  1268. show: this.quoteType !== 2
  1269. },
  1270. {
  1271. width: 160,
  1272. prop: 'goodsPriceType',
  1273. label: '价格类型',
  1274. slot: 'goodsPriceType',
  1275. align: 'center',
  1276. show: this.quoteType !== 2
  1277. },
  1278. {
  1279. width: 200,
  1280. prop: 'singlePrice',
  1281. label: '单价',
  1282. slot: 'singlePrice',
  1283. headerSlot: this.isSinglePrice ? 'headerSinglePrice' : '',
  1284. align: 'center',
  1285. show: this.quoteType !== 2
  1286. },
  1287. {
  1288. width: 160,
  1289. prop: 'taxRate',
  1290. label: '税率',
  1291. slot: 'taxRate',
  1292. align: 'center',
  1293. headerSlot: this.isTaxRate == 1 ? 'headerTaxRate' : '',
  1294. show: this.quoteType !== 2
  1295. },
  1296. {
  1297. width: 180,
  1298. prop: 'notaxSinglePrice',
  1299. label: '不含税单价',
  1300. slot: 'notaxSinglePrice',
  1301. align: 'center',
  1302. show: this.quoteType !== 2
  1303. },
  1304. this.isDiscount
  1305. ? {
  1306. width: 160,
  1307. prop: 'discountSinglePrice',
  1308. label: '折让单价',
  1309. align: 'center',
  1310. show: this.isDiscount,
  1311. formatter: (_row, _column, cellValue) => {
  1312. return _row.discountSinglePrice
  1313. ? Number(_row.discountSinglePrice).toFixed(2)
  1314. : '';
  1315. }
  1316. }
  1317. : {
  1318. width: 1
  1319. },
  1320. {
  1321. width: 120,
  1322. prop: 'totalPrice',
  1323. label: '合计',
  1324. slot: 'totalPrice',
  1325. align: 'center'
  1326. },
  1327. this.isDiscount
  1328. ? {
  1329. width: 160,
  1330. prop: 'discountTotalPrice',
  1331. label: '折让合计',
  1332. align: 'center',
  1333. show: this.isDiscount,
  1334. formatter: (_row, _column, cellValue) => {
  1335. return _row.discountTotalPrice
  1336. ? Number(_row.discountTotalPrice).toFixed(2)
  1337. : '';
  1338. }
  1339. }
  1340. : {
  1341. width: 1
  1342. }
  1343. ];
  1344. // 其他列
  1345. const otherColumns = [
  1346. {
  1347. width: 110,
  1348. prop: 'batchNo',
  1349. label: '批次号',
  1350. slot: 'batchNo',
  1351. headerSlot: this.isBatchNo ? 'headerBatchNo' : '',
  1352. align: 'center',
  1353. show: this.quoteType !== 2
  1354. },
  1355. {
  1356. width: 120,
  1357. prop: 'availableCountBase',
  1358. label: '库存数量',
  1359. slot: 'availableCountBase',
  1360. align: 'center',
  1361. show: this.quoteType !== 2
  1362. },
  1363. // {
  1364. // width: 120,
  1365. // prop: 'measuringUnit',
  1366. // label: '计量单位',
  1367. // slot: 'measuringUnit',
  1368. // align: 'center'
  1369. // },
  1370. {
  1371. prop: 'provenance',
  1372. label: '产地',
  1373. slot: 'provenance',
  1374. align: 'center',
  1375. showOverflowTooltip: true,
  1376. minWidth: 200,
  1377. show: this.quoteType !== 2
  1378. },
  1379. {
  1380. width: 180,
  1381. prop: 'totalWeight',
  1382. label: '总重',
  1383. slot: 'totalWeight',
  1384. formatter: (_row, _column, cellValue) => {
  1385. if (_row.totalWeight) {
  1386. return _row.totalWeight + ' ' + _row.weightUnit;
  1387. }
  1388. },
  1389. align: 'center'
  1390. },
  1391. {
  1392. width: 160,
  1393. prop: 'productBrand',
  1394. label: '牌号',
  1395. slot: 'productBrand',
  1396. align: 'center',
  1397. show: this.quoteType !== 2
  1398. },
  1399. {
  1400. width: 120,
  1401. prop: 'modelType',
  1402. label: '型号',
  1403. slot: 'modelType',
  1404. align: 'center',
  1405. show: this.quoteType !== 2
  1406. },
  1407. {
  1408. width: 160,
  1409. prop: 'modelKey',
  1410. label: '机型',
  1411. slot: 'modelKey',
  1412. align: 'center',
  1413. show: this.quoteType !== 2
  1414. },
  1415. {
  1416. width: 160,
  1417. prop: 'colorKey',
  1418. label: '颜色',
  1419. slot: 'colorKey',
  1420. align: 'center',
  1421. show: this.quoteType !== 2
  1422. },
  1423. {
  1424. width: 120,
  1425. prop: 'produceType',
  1426. align: 'center',
  1427. label: '属性类型',
  1428. show: this.quoteType !== 2,
  1429. showOverflowTooltip: true,
  1430. formatter: (row, column) => {
  1431. if (row.produceType) {
  1432. return row.produceType
  1433. .map((item) => {
  1434. return lbjtList[item];
  1435. })
  1436. .toString();
  1437. }
  1438. }
  1439. },
  1440. this.isArrivalWay
  1441. ? {
  1442. width: 160,
  1443. prop: 'arrivalWay',
  1444. label: '到货方式',
  1445. slot: 'arrivalWay',
  1446. align: 'center',
  1447. show: this.isArrivalWay,
  1448. show: this.quoteType !== 2
  1449. }
  1450. : {
  1451. width: 1
  1452. },
  1453. this.contractBookType == 1
  1454. ? {
  1455. width: 160,
  1456. prop: 'produceDeliveryDeadline',
  1457. label: '生产交付交期',
  1458. slot: 'produceDeliveryDeadline',
  1459. headerSlot:
  1460. this.isDate == 1 && this.isProduceDeliveryDeadline
  1461. ? 'headerProduceDeliveryDeadline'
  1462. : '',
  1463. show: this.contractBookType == 1,
  1464. align: 'center'
  1465. }
  1466. : {
  1467. width: 1
  1468. },
  1469. {
  1470. width: 200,
  1471. prop: 'guaranteePeriod',
  1472. label: '有效期',
  1473. slot: 'guaranteePeriod',
  1474. align: 'center',
  1475. show: this.quoteType !== 2
  1476. },
  1477. this.isGuaranteePeriod
  1478. ? {
  1479. width: 200,
  1480. prop: 'guaranteePeriodDeadline',
  1481. label: '有效期截止日期',
  1482. slot: 'guaranteePeriodDeadline',
  1483. show: this.isGuaranteePeriod,
  1484. align: 'center'
  1485. }
  1486. : {
  1487. width: 1
  1488. },
  1489. {
  1490. width: 120,
  1491. prop: 'imgCode',
  1492. align: 'center',
  1493. label: '图号/件号',
  1494. showOverflowTooltip: true,
  1495. show: this.quoteType !== 2
  1496. },
  1497. {
  1498. width: 220,
  1499. prop: 'customerReqFiles',
  1500. label: '客户需求',
  1501. slot: 'customerReqFiles',
  1502. align: 'center',
  1503. show: this.quoteType !== 2
  1504. },
  1505. {
  1506. width: 130,
  1507. prop: 'technicalAnswerName',
  1508. label: '技术答疑人',
  1509. slot: 'technicalAnswerName',
  1510. align: 'center',
  1511. show: this.quoteType !== 2
  1512. },
  1513. {
  1514. width: 220,
  1515. prop: 'technicalParams',
  1516. label: '技术参数',
  1517. slot: 'technicalParams',
  1518. align: 'center',
  1519. show: this.quoteType !== 2
  1520. },
  1521. {
  1522. width: 240,
  1523. prop: 'technicalDrawings',
  1524. label: '技术图纸',
  1525. slot: 'technicalDrawings',
  1526. align: 'center'
  1527. },
  1528. {
  1529. width: 120,
  1530. prop: 'drawingVersion',
  1531. label: '图纸版本',
  1532. align: 'center',
  1533. show: this.quoteType !== 2
  1534. },
  1535. {
  1536. width: 240,
  1537. prop: 'technologyRouteName',
  1538. label: '工艺路线',
  1539. slot: 'technologyRouteName',
  1540. align: 'center',
  1541. show: this.quoteType !== 2
  1542. },
  1543. {
  1544. width: 240,
  1545. prop: 'industryArtFiles',
  1546. label: '工艺附件',
  1547. slot: 'industryArtFiles',
  1548. align: 'center',
  1549. show: this.quoteType !== 2
  1550. },
  1551. {
  1552. width: 240,
  1553. prop: 'otherFiles',
  1554. label: '其他附件',
  1555. slot: 'otherFiles',
  1556. align: 'center',
  1557. show: this.quoteType !== 2
  1558. },
  1559. {
  1560. width: 220,
  1561. prop: 'remark',
  1562. label: '备注',
  1563. slot: 'remark',
  1564. align: 'center'
  1565. },
  1566. {
  1567. columnKey: 'action',
  1568. label: '操作',
  1569. width: 120,
  1570. align: 'center',
  1571. resizable: false,
  1572. slot: 'action',
  1573. fixed: 'right',
  1574. showOverflowTooltip: true
  1575. }
  1576. ];
  1577. // 合并所有列
  1578. return [...baseColumns, ...priceColumns, ...otherColumns];
  1579. }
  1580. },
  1581. created() {
  1582. parameterGetByCode({
  1583. code: 'eom_inventoryTable_customerExpectDeliveryDeadline'
  1584. }).then((res) => {
  1585. if (res.value) {
  1586. this.isDate = res.value;
  1587. }
  1588. });
  1589. // 监听数据变化以重新计算含税单价
  1590. let calculating = false;
  1591. this.$watch(
  1592. 'form.datasource',
  1593. (newVal) => {
  1594. newVal.forEach((row, index) => {
  1595. // 为每个行项目添加监听器,但使用标志位避免循环
  1596. this.$watch(
  1597. () => [
  1598. row.processingFeeBeforeTax,
  1599. row.packagingFeeNotTaxed,
  1600. row.transportationFeeWithoutTax,
  1601. row.extraTax,
  1602. row[this.countObj.countKey]
  1603. ],
  1604. () => {
  1605. if (!calculating) {
  1606. calculating = true;
  1607. this.calculateIncludingTaxPrice(row, index);
  1608. this.changeAll();
  1609. calculating = false;
  1610. }
  1611. },
  1612. { deep: true }
  1613. );
  1614. });
  1615. },
  1616. { immediate: true, deep: true }
  1617. );
  1618. },
  1619. methods: {
  1620. handleCountChange(row, index) {
  1621. // 数量变化时,若为生产加工类型,触发含税小计计算
  1622. if (this.quoteType === 2) {
  1623. this.calculateIncludingTaxPrice(row, index);
  1624. } else {
  1625. this.changeCount(row, index);
  1626. }
  1627. },
  1628. packingChange(item, index) {
  1629. this.$set(
  1630. this.form.datasource[index],
  1631. this.countObj.unitKey,
  1632. item.conversionUnit
  1633. );
  1634. },
  1635. openVersion(index) {
  1636. this.$refs.versionRefs.open(index);
  1637. },
  1638. //设置分批到货时间
  1639. handleMethod(row, index) {
  1640. this.$refs.timeDialogRef.open(row, index);
  1641. },
  1642. chooseTime({ arrivalBatch, index }) {
  1643. this.$set(
  1644. this.form.datasource[index],
  1645. 'arrivalBatch',
  1646. copyObj(arrivalBatch)
  1647. );
  1648. },
  1649. //工艺路线
  1650. changeProduct(data, index) {
  1651. this.$set(this.form.datasource[index], 'technologyRouteName', data.name);
  1652. this.$set(this.form.datasource[index], 'technologyRouteId', data.id);
  1653. },
  1654. handleTaskinstance(row, index) {
  1655. this.taskinstanceDialogFlag = true;
  1656. this.$nextTick(() => {
  1657. this.$refs.taskinstanceDialogRef.open(row, index);
  1658. });
  1659. },
  1660. saveTaskInstance(row = {}) {
  1661. this.$set(this.form.datasource[row.index], 'taskId', row.id);
  1662. this.$set(this.form.datasource[row.index], 'taskName', row.name);
  1663. this.$set(
  1664. this.form.datasource[row.index],
  1665. 'routingId',
  1666. row.produceRoutingId
  1667. );
  1668. },
  1669. async getSupplierObj(productList, queryName) {
  1670. try {
  1671. let categoryIds = productList
  1672. .filter((item) => item.productId)
  1673. .map((item) => item.productId);
  1674. if (categoryIds.length > 0) {
  1675. return await contactQueryByCategoryIdsAPI({
  1676. categoryIds
  1677. });
  1678. } else {
  1679. return Promise.resolve({});
  1680. }
  1681. } catch (e) {
  1682. return Promise.resolve({});
  1683. }
  1684. },
  1685. setDeliveryDays(row, index, type, isAll) {
  1686. if (isAll) {
  1687. this.form.datasource.forEach((item, i) => {
  1688. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1689. item.guaranteePeriodUnitCode
  1690. );
  1691. this.$set(
  1692. this.form.datasource[i],
  1693. 'guaranteePeriodDeadline',
  1694. guaranteePeriodUnitName != 'second'
  1695. ? this.setDay(item.guaranteePeriod, guaranteePeriodUnitName, item)
  1696. : ''
  1697. );
  1698. });
  1699. return;
  1700. }
  1701. if (type == 'guaranteePeriod') {
  1702. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1703. row.guaranteePeriodUnitCode
  1704. );
  1705. this.$set(
  1706. this.form.datasource[index],
  1707. 'guaranteePeriodDeadline',
  1708. guaranteePeriodUnitName != 'second'
  1709. ? this.setDay(row.guaranteePeriod, guaranteePeriodUnitName, row)
  1710. : ''
  1711. );
  1712. }
  1713. },
  1714. guaranteePeriodUnit(code) {
  1715. return code == 3
  1716. ? 'day'
  1717. : code == 4
  1718. ? 'month'
  1719. : code == 5
  1720. ? 'year'
  1721. : 'second';
  1722. },
  1723. setDay(addDay, dateType = 'day', item) {
  1724. let tiem =
  1725. this.contractBookType == 1
  1726. ? item.produceDeliveryDeadline
  1727. : item.customerExpectDeliveryDeadline;
  1728. return dayjs(tiem || new Date())
  1729. .add(addDay, dateType)
  1730. .format('YYYY-MM-DD');
  1731. },
  1732. // 返回列表数据
  1733. getTableValue() {
  1734. let comitDatasource = copyObj(this.form.datasource);
  1735. if (comitDatasource.length === 0) return [];
  1736. comitDatasource.forEach((v) => {
  1737. if (v.guaranteePeriodUnitCode) {
  1738. v.guaranteePeriodUnitName = this.getDictValue(
  1739. '保质期单位',
  1740. v.guaranteePeriodUnitCode
  1741. );
  1742. }
  1743. if (v.modelKey) {
  1744. v.modelKey = v.modelKey.toString();
  1745. }
  1746. if (v.colorKey) {
  1747. v.colorKey = v.colorKey.toString();
  1748. }
  1749. v.technicalDrawings = v.technicalDrawings ? v.technicalDrawings : [];
  1750. v.customerReqFiles = v.customerReqFiles || [];
  1751. v.industryArtFiles = v.industryArtFiles || [];
  1752. v.otherFiles = v.otherFiles || [];
  1753. });
  1754. return comitDatasource;
  1755. },
  1756. getPrice() {
  1757. return [this.allPrice, this.form.discountTotalPrice];
  1758. },
  1759. //改变数量
  1760. changeCount(row, index) {
  1761. if (!row) {
  1762. this.form.datasource = this.form.datasource.map((item, i) => {
  1763. return changeCount(item, this.countObj, false, this.quoteType);
  1764. });
  1765. } else {
  1766. const updatedRow = changeCount(
  1767. row,
  1768. this.countObj,
  1769. false,
  1770. this.quoteType
  1771. );
  1772. this.$set(this.form.datasource, index, updatedRow);
  1773. }
  1774. this.$nextTick(() => {
  1775. // 生产加工类型不需要计算不含税单价,但需要计算含税小计
  1776. if (this.quoteType === 2) {
  1777. if (row) {
  1778. this.calculateIncludingTaxPrice(row, index);
  1779. } else {
  1780. this.form.datasource.forEach((item, i) => {
  1781. this.calculateIncludingTaxPrice(item, i);
  1782. });
  1783. }
  1784. } else {
  1785. this.getNotaxSinglePrice();
  1786. }
  1787. this.changeAll();
  1788. });
  1789. },
  1790. // 计算含税小计(原含税单价逻辑)
  1791. calculateIncludingTaxPrice(row, index) {
  1792. if (!row) return;
  1793. // 计算未税小记
  1794. const untaxedSubtotal =
  1795. (Number(row.processingFeeBeforeTax) || 0) +
  1796. (Number(row.packagingFeeNotTaxed) || 0) +
  1797. (Number(row.transportationFeeWithoutTax) || 0);
  1798. // 使用 $nextTick 确保响应式更新完成
  1799. this.$nextTick(() => {
  1800. this.$set(row, 'untaxedSubtotal', untaxedSubtotal.toFixed(2));
  1801. // 计算含税小计
  1802. const taxRate = (Number(row.extraTax) || 0) / 100;
  1803. const includingTaxPrice = untaxedSubtotal * (1 + taxRate);
  1804. this.$set(row, 'includingTaxPrice', includingTaxPrice.toFixed(2));
  1805. // 为生产加工类型计算totalPrice
  1806. if (this.quoteType === 2) {
  1807. const quantity = Number(row[this.countObj.countKey]) || 1;
  1808. const totalPrice = includingTaxPrice * quantity;
  1809. this.$set(row, 'totalPrice', totalPrice.toFixed(2));
  1810. // 强制更新总计
  1811. this.$nextTick(() => {
  1812. this.changeAll();
  1813. });
  1814. }
  1815. });
  1816. },
  1817. changeAll() {
  1818. // 确保生产加工类型的行都有正确的totalPrice
  1819. if (this.quoteType === 2) {
  1820. this.form.datasource.forEach((row, index) => {
  1821. if (!row.totalPrice || row.totalPrice === '0.00') {
  1822. this.calculateIncludingTaxPrice(row, index);
  1823. }
  1824. });
  1825. }
  1826. this.allPrice = getAllPrice(this.form.datasource) || 0;
  1827. if (this.isDiscountTotalPrice) {
  1828. this.form.discountTotalPrice = this.allPrice;
  1829. this.$emit('setDiscountTotalPrice', this.allPrice);
  1830. }
  1831. this.$emit('setCountAmount', this.allPrice);
  1832. },
  1833. setCustomerMark(customerMark) {
  1834. this.form.datasource.forEach((item) => {
  1835. item['customerMark'] = customerMark;
  1836. this.$forceUpdate();
  1837. });
  1838. },
  1839. //计算不含税单价
  1840. getNotaxSinglePrice() {
  1841. this.form.datasource.forEach((item, index) => {
  1842. if (item.singlePrice && item.taxRate) {
  1843. this.$set(
  1844. this.form.datasource[index],
  1845. 'notaxSinglePrice',
  1846. parseFloat((item.singlePrice / (1 + item.taxRate / 100)).toFixed(2))
  1847. );
  1848. } else {
  1849. this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
  1850. }
  1851. });
  1852. },
  1853. //设置优惠后总金额修改产品单价
  1854. discountInputByOrder(val) {
  1855. this.form.discountTotalPrice = val;
  1856. this.form.datasource.forEach((item, index) => {
  1857. this.$set(
  1858. this.form.datasource[index],
  1859. 'discountSinglePrice',
  1860. this.getDiscountSinglePrice(item)
  1861. );
  1862. this.$set(
  1863. this.form.datasource[index],
  1864. 'discountTotalPrice',
  1865. this.getDiscountTotalPrice(item)
  1866. );
  1867. });
  1868. this.$emit('setDiscountTotalPrice', val);
  1869. this.$forceUpdate();
  1870. this.$refs.table.reRenderTable();
  1871. },
  1872. setAllValueChange({ key, value }) {
  1873. let indexS = this.selection.map((item) => item.key - 1);
  1874. indexS.forEach((i) => {
  1875. this.$set(this.form.datasource[i], key, value);
  1876. this.setDeliveryDays(this.form.datasource[i], i, 'guaranteePeriod');
  1877. });
  1878. },
  1879. //获取折让单价
  1880. getDiscountSinglePrice(row) {
  1881. let num =
  1882. (Number(this.form.discountTotalPrice) / Number(this.allPrice)) *
  1883. Number(row.singlePrice);
  1884. return isNaN(num) ? '' : num;
  1885. },
  1886. //获取折让合计
  1887. getDiscountTotalPrice(row) {
  1888. let num = 0;
  1889. num = Number(row.discountSinglePrice) * Number(row.totalCount);
  1890. return isNaN(num) ? '' : num.toFixed(2);
  1891. },
  1892. orderNoChange(row, item) {
  1893. row['orderId'] = item.orderId;
  1894. },
  1895. //修改回显
  1896. async putTableValue(data) {
  1897. let productList =
  1898. (data &&
  1899. (data.quoteProductList || data.productList || data.detailList)) ||
  1900. [];
  1901. if (productList) {
  1902. let supplierObj = await this.getSupplierObj(productList, 'productId');
  1903. productList.forEach((item, index) => {
  1904. item['key'] = index + 1;
  1905. if (item.modelKey) {
  1906. item.modelKey = item.modelKey.split(',');
  1907. }
  1908. if (item.colorKey) {
  1909. item.colorKey = item.colorKey.split(',');
  1910. }
  1911. item.pricingWay =
  1912. item.pricingWay || data.pricingWay || data?.contractVO?.pricingWay;
  1913. item.guaranteePeriodUnitCode = item.guaranteePeriodUnitCode
  1914. ? item.guaranteePeriodUnitCode + ''
  1915. : '';
  1916. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1917. item.guaranteePeriodUnitCode
  1918. );
  1919. if (item.guaranteePeriod && item.guaranteePeriodUnitCode) {
  1920. item['guaranteePeriodDeadline'] =
  1921. item['guaranteePeriodDeadline'] ||
  1922. guaranteePeriodUnitName != 'second'
  1923. ? this.setDay(
  1924. item.guaranteePeriod,
  1925. guaranteePeriodUnitName,
  1926. item
  1927. )
  1928. : '';
  1929. }
  1930. item.entrustedEnterpriseIdList = supplierObj[item.productId];
  1931. // if (supplierObj[item.productId]?.length === 1) {
  1932. // item.entrustedEnterpriseId = supplierObj[item.productId][0].id;
  1933. // }
  1934. item['customerMark'] = item.customerMark || this.customerMark;
  1935. item['arrivalWay'] = item.arrivalWay || 1;
  1936. // 当quoteType为2时,数量默认设置为1
  1937. if (
  1938. this.quoteType === 2 &&
  1939. item[this.countObj.countKey] === undefined
  1940. ) {
  1941. item[this.countObj.countKey] = 1;
  1942. }
  1943. // 初始化生产加工特有字段及未税小记
  1944. if (this.quoteType === 2) {
  1945. item.thickNess = item.thickNess || '';
  1946. item.squareNumber = item.squareNumber || '';
  1947. item.processingFeeBeforeTax = item.processingFeeBeforeTax || '';
  1948. item.packagingFeeNotTaxed = item.packagingFeeNotTaxed || '';
  1949. item.transportationFeeWithoutTax =
  1950. item.transportationFeeWithoutTax || '';
  1951. item.extraTax = item.extraTax || '13'; // 设置默认税率
  1952. // 强制计算一次
  1953. const untaxedSubtotal =
  1954. (Number(item.processingFeeBeforeTax) || 0) +
  1955. (Number(item.packagingFeeNotTaxed) || 0) +
  1956. (Number(item.transportationFeeWithoutTax) || 0);
  1957. item.untaxedSubtotal = untaxedSubtotal.toFixed(2);
  1958. const taxRate = (Number(item.extraTax) || 0) / 100;
  1959. const includingTaxPrice = untaxedSubtotal * (1 + taxRate);
  1960. item.includingTaxPrice = includingTaxPrice.toFixed(2);
  1961. const quantity = Number(item[this.countObj.countKey]) || 1;
  1962. item.totalPrice = (includingTaxPrice * quantity).toFixed(2);
  1963. }
  1964. });
  1965. this.form.datasource = productList;
  1966. let codeList = this.form.datasource
  1967. .filter((item) => item.productCode)
  1968. .map((item) => item.productCode);
  1969. //获取仓库库存
  1970. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1971. this.form.datasource
  1972. .filter((item) => item.productCode)
  1973. .forEach((item, index) => {
  1974. let find =
  1975. inventoryTotalList.find((key) => key.code == item.productCode) ||
  1976. {};
  1977. this.form.datasource;
  1978. this.$set(
  1979. this.form.datasource[index],
  1980. 'availableCountBase',
  1981. find.availableCountBase
  1982. );
  1983. });
  1984. if (this.isChangeCount) {
  1985. this.changeCount();
  1986. } else {
  1987. this.allPrice = data.totalAmount || data?.contractVO?.totalPrice;
  1988. }
  1989. if (this.isDiscountTotalPrice) {
  1990. this.form.discountTotalPrice =
  1991. data.payAmount || data?.contractVO?.discountTotalPrice;
  1992. }
  1993. this.$refs.table.reload();
  1994. // 额外确保计算一次
  1995. this.$nextTick(() => {
  1996. this.changeAll();
  1997. });
  1998. }
  1999. },
  2000. //选择产品
  2001. handParent(row, index) {
  2002. let item = {
  2003. id: row?.productCode
  2004. };
  2005. if (row?.goodsId) {
  2006. this.handGoods(index);
  2007. return;
  2008. }
  2009. if (this.needProduce == 1 || this.needProduce == 2) {
  2010. this.$refs.productListRef.open(item, index);
  2011. } else {
  2012. this.$refs.selectStockLedgerDialogRef.open(item, index);
  2013. }
  2014. },
  2015. handGoods(index) {
  2016. this.$refs.commodityPriceListDialogRef.open(index);
  2017. },
  2018. //选择技术人回调
  2019. changeAnswer(obj, idx) {
  2020. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  2021. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  2022. },
  2023. handHead(row, index) {
  2024. let item = {
  2025. id: row.technicalAnswerId
  2026. };
  2027. this.$refs.headRef.open(item, index);
  2028. },
  2029. //选择产品回调
  2030. changeParent(obj, idx) {
  2031. obj.forEach((item, index) => {
  2032. let i = idx == -1 ? index : idx;
  2033. let row = JSON.parse(JSON.stringify(this.defaultForm));
  2034. row.key = this.form.datasource.length + 1;
  2035. let parasm = idx == -1 ? row : this.form.datasource[i];
  2036. this.$set(parasm, 'productId', item.id);
  2037. this.$set(parasm, 'categoryName', item.name);
  2038. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  2039. this.$set(parasm, 'productBrand', item.brandNum);
  2040. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  2041. this.$set(parasm, 'productCode', item.code);
  2042. this.$set(parasm, 'productName', item.name);
  2043. this.$set(parasm, 'modelType', item.modelType);
  2044. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  2045. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  2046. this.$set(parasm, 'specification', item.specification);
  2047. this.$set(parasm, 'weightUnit', item.weightUnit);
  2048. this.$set(parasm, 'singleWeight', item.netWeight);
  2049. this.$set(parasm, 'pricingWay', 1);
  2050. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  2051. this.$set(parasm, 'guaranteePeriod', item.warrantyPeriod);
  2052. if (item.modelKey) {
  2053. this.$set(parasm, 'modelKey', item.modelKey.split(','));
  2054. }
  2055. if (item.colorKey) {
  2056. this.$set(parasm, 'colorKey', item.colorKey.split(','));
  2057. }
  2058. if (this.defTaxRate) {
  2059. this.$set(parasm, 'taxRate', parasm.taxRate || this.defTaxRate);
  2060. }
  2061. this.$set(
  2062. parasm,
  2063. 'guaranteePeriodUnitCode',
  2064. item.warrantyPeriodUnit ? item.warrantyPeriodUnit + '' : ''
  2065. );
  2066. if (item.warrantyPeriod && item.warrantyPeriodUnit) {
  2067. this.$set(
  2068. parasm,
  2069. 'guaranteePeriodDeadline',
  2070. this.setDay(
  2071. item.warrantyPeriod,
  2072. this.guaranteePeriodUnit(item.warrantyPeriodUnit),
  2073. {}
  2074. )
  2075. );
  2076. }
  2077. this.$set(
  2078. parasm,
  2079. 'packageDispositionList',
  2080. item.packageDispositionList
  2081. );
  2082. if (item.packageDispositionList?.length) {
  2083. this.$set(
  2084. parasm,
  2085. this.countObj.unitIdKey,
  2086. item.packageDispositionList[0].id
  2087. );
  2088. this.$set(
  2089. parasm,
  2090. this.countObj.unitKey,
  2091. item.packageDispositionList[0].conversionUnit
  2092. );
  2093. }
  2094. this.$set(parasm, 'arrivalWay', item.arrivalWay || 1);
  2095. this.$set(parasm, 'imgCode', item.imgCode);
  2096. this.$set(parasm, 'produceType', item.componentAttribute);
  2097. if (this.isOrderNo) {
  2098. this.$set(parasm, 'orderNo', this.orderOption[0]?.orderNo);
  2099. this.$set(parasm, 'orderId', this.orderOption[0]?.orderId);
  2100. }
  2101. if (this.isGoods && item.goodsId) {
  2102. this.$set(parasm, 'goodsId', item.goodsId);
  2103. this.$set(parasm, 'goodsPriceId', item.goodsPriceId);
  2104. this.$set(parasm, 'goodsPriceType', item.goodsPriceType);
  2105. this.$set(parasm, 'singlePrice', item.singlePrice);
  2106. this.$set(parasm, 'notaxSinglePrice', item.notaxSinglePrice);
  2107. this.$set(parasm, 'taxRate', item.taxRate);
  2108. this.$set(parasm, 'discountSinglePrice', item.singlePrice);
  2109. this.$set(parasm, 'totalCount', '');
  2110. } else {
  2111. this.$set(parasm, 'singlePrice', parasm.singlePrice || 0);
  2112. }
  2113. // 当quoteType为2时,数量默认设置为1
  2114. if (this.quoteType === 2) {
  2115. this.$set(parasm, this.countObj.countKey, 1);
  2116. }
  2117. if (this.isSupplier) {
  2118. this.$set(
  2119. parasm,
  2120. 'entrustedEnterpriseIdList',
  2121. item.entrustedEnterpriseIdList
  2122. );
  2123. this.$set(
  2124. parasm,
  2125. 'entrustedEnterpriseId',
  2126. item.entrustedEnterpriseId
  2127. );
  2128. }
  2129. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  2130. this.$set(
  2131. parasm,
  2132. 'packingSpecification',
  2133. item.extField.packingSpecification
  2134. );
  2135. this.$set(parasm, 'customerMark', this.customerMark);
  2136. if (item.purchaseOrigins?.length > 0) {
  2137. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  2138. }
  2139. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  2140. // 初始化生产加工特有字段及未税小记
  2141. if (this.quoteType === 2) {
  2142. parasm.thickNess = '';
  2143. parasm.squareNumber = '';
  2144. parasm.processingFeeBeforeTax = '';
  2145. parasm.packagingFeeNotTaxed = '';
  2146. parasm.transportationFeeWithoutTax = '';
  2147. parasm.extraTax = 13;
  2148. parasm.untaxedSubtotal = '0.00';
  2149. parasm.includingTaxPrice = '';
  2150. }
  2151. if (idx == -1) {
  2152. this.form.datasource.push(row);
  2153. }
  2154. });
  2155. this.changeCount();
  2156. },
  2157. replaceTable(obj, idx) {
  2158. obj.forEach(async (item, index) => {
  2159. let i = idx == -1 ? index : idx;
  2160. let row = JSON.parse(JSON.stringify(this.defaultForm));
  2161. row.key = this.form.datasource.length + 1;
  2162. let parasm = idx == -1 ? row : this.form.datasource[i];
  2163. this.$set(parasm, 'customerMark', this.customerMark);
  2164. this.$set(parasm, 'productId', item.productId);
  2165. this.$set(parasm, 'categoryName', item.productName);
  2166. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  2167. this.$set(parasm, 'productBrand', item.productBrand);
  2168. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  2169. this.$set(parasm, 'productCode', item.productCode);
  2170. this.$set(parasm, 'productName', item.productName);
  2171. this.$set(parasm, 'modelType', item.categoryModel);
  2172. this.$set(parasm, 'availableCountBase', item.measureQuantity);
  2173. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  2174. this.$set(parasm, 'specification', item.specification);
  2175. this.$set(parasm, 'weightUnit', item.weightUnit);
  2176. this.$set(parasm, 'singleWeight', item.weight);
  2177. this.$set(parasm, 'pricingWay', 1);
  2178. this.$set(parasm, 'arrivalWay', item.arrivalWay || 1);
  2179. this.$set(parasm, 'batchNo', item.batchNo);
  2180. this.$set(parasm, 'imgCode', '');
  2181. this.$set(parasm, 'produceType', item.componentAttribute);
  2182. let goodsData = await getGoodsByCategoryId(item.productId);
  2183. goodsData = goodsData.filter((item) => item.approvalStatus == 2);
  2184. if (goodsData?.length) {
  2185. let goodsPriceList = goodsData[0]?.goodsPriceList[0];
  2186. this.$set(parasm, 'goodsId', goodsData[0].id);
  2187. this.$set(parasm, 'goodsPriceId', goodsPriceList.id);
  2188. this.$set(parasm, 'goodsPriceType', goodsPriceList.priceType);
  2189. this.$set(parasm, 'singlePrice', goodsPriceList.unitPrice || 0);
  2190. this.$set(parasm, 'notaxSinglePrice', goodsPriceList.excludeTaxPrice);
  2191. this.$set(parasm, 'taxRate', goodsPriceList.taxRate);
  2192. this.$set(parasm, 'discountSinglePrice', goodsPriceList.unitPrice);
  2193. this.$set(parasm, 'totalCount', '');
  2194. } else {
  2195. this.$set(parasm, 'singlePrice', 0);
  2196. }
  2197. if (item.modelKey) {
  2198. this.$set(parasm, 'modelKey', item.modelKey.split(','));
  2199. }
  2200. if (item.colorKey) {
  2201. this.$set(parasm, 'colorKey', item.colorKey.split(','));
  2202. }
  2203. if (this.isSupplier) {
  2204. this.$set(
  2205. parasm,
  2206. 'entrustedEnterpriseIdList',
  2207. item.entrustedEnterpriseIdList
  2208. );
  2209. this.$set(
  2210. parasm,
  2211. 'entrustedEnterpriseId',
  2212. item.entrustedEnterpriseId
  2213. );
  2214. }
  2215. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  2216. this.$set(
  2217. parasm,
  2218. 'packingSpecification',
  2219. item.extField.packingSpecification
  2220. );
  2221. this.$set(
  2222. parasm,
  2223. 'packageDispositionList',
  2224. item.packageDispositionList
  2225. );
  2226. if (item.packageDispositionList?.length) {
  2227. this.$set(
  2228. parasm,
  2229. this.countObj.unitIdKey,
  2230. item.packageDispositionList[0].id
  2231. );
  2232. this.$set(
  2233. parasm,
  2234. this.countObj.unitKey,
  2235. item.packageDispositionList[0].conversionUnit
  2236. );
  2237. }
  2238. this.$set(parasm, 'customerMark', this.customerMark);
  2239. if (item.purchaseOrigins?.length > 0) {
  2240. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  2241. }
  2242. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  2243. // 当quoteType为2时,数量默认设置为1
  2244. if (this.quoteType === 2) {
  2245. this.$set(parasm, this.countObj.countKey, 1);
  2246. }
  2247. // 初始化生产加工特有字段及未税小记
  2248. if (this.quoteType === 2) {
  2249. parasm.thickNess = '';
  2250. parasm.squareNumber = '';
  2251. parasm.processingFeeBeforeTax = '';
  2252. parasm.packagingFeeNotTaxed = '';
  2253. parasm.transportationFeeWithoutTax = '';
  2254. parasm.extraTax = '';
  2255. parasm.untaxedSubtotal = '0.00';
  2256. parasm.includingTaxPrice = '';
  2257. }
  2258. if (idx == -1) {
  2259. this.form.datasource.push(row);
  2260. }
  2261. });
  2262. },
  2263. remove(index) {
  2264. this.form.datasource.splice(index, 1);
  2265. this.setSort();
  2266. this.changeAll();
  2267. },
  2268. // 重新排序
  2269. setSort() {
  2270. this.form.datasource.forEach((n, index) => {
  2271. n.key = index + 1;
  2272. });
  2273. },
  2274. // 添加临时产品
  2275. handlAdd() {
  2276. let item = JSON.parse(JSON.stringify(this.defaultForm));
  2277. item.key = this.form.datasource.length + 1;
  2278. item.customerMark = this.customerMark;
  2279. // 当quoteType为2时,数量默认设置为1
  2280. if (this.quoteType === 2) {
  2281. item[this.countObj.countKey] = 1;
  2282. }
  2283. // 初始化生产加工特有字段及未税小记
  2284. if (this.quoteType === 2) {
  2285. item.thickNess = '';
  2286. item.squareNumber = '';
  2287. item.processingFeeBeforeTax = '';
  2288. item.packagingFeeNotTaxed = '';
  2289. item.transportationFeeWithoutTax = '';
  2290. item.extraTax = '';
  2291. item.untaxedSubtotal = '0.00';
  2292. item.includingTaxPrice = '';
  2293. }
  2294. this.form.datasource.push(item);
  2295. },
  2296. validateForm(callback) {
  2297. this.$refs.form.validate((valid, obj) => {
  2298. if (obj) {
  2299. let messages = Object.keys(obj).map((key) => obj[key][0]);
  2300. if (messages.length > 0) {
  2301. this.$message.warning(messages[0].message);
  2302. }
  2303. }
  2304. callback(valid);
  2305. });
  2306. },
  2307. goodsPriceTypeChange(row, index) {
  2308. if (row.goodsId) {
  2309. getGoodsPriceByCondition({
  2310. id: row.goodsId,
  2311. priceType: row.goodsPriceType
  2312. }).then((res) => {
  2313. if (res.id) {
  2314. this.$set(this.form.datasource[index], 'goodsPriceId', res.id);
  2315. this.$set(
  2316. this.form.datasource[index],
  2317. 'goodsPriceType',
  2318. res.priceType
  2319. );
  2320. this.$set(
  2321. this.form.datasource[index],
  2322. 'singlePrice',
  2323. res.unitPrice
  2324. );
  2325. this.$set(
  2326. this.form.datasource[index],
  2327. 'notaxSinglePrice',
  2328. res.excludeTaxPrice
  2329. );
  2330. this.$set(this.form.datasource[index], 'taxRate', res.taxRate);
  2331. this.$set(
  2332. this.form.datasource[index],
  2333. 'discountSinglePrice',
  2334. res.unitPrice
  2335. );
  2336. }
  2337. this.changeCount(row, index);
  2338. });
  2339. }
  2340. },
  2341. save() {
  2342. this.$emit('save');
  2343. }
  2344. }
  2345. };
  2346. </script>
  2347. <style lang="scss" scoped>
  2348. .headbox {
  2349. display: flex;
  2350. justify-content: space-between;
  2351. align-items: center;
  2352. .amount {
  2353. font-size: 14px;
  2354. font-weight: bold;
  2355. padding-right: 30px;
  2356. }
  2357. }
  2358. .time-form .el-form-item {
  2359. margin-bottom: 0 !important;
  2360. }
  2361. ::v-deep .period {
  2362. display: flex;
  2363. .borderleftnone {
  2364. .el-input--medium .el-input__inner {
  2365. border-top-right-radius: 0;
  2366. border-bottom-right-radius: 0;
  2367. }
  2368. }
  2369. .borderrightnone {
  2370. .el-input--medium .el-input__inner {
  2371. border-top-left-radius: 0;
  2372. border-bottom-left-radius: 0;
  2373. }
  2374. }
  2375. }
  2376. ::v-deep .time-form tbody > tr:hover > td {
  2377. background-color: transparent !important;
  2378. }
  2379. ::v-deep .time-form .el-table tr {
  2380. background-color: #ffffff;
  2381. }
  2382. .pricebox {
  2383. display: flex;
  2384. justify-content: flex-start;
  2385. align-items: center;
  2386. font-weight: bold;
  2387. }
  2388. </style>