index.vue 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276
  1. <template>
  2. <div class="my-container">
  3. <div class="bill-left" v-show="isShow==='home'" key="item">
  4. <div class="bill-tab">
  5. <div class="bill-title">导航</div>
  6. <side-tree :propConfig="treeConfig" @onChange="onChangeTree" ref="sideTree" />
  7. </div>
  8. </div>
  9. <div class="bill-main" v-show="isShow==='home'" key="item2">
  10. <module-view :propConfig="config" ref="moduleView" @pagination="getDataList" @search="getDataList"
  11. @resert="onRefresh" @clickHandle="clickHandle" @detail="getDetail" @onRefresh="onRefresh" />
  12. </div>
  13. <!-- 新增/编辑 -->
  14. <div class="detil" v-show="isShow==='add'" key="item3">
  15. <by-tool :propConfig="toolConfig" @clickHandle="insideTools" ref="byTool" />
  16. <div class="box-shadow">
  17. <el-button style="margin-bottom: 20px;" type="primary" icon="el-icon-sort" @click="openVxeData">关联金蝶财务系统物料</el-button>
  18. <by-form :propConfig="formConfig" ref="form">
  19. <template v-slot:description>
  20. <el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="textarea">
  21. </el-input>
  22. </template>
  23. <template v-slot:tags>
  24. <el-tag style="margin-right: 16px;" :disable-transitions="true" v-for="(item,index) of tagsData"
  25. :key="index" closable @close="handleClose2(index)">
  26. {{item}}
  27. </el-tag>
  28. <by-input class="input-new-tag" ref="tagsValue" style="width: 150px;"></by-input>
  29. <el-button class="button-new-tag" @click="getTagsValue">添加</el-button>
  30. </template>
  31. <template v-slot:status>
  32. <el-radio v-model="status" :label="0">启用</el-radio>
  33. <el-radio v-model="status" :label="1">备用</el-radio>
  34. <el-radio v-model="status" :label="2">禁用</el-radio>
  35. </template>
  36. <template v-slot:ismakeup>
  37. <el-radio v-model="ismakeup" :label="0" :disabled="materialSpec==1">是</el-radio>
  38. <el-radio v-model="ismakeup" :label="1">否</el-radio>
  39. <el-button v-show="ismakeup===0" @click="openMakeup">选择商品</el-button>
  40. </template>
  41. <template v-slot:makeupTable>
  42. <div v-if="ismakeup===0">
  43. <by-table :propConfig="makeupTable" ref="makeupTable" @onChangeRow="getMakeupTableValue"></by-table>
  44. </div>
  45. </template>
  46. <template v-slot:issued>
  47. <el-radio v-model="issued" :label="0">是</el-radio>
  48. <el-radio v-model="issued" :label="1">否</el-radio>
  49. </template>
  50. <template v-slot:materialSpec>
  51. <el-radio v-model="materialSpec" :label="0" @input="changeSingle">单规格</el-radio>
  52. <el-radio v-model="materialSpec" :label="1" @input="changeSingle" :disabled="ismakeup==0">多规格</el-radio>
  53. </template>
  54. <template v-slot:attributeName>
  55. <div v-if="isSingle" key="item4">
  56. <by-table :propConfig="singleTable" @onChangeRow="getInputValue" ref="singeTable">
  57. <template v-slot:stock="{row}">
  58. <vxe-input v-if="!isEdit" v-model="row.stock" size="mini" type="integer"></vxe-input>
  59. <span v-else>{{ row.stock }}</span>
  60. </template>
  61. </by-table>
  62. </div>
  63. <div v-if="!isSingle" key="item5">
  64. <el-select :value="selectValue" clearable placeholder="请选择" style="width: 19.5%;" @input="getSelectValue">
  65. <el-option v-for="item in selectList" :key="item.value" :label="item.name" :value="item.id">
  66. </el-option>
  67. </el-select>
  68. <div class="by-tab" key="item6">
  69. <div v-for="(item,index) of attributeList" :key="index">
  70. <div class="tab-title">{{item.title}} <i class="el-icon-circle-close" @click="closeGroup(index)"></i>
  71. </div>
  72. <el-tag class="item-tab" :disable-transitions="true" :key="i" v-for="(tag,i) of item.list" closable
  73. @close="handleClose(tag,index)">
  74. {{tag}}
  75. </el-tag>
  76. <by-input class="input-new-tag" :ref="'getValue_'+index"></by-input>
  77. <el-button class="button-new-tag" @click="showInput(index)">添加</el-button>
  78. </div>
  79. <div style="margin: 20px 0;" v-if="!isAdd" key="item7">
  80. <div class="el-button mr15 el-button--primary el-button--small" @click="isAdd=true">添加新规格</div>
  81. </div>
  82. <div style="display: flex;margin: 20px 0;" v-else key='item8'>
  83. <div class="flex-item">
  84. <label>规格:</label>
  85. <div class="el-input el-input--small" style="width: 250px;margin-right: 16px;">
  86. <input type="text" v-model="norms" placeholder="请输入规格" class="el-input__inner">
  87. </div>
  88. </div>
  89. <div class="flex-item">
  90. <label>规格值:</label>
  91. <div class="el-input el-input--small" style="width: 250px;margin-right: 16px;">
  92. <input type="text" v-model="normsValue" placeholder="请输入规格值" class="el-input__inner">
  93. </div>
  94. </div>
  95. <div @click="doComfirm" class="el-button el-button--primary el-button--small">确定</div>
  96. <div @click="isAdd=false" class="el-button el-button--danger el-button--small">取消</div>
  97. </div>
  98. <div>
  99. <by-table :propConfig="tableConfig" @onChangeRow="getInputValue" ref="table">
  100. <template v-slot:stock="{row}">
  101. <vxe-input v-if="!isEdit" v-model="row.stock" size="mini" type="integer"></vxe-input>
  102. <span v-else>{{ row.stock }}</span>
  103. </template>
  104. </by-table>
  105. </div>
  106. </div>
  107. </div>
  108. </template>
  109. </by-form>
  110. </div>
  111. </div>
  112. <!-- 选择物料 -->
  113. <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
  114. <vxe-modal v-model="vxeValue" width="48%" height="88%" show-zoom resize transfer show-footer mask-closable :loading="tableloading">
  115. <template #title>
  116. <span>关联金蝶财务系统物料</span>
  117. </template>
  118. <template #default>
  119. <el-form ref="tableSearchForm" :inline="true" :model="tableSearchForm" label-width="80px">
  120. <el-form-item label="标题">
  121. <el-input style="width: 220px;" v-model="tableSearchForm.fname" placeholder="请输入标题" clearable></el-input>
  122. </el-form-item>
  123. <el-form-item label="财务编号">
  124. <el-input style="width: 220px;" v-model="tableSearchForm.fnumber" placeholder="请输入财务编号" clearable></el-input>
  125. </el-form-item>
  126. <el-form-item label="开始时间">
  127. <el-date-picker style="width: 220px;" v-model="tableSearchForm.stime" type="date" placeholder="选择日期" :clearable="false" value-format="yyyy-MM-dd"></el-date-picker>
  128. </el-form-item>
  129. <el-form-item label="结束时间">
  130. <el-date-picker style="width: 220px;" v-model="tableSearchForm.etime" type="date" placeholder="选择日期" :clearable="false" value-format="yyyy-MM-dd"></el-date-picker>
  131. </el-form-item>
  132. <el-form-item>
  133. <el-button type="primary" @click="tableSearchOnSubmit">搜索</el-button>
  134. <el-button @click="resetTableSearch">重置</el-button>
  135. </el-form-item>
  136. </el-form>
  137. <el-table
  138. ref="multipleTable"
  139. :data="newtableData"
  140. stripe
  141. border
  142. style="width: 100%"
  143. :header-cell-style="{ background: '#f3f6fd', color: '#555'}">
  144. <el-table-column
  145. width="55">
  146. <template slot-scope="scope">
  147. <el-radio v-model="tableRadio" :label="scope.row" @input="handleSelectionChange">{{""}}</el-radio>
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="fname" label="标题"></el-table-column>
  151. <el-table-column prop="fnumber" label="财务编号"></el-table-column>
  152. <el-table-column prop="fbaseUnitName" label="单位"></el-table-column>
  153. <el-table-column prop="fbaseUnitCode" label="单位编码"></el-table-column>
  154. </el-table>
  155. <el-pagination
  156. style="margin-top: 25px;"
  157. background
  158. layout="prev, pager, next"
  159. :page-size="tablePageSize"
  160. :current-page="tablePageNum"
  161. :total="tableDataTotal"
  162. @current-change="currentChange">
  163. </el-pagination>
  164. </template>
  165. <template #footer>
  166. <div class="btn">
  167. <el-button size="small" @click="vxeValue=false">取消</el-button>
  168. <el-button type="primary" size="small" @click="doConfirm">确定</el-button>
  169. </div>
  170. </template>
  171. </vxe-modal>
  172. <el-dialog
  173. title="同步金蝶物料"
  174. v-loading="dateLoading"
  175. :visible.sync="dateDialogVisible"
  176. :close-on-click-modal='false'
  177. :close-on-press-escape='false'
  178. :show-close='false'
  179. width="518px">
  180. <el-date-picker v-model="stime" type="date" :picker-options="stimePickerOptions" placeholder="选择日期" value-format="yyyy-MM-dd"></el-date-picker>
  181. <span style="margin: 0 12px;">至</span>
  182. <el-date-picker v-model="etime" type="date" :picker-options="etimePickerOptions" placeholder="选择日期" value-format="yyyy-MM-dd"></el-date-picker>
  183. <span slot="footer" class="dialog-footer">
  184. <el-button @click="dateDialogVisible = false">取 消</el-button>
  185. <el-button type="primary" @click="dateConfirm">确 定</el-button>
  186. </span>
  187. </el-dialog>
  188. <StoreRecord ref="StoreRecord" />
  189. </div>
  190. </template>
  191. <script lang="ts">
  192. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  193. import api from '@/api/currency'
  194. import other from '@/api/other'
  195. import ForTab from "@/components/ForTab/index.vue";
  196. import productModal from "./components/productModal.vue";
  197. import brandType from "./components/brandType.vue";
  198. import StoreRecord from "./components/storeRecord.vue";
  199. // import selectKin from "./components/selectKin.vue";
  200. @Component({ components: { ForTab, productModal, brandType,StoreRecord } })
  201. export default class productManagement extends Vue {
  202. tagsData : any = [] // 标签值
  203. isShow = 'home'
  204. isEdit = true
  205. vxeValue = false
  206. editInfo : any = ''
  207. isSingle : any = true
  208. timeNum = 0;
  209. timer : any = null
  210. materialSpec : any = 0
  211. status : any = 0
  212. ismakeup : any = 1
  213. issued : any = 0
  214. textarea : any = ''
  215. categoryIds : any = ''
  216. selectList = []
  217. selectValue = ''
  218. // tab
  219. singeTable : any = ''
  220. setTableConfig : any = ''
  221. towTable : any = ''
  222. attributeList : any = [] // 物料属性规格
  223. inputValue : any = ''
  224. norms : any = ''
  225. normsValue : any = ''
  226. isAdd : any = false
  227. skuRuleList : any = ''
  228. tableList : any = ''
  229. attributeId : any = ''
  230. intercept : any = ''
  231. makeupList : any = [] // 组合商品列表
  232. dateDialogVisible = false
  233. dateLoading = false
  234. stime : any = null
  235. etime : any = null
  236. stimePickerOptions : any = {
  237. disabledDate(time : any) {
  238. return time.getTime() > Date.now();
  239. }
  240. }
  241. etimePickerOptions : any = {
  242. disabledDate(time : any) {
  243. return time.getTime() > Date.now();
  244. }
  245. }
  246. // tab
  247. toolConfig = {
  248. tools: {
  249. return: true,
  250. save: true,
  251. }
  252. }
  253. treeConfig = {
  254. attr: {
  255. retConfig: {
  256. id: 'id',
  257. },
  258. defaultExpandAll: true,
  259. label: 'name',
  260. // resType: 'data'
  261. },
  262. // request: {
  263. // url: '/maindata/maindataMaterialCategory/treeUseList',
  264. // method: 'GET'
  265. // }
  266. }
  267. singleTable : any = {
  268. attr: {
  269. size: 'mini',
  270. align: 'left',
  271. editRules: {
  272. skuTitle: [
  273. { required: true, message: '请输入标题'}
  274. ],
  275. skuCode: [
  276. { required: true, message: '请输入物料编码'}
  277. ],
  278. barCode: [
  279. { required: true, message: '请输入69码-商品条码'}
  280. ]
  281. }
  282. },
  283. columns: [
  284. {
  285. // width: '150px',
  286. title: '标题(必填项)',
  287. field: 'skuTitle',
  288. component: 'by-input',
  289. compConfig: {
  290. attr: {
  291. size: 'mini',
  292. placeholder: ' '
  293. },
  294. }
  295. },
  296. {
  297. // width: '150px',
  298. title: '副标题',
  299. field: 'skuSubtitle',
  300. component: 'by-input',
  301. compConfig: {
  302. attr: {
  303. size: 'mini',
  304. placeholder: ' '
  305. },
  306. }
  307. },
  308. {
  309. // width: '150px',
  310. title: '物料编码(必填项)',
  311. field: 'skuCode',
  312. component: 'by-input',
  313. compConfig: {
  314. attr: {
  315. size: 'mini',
  316. placeholder: ' '
  317. },
  318. }
  319. },
  320. {
  321. width: '110px',
  322. title: '69码-商品条码(必填项)',
  323. field: 'barCode',
  324. component: 'by-input',
  325. // width:110,
  326. compConfig: {
  327. attr: {
  328. size: 'mini',
  329. placeholder: ' '
  330. },
  331. }
  332. },
  333. // {
  334. // width: '55px',
  335. // component: selectKin
  336. // },
  337. {
  338. // width: '150px',
  339. title: '财务编号',
  340. field: 'financialCode',
  341. component: 'by-input',
  342. compConfig: {
  343. attr: {
  344. size: 'mini',
  345. placeholder: ' '
  346. },
  347. }
  348. },
  349. {
  350. width: '90px',
  351. title: '价格',
  352. field: 'price',
  353. component: 'by-input',
  354. compConfig: {
  355. attr: {
  356. size: 'mini',
  357. placeholder: ' ',
  358. type: "number",
  359. min: 0,
  360. defaultValue: 0
  361. },
  362. }
  363. },
  364. {
  365. width: '90px',
  366. title: '单位',
  367. field: 'unit',
  368. component: 'by-input',
  369. compConfig: {
  370. attr: {
  371. size: 'mini',
  372. placeholder: ' ',
  373. },
  374. }
  375. },
  376. {
  377. width: '90px',
  378. title: '单位编码',
  379. field: 'unitCode',
  380. component: 'by-input',
  381. compConfig: {
  382. attr: {
  383. size: 'mini',
  384. placeholder: ' ',
  385. },
  386. }
  387. },
  388. // {
  389. // width: '70px',
  390. // title: '库存',
  391. // field: 'stock',
  392. // slot: true,
  393. // },
  394. {
  395. width: '100px',
  396. title: '保质期(天)',
  397. field: 'shelfLife',
  398. component: 'by-input',
  399. compConfig: {
  400. attr: {
  401. size: 'mini',
  402. placeholder: ' ',
  403. type: "integer",
  404. min: 0,
  405. },
  406. }
  407. },
  408. {
  409. width: '80px',
  410. title: '重量/g',
  411. field: 'weight',
  412. component: 'by-input',
  413. compConfig: {
  414. attr: {
  415. size: 'mini',
  416. placeholder: ' ',
  417. type: "number",
  418. min: 0,
  419. },
  420. }
  421. },
  422. {
  423. width: '80px',
  424. title: '长/cm',
  425. field: 'length',
  426. component: 'by-input',
  427. compConfig: {
  428. attr: {
  429. size: 'mini',
  430. placeholder: ' ',
  431. type: "number",
  432. min: 0,
  433. },
  434. }
  435. },
  436. {
  437. width: '80px',
  438. title: '宽/cm',
  439. field: 'width',
  440. component: 'by-input',
  441. compConfig: {
  442. attr: {
  443. size: 'mini',
  444. placeholder: ' ',
  445. type: "number",
  446. min: 0,
  447. },
  448. }
  449. },
  450. {
  451. width: '80px',
  452. title: '高/cm',
  453. field: 'height',
  454. component: 'by-input',
  455. compConfig: {
  456. attr: {
  457. size: 'mini',
  458. placeholder: ' ',
  459. type: "number",
  460. min: 0,
  461. },
  462. }
  463. },
  464. {
  465. width: '80px',
  466. title: '体积/cm³',
  467. field: 'volume',
  468. },
  469. // {
  470. // width: '100px',
  471. // title: '操作',
  472. // action: true,
  473. // // plugins: [{
  474. // // icon: 'el-icon-edit',
  475. // // name: '选择物料',
  476. // // audit: '',
  477. // // event: {
  478. // // click: () => {
  479. // // (this as any).openVxeData(1)
  480. // // }
  481. // // }
  482. // // }]
  483. // }
  484. ]
  485. }
  486. tableConfig : any = {
  487. attr: {
  488. size: 'mini',
  489. align: 'left',
  490. editRules: {
  491. skuTitle: [
  492. { required: true, message: '请输入标题'}
  493. ],
  494. skuCode: [
  495. { required: true, message: '请输入物料编码'}
  496. ],
  497. barCode: [
  498. { required: true, message: '请输入69码-商品条码'}
  499. ]
  500. }
  501. },
  502. columns: [
  503. {
  504. width: '160px',
  505. title: '标题(必填项)',
  506. field: 'skuTitle',
  507. component: 'by-input',
  508. compConfig: {
  509. attr: {
  510. size: 'mini',
  511. placeholder: ' '
  512. },
  513. }
  514. },
  515. {
  516. width: '120px',
  517. title: '副标题',
  518. field: 'skuSubtitle',
  519. component: 'by-input',
  520. compConfig: {
  521. attr: {
  522. size: 'mini',
  523. placeholder: ' '
  524. },
  525. }
  526. },
  527. {
  528. width: '140px',
  529. title: '物料编码(必填项)',
  530. field: 'skuCode',
  531. component: 'by-input',
  532. compConfig: {
  533. attr: {
  534. size: 'mini',
  535. placeholder: ' '
  536. },
  537. }
  538. },
  539. {
  540. width: '110px',
  541. title: '69码-商品条码(必填项)',
  542. field: 'barCode',
  543. component: 'by-input',
  544. compConfig: {
  545. attr: {
  546. size: 'mini',
  547. placeholder: ' ',
  548. },
  549. }
  550. },
  551. // {
  552. // width: '55px',
  553. // component: selectKin
  554. // },
  555. {
  556. width: '140px',
  557. title: '财务编号',
  558. field: 'financialCode',
  559. component: 'by-input',
  560. compConfig: {
  561. attr: {
  562. size: 'mini',
  563. placeholder: ' '
  564. },
  565. }
  566. },
  567. {
  568. width: '80px',
  569. title: '价格',
  570. field: 'price',
  571. component: 'by-input',
  572. compConfig: {
  573. attr: {
  574. size: 'mini',
  575. placeholder: ' ',
  576. type: "number",
  577. min: 0,
  578. },
  579. }
  580. },
  581. {
  582. width: '80px',
  583. title: '单位',
  584. field: 'unit',
  585. component: 'by-input',
  586. compConfig: {
  587. attr: {
  588. size: 'mini',
  589. placeholder: ' ',
  590. },
  591. }
  592. },
  593. {
  594. width: '80px',
  595. title: '单位编码',
  596. field: 'unitCode',
  597. component: 'by-input',
  598. compConfig: {
  599. attr: {
  600. size: 'mini',
  601. placeholder: ' ',
  602. },
  603. }
  604. },
  605. // {
  606. // width: '80px',
  607. // title: '库存',
  608. // field: 'stock',
  609. // slot: true,
  610. // },
  611. {
  612. width: '100px',
  613. title: '保质期(天)',
  614. field: 'shelfLife',
  615. component: 'by-input',
  616. compConfig: {
  617. attr: {
  618. size: 'mini',
  619. placeholder: ' ',
  620. type: "integer",
  621. min: 0,
  622. },
  623. }
  624. },
  625. {
  626. width: '80px',
  627. title: '重量/g',
  628. field: 'weight',
  629. component: 'by-input',
  630. compConfig: {
  631. attr: {
  632. size: 'mini',
  633. placeholder: ' ',
  634. type: "number",
  635. min: 0,
  636. },
  637. }
  638. },
  639. {
  640. width: '80px',
  641. title: '长/cm',
  642. field: 'length',
  643. component: 'by-input',
  644. compConfig: {
  645. attr: {
  646. size: 'mini',
  647. placeholder: ' ',
  648. type: "number",
  649. min: 0,
  650. },
  651. }
  652. },
  653. {
  654. width: '80px',
  655. title: '宽/cm',
  656. field: 'width',
  657. component: 'by-input',
  658. compConfig: {
  659. attr: {
  660. size: 'mini',
  661. placeholder: ' ',
  662. type: "number",
  663. min: 0,
  664. },
  665. }
  666. },
  667. {
  668. width: '80px',
  669. title: '高/cm',
  670. field: 'height',
  671. component: 'by-input',
  672. compConfig: {
  673. attr: {
  674. size: 'mini',
  675. placeholder: ' ',
  676. type: "number",
  677. min: 0,
  678. },
  679. }
  680. },
  681. {
  682. width: '80px',
  683. title: '体积/cm³',
  684. field: 'volume',
  685. },
  686. {
  687. width: '180px',
  688. title: '操作',
  689. action: true,
  690. plugins: [
  691. // {
  692. // icon: 'el-icon-edit',
  693. // name: '选择物料',
  694. // audit: '',
  695. // event: {
  696. // click: () => {
  697. // (this as any).openVxeData(2)
  698. // }
  699. // }
  700. // },
  701. {
  702. icon: 'el-icon-delete',
  703. name: '删除',
  704. audit: '',
  705. event: {
  706. click: (item : any) => {
  707. (this as any).doDeleteTable(item)
  708. }
  709. }
  710. },
  711. ]
  712. }
  713. ]
  714. }
  715. makeupTable : any = {
  716. attr: {
  717. size: 'mini',
  718. align: 'center',
  719. },
  720. columns: [
  721. {
  722. // width: '170px',
  723. title: '标题',
  724. field: 'title',
  725. },
  726. {
  727. // width: '170px',
  728. title: '副标题',
  729. field: 'subtitle',
  730. },
  731. {
  732. width: '170px',
  733. title: '数量',
  734. field: 'number',
  735. component: 'by-input',
  736. compConfig: {
  737. attr: {
  738. size: 'mini',
  739. defaultValue: '1',
  740. type: 'number',
  741. min: '0'
  742. },
  743. }
  744. },
  745. {
  746. width: 120,
  747. title: '操作',
  748. action: true,
  749. plugins: [{
  750. name: '删除',
  751. event: {
  752. click: (item : any) => (this as any).deleteMakeup(item)
  753. }
  754. }]
  755. }
  756. ]
  757. }
  758. formConfig = {
  759. attr: {
  760. size: 'medium',
  761. rules: {
  762. name: [{
  763. required: true, message: '请输入名称', trigger: 'blur'
  764. }],
  765. // materialCode: [{
  766. // required: true, message: '请输入物料编码', trigger: 'blur'
  767. // }],
  768. basePrice: [{
  769. required: true, message: '请输入基本售价', trigger: 'blur'
  770. }],
  771. categoryName: [{
  772. required: true, message: '请选择物料分类', trigger: 'change'
  773. }],
  774. brandId: [{
  775. required: true, message: '请选择物料品牌', trigger: 'change'
  776. }],
  777. }
  778. },
  779. columns: [
  780. [
  781. {
  782. span: 6,
  783. label: '名称',
  784. prop: 'name',
  785. component: 'by-input',
  786. compConfig: {
  787. attr: {
  788. placeholder: '请输入名称',
  789. clearable: true
  790. }
  791. }
  792. },
  793. {
  794. span: 6,
  795. label: '简称',
  796. prop: 'shortName',
  797. component: 'by-input',
  798. compConfig: {
  799. attr: {
  800. placeholder: '请输入简称',
  801. clearable: true
  802. }
  803. }
  804. },
  805. {
  806. span: 6,
  807. label: '物料编码',
  808. prop: 'materialCode',
  809. component: 'by-input',
  810. compConfig: {
  811. attr: {
  812. placeholder: '请输入物料编码',
  813. }
  814. }
  815. },
  816. {
  817. span: 6,
  818. label: '货号',
  819. prop: 'itemNumber',
  820. component: 'by-input',
  821. compConfig: {
  822. attr: {
  823. placeholder: '请输入货号',
  824. clearable: true
  825. }
  826. }
  827. },
  828. ],
  829. [
  830. {
  831. span: 6,
  832. label: '基本售价',
  833. prop: 'basePrice',
  834. component: 'by-input',
  835. compConfig: {
  836. attr: {
  837. placeholder: '请输入基本售价',
  838. type: 'number',
  839. min: '0'
  840. }
  841. }
  842. },
  843. {
  844. span: 6,
  845. label: '市场价格',
  846. prop: 'markPrice',
  847. component: 'by-input',
  848. compConfig: {
  849. attr: {
  850. placeholder: '请输入市场价格',
  851. type: 'number',
  852. min: '0'
  853. }
  854. }
  855. },
  856. {
  857. span: 6,
  858. label: '国际码',
  859. prop: 'nsCode',
  860. component: 'by-input',
  861. compConfig: {
  862. attr: {
  863. placeholder: '请输入国际码',
  864. clearable: true
  865. }
  866. }
  867. },
  868. ],
  869. [
  870. {
  871. span: 6,
  872. label: '物料分类',
  873. prop: 'categoryName',
  874. component: 'select-tree',
  875. compConfig: {
  876. attr: {
  877. label: 'name',
  878. clearable: true,
  879. placeholder: '请选择物料分类',
  880. retConfig: {
  881. categoryName: 'name',
  882. categoryId: 'id'
  883. },
  884. defaultExpandAll: true
  885. },
  886. request: {
  887. url: '/maindata/maindataMaterialCategory/treeUseList'
  888. }
  889. }
  890. },
  891. {
  892. span: 6,
  893. label: '物料品牌',
  894. prop: 'brandId',
  895. component: brandType,
  896. },
  897. {
  898. span: 6,
  899. label: '虚拟分类',
  900. prop: 'vmCategoryName',
  901. component: 'select-tree',
  902. compConfig: {
  903. attr: {
  904. label: 'name',
  905. clearable: true,
  906. placeholder: '请选择虚拟分类',
  907. retConfig: {
  908. vmCategoryName: 'name',
  909. vmCategoryId: 'id'
  910. },
  911. defaultExpandAll: true
  912. },
  913. request: {
  914. url: '/maindata/maindataMaterialVmcategory/treeUseList'
  915. }
  916. }
  917. },
  918. {
  919. labelWidth: '116px',
  920. span: 6,
  921. label: '机构商品分类',
  922. prop: 'organizationCategoryName',
  923. component: 'select-tree',
  924. compConfig: {
  925. attr: {
  926. label: 'name',
  927. clearable: true,
  928. placeholder: '请选择机构商品分类',
  929. retConfig: {
  930. organizationCategoryName: 'name',
  931. organizationCategoryId: 'id'
  932. },
  933. defaultExpandAll: true
  934. },
  935. request: {
  936. url: '/maindata/maindataMaterialOrganizationCategory/treeUseList'
  937. }
  938. }
  939. },
  940. ],
  941. [
  942. {
  943. span: 30,
  944. label: '描述',
  945. slot: true,
  946. prop: 'description',
  947. }
  948. ],
  949. [
  950. {
  951. span: 20,
  952. label: '标签',
  953. slot: true,
  954. prop: 'tags',
  955. }
  956. ],
  957. [
  958. {
  959. span: 20,
  960. label: '物料状态',
  961. slot: true,
  962. prop: 'status',
  963. }
  964. ],
  965. [
  966. {
  967. span: 20,
  968. label: '组合商品',
  969. slot: true,
  970. prop: 'ismakeup',
  971. }
  972. ],
  973. [
  974. {
  975. span: 30,
  976. label: '',
  977. slot: true,
  978. prop: 'makeupTable',
  979. }
  980. ],
  981. [
  982. {
  983. span: 20,
  984. label: '是否公布',
  985. slot: true,
  986. prop: 'issued',
  987. }
  988. ],
  989. [
  990. {
  991. span: 20,
  992. label: '商品规格',
  993. slot: true,
  994. prop: 'materialSpec',
  995. }
  996. ],
  997. [
  998. {
  999. span: 30,
  1000. label: '物料属性',
  1001. slot: true,
  1002. prop: 'attributeName',
  1003. }
  1004. ],
  1005. ],
  1006. }
  1007. config : any = {
  1008. attr: {
  1009. calculateH: true
  1010. },
  1011. search: {
  1012. attr: {
  1013. size: 'mini'
  1014. },
  1015. columns: [
  1016. [
  1017. {
  1018. span: 6,
  1019. label: '名称',
  1020. prop: 'name',
  1021. component: 'by-input',
  1022. labelWidth: '70px',
  1023. compConfig: {
  1024. attr: {
  1025. placeholder: '请输入名称',
  1026. clearable: true
  1027. }
  1028. },
  1029. }, {
  1030. span: 6,
  1031. label: '简称',
  1032. prop: 'shortName',
  1033. component: 'by-input',
  1034. labelWidth: '70px',
  1035. compConfig: {
  1036. attr: {
  1037. placeholder: '请输入简称',
  1038. clearable: true
  1039. }
  1040. }
  1041. },
  1042. {
  1043. span: 6,
  1044. label: '货号',
  1045. prop: 'itemNumber',
  1046. component: 'by-input',
  1047. labelWidth: '70px',
  1048. compConfig: {
  1049. attr: {
  1050. placeholder: '请输入货号',
  1051. clearable: true
  1052. }
  1053. }
  1054. },
  1055. ],
  1056. ]
  1057. },
  1058. tool: {
  1059. tools: {
  1060. add: true,
  1061. delete: true,
  1062. search: true,
  1063. refresh: true,
  1064. },
  1065. customTools: [
  1066. {
  1067. name: '同步金蝶物料', icon: 'el-icon-top', audit: [''], event: {
  1068. click: () => {
  1069. (this as any).syncSystem()
  1070. }
  1071. }
  1072. },
  1073. {
  1074. name: '商品监控', icon: 'el-icon-document', event: {
  1075. click: () => {
  1076. let data = (this.$refs.moduleView as any).getSelectData();
  1077. if(data.length !== 1) {
  1078. this.$message('请选择一条商品!')
  1079. return
  1080. }
  1081. (this.$refs.StoreRecord as any).setShow(true);
  1082. (this.$refs.StoreRecord as any).setData(data[0]);
  1083. }
  1084. }
  1085. }
  1086. ]
  1087. },
  1088. table: {
  1089. attr: {
  1090. size: 'mini',
  1091. align: 'left',
  1092. checkbox: true,
  1093. },
  1094. columns: [{
  1095. width: 250,
  1096. title: '名称',
  1097. field: 'name',
  1098. isDetail: true,
  1099. }, {
  1100. width: 200,
  1101. title: '简称',
  1102. field: 'shortName'
  1103. }, {
  1104. width: 200,
  1105. title: '货号',
  1106. field: 'itemNumber'
  1107. }, {
  1108. width: 200,
  1109. title: '国际码',
  1110. field: 'nsCode'
  1111. }, {
  1112. width: 90,
  1113. title: '基本售价',
  1114. field: 'basePrice'
  1115. }, {
  1116. width: 90,
  1117. title: '市场价格', // (市场价格统一售价)
  1118. field: 'markPrice'
  1119. },
  1120. {
  1121. width: 120,
  1122. title: '操作',
  1123. action: true,
  1124. plugins: [{
  1125. icon: 'el-icon-edit',
  1126. name: '编辑',
  1127. audit: '',
  1128. event: {
  1129. click: (item : any) => {
  1130. (this as any).getDetail(item)
  1131. }
  1132. }
  1133. }, {
  1134. name: '删除',
  1135. event: {
  1136. click: (item : any) => (this as any).doDelete2(item)
  1137. }
  1138. }]
  1139. }]
  1140. },
  1141. }
  1142. tableloading: boolean = true
  1143. tableRadio: any = {}
  1144. tableData: any = []
  1145. newtableData: any = []
  1146. tableSearchForm: any = {}
  1147. tableDataTotal: any = 0
  1148. tablePageSize: any = 10
  1149. tablePageNum: any = 1
  1150. productDataList: any = []
  1151. mounted() {
  1152. this.getAttribute()
  1153. this.timer = setInterval(() => {
  1154. this.getDataList()
  1155. }, 500)
  1156. // 获取关联金蝶财务系统物料列表
  1157. var t = new Date();
  1158. var y = t.getFullYear();
  1159. var m:any = t.getMonth()+1;
  1160. if(m<10){m='0'+m}
  1161. var d:any = t.getDate()
  1162. if(d<10){d='0'+d}
  1163. this.tableSearchForm.stime = '2020-01-01';
  1164. this.tableSearchForm.etime = y+'-'+m+'-'+d;
  1165. this.etime = y+'-'+m+'-'+d;
  1166. // this.getFinancialCode()
  1167. }
  1168. // 确定商品新增
  1169. confirmProduct(e : any) {
  1170. this.$nextTick(() => {
  1171. let nowData = (this.$refs.makeupTable as any).getValue();
  1172. let names = '';
  1173. if (e.length > 0) {
  1174. for (const item of e) {
  1175. this.productDataList.push(item)
  1176. let t = true;
  1177. for (const t_item of nowData) {
  1178. if (item.id == t_item.materialSkuId) {
  1179. if (!names) {
  1180. names = item.skuTitle
  1181. } else {
  1182. names = names + ',' + item.skuTitle
  1183. }
  1184. t = false;
  1185. break;
  1186. }
  1187. }
  1188. if (t) {
  1189. let obj : any = {};
  1190. obj.title = item.skuTitle
  1191. obj.subtitle = item.skuSubtitle
  1192. obj.materialSkuId = item.id
  1193. obj.isDeleted = 0
  1194. this.makeupList.push(obj);
  1195. nowData.push(obj);
  1196. }
  1197. };
  1198. (this as any).$refs.makeupTable.setValue(nowData) // 设置表格数据
  1199. if (names) {
  1200. this.$alert('商品 “' + names + '”已存在!', '提示', {
  1201. confirmButtonText: '确定',
  1202. });
  1203. }
  1204. }
  1205. })
  1206. }
  1207. //点击树获取数据
  1208. onChangeTree(e : any) {
  1209. this.categoryIds = e.id;
  1210. var ids:any = e.id;
  1211. if(e.id[0]==0) ids = 0;
  1212. let loading = this.$loading({ target: '.main-container' });
  1213. api.byCategoryPage({
  1214. categoryId: ids,
  1215. pageSize: 20,
  1216. pageNo: 1,
  1217. }, 'maindataMaterialCategory').then((res : any) => {
  1218. loading.close();
  1219. if (res.code === 200) {
  1220. (this.$refs.moduleView as any).setTableValue(res.data.records);
  1221. let page = {
  1222. pageNo: res.data.current, //当前页
  1223. pageSize: res.data.size, //每页条数
  1224. total: res.data.total //总条数
  1225. };
  1226. (this.$refs.moduleView as any).setPage(page);
  1227. }
  1228. }).catch(() => loading.close());
  1229. }
  1230. // 保存编辑/新增
  1231. doFormData() {
  1232. (this as any).$refs.form.validate().then(() => {
  1233. let query = (this as any).$refs.form.getValue();
  1234. // console.log('物料信息 ==> ', query);
  1235. query.materialSpec = this.materialSpec; // 商品规格
  1236. query.attributeList = JSON.stringify(this.attributeList) // 物料属性
  1237. query.attributeId = this.attributeId // 物料属性ID
  1238. query.status = this.status; // 物料状态
  1239. query.tags = this.tagsData.join(","); // 标签
  1240. query.ismakeup = this.ismakeup; // 商品组合
  1241. query.issued = this.issued; // 是否公布
  1242. query.description = this.textarea; // 备注
  1243. let data : any = {}
  1244. // 多规格
  1245. if (query.materialSpec === 1) {
  1246. if (this.tableList.length <= 0 || this.attributeList.length <= 0) return (this as any).$message.warning('多规格商品,物料属性不能为空!');
  1247. // console.log('多规格表格数据 ==> ', this.tableList);
  1248. for (let v of this.tableList) {
  1249. // if (!v.price) return this.$message.warning('物料属性价格必填');
  1250. // if (parseInt(v.price) <= 0) return this.$message.warning('物料属性价格不能小于1');
  1251. // if (!v.unit) return this.$message.warning('物料属性单位必填');
  1252. // if (!v.stock) return this.$message.warning('物料属性库存必填');
  1253. // if (parseInt(v.stock) <= 0) return this.$message.warning('物料属性库存必须为自然数');
  1254. // if (!v.shelfLife) return this.$message.warning('物料属性保质期必填');
  1255. // if (parseInt(v.shelfLife) <= 0) return this.$message.warning('物料属性保质期必须为自然数');
  1256. // if (!v.weight) return this.$message.warning('物料属性重量必填');
  1257. // if (parseInt(v.weight) <= 0) return this.$message.warning('物料属性重量不能小于1');
  1258. // if (!v.length) return this.$message.warning('物料属性长度必填');
  1259. // if (parseInt(v.length) <= 0) return this.$message.warning('物料属性长度不能小于1');
  1260. // if (!v.width) return this.$message.warning('物料属性宽度必填');
  1261. // if (parseInt(v.width) <= 0) return this.$message.warning('物料属性宽度不能小于1');
  1262. // if (!v.height) return this.$message.warning('物料属性高度必填');
  1263. // if (parseInt(v.height) <= 0) return this.$message.warning('物料属性高度不能小于1');
  1264. (this.$refs.table as any).validate();
  1265. if (!v.skuTitle) return this.$message.warning('物料标题必填');
  1266. if (!v.skuCode) return this.$message.warning('物料编码必填');
  1267. if (!v.barCode) return this.$message.warning('物料属性的69码-商品条码需必填');
  1268. if (!/^\d{1,32}$/.test(v.barCode)){
  1269. return this.$message.warning('69码-商品条码为数字,最大32位');
  1270. }
  1271. // if(v.weight&&v.weight!=0){
  1272. // v.weight = v.weight/1000
  1273. // }
  1274. // v.isDeleted = 0
  1275. v.ismakeup = this.ismakeup
  1276. };
  1277. data = { maindataMaterialReceiveParam: query, maindataMaterialSkus: this.tableList }
  1278. let newArray : any = []
  1279. let materialSpecData : any = []
  1280. let attributeLength = this.attributeList.length
  1281. this.tableList.map((v : any) => {
  1282. for (let kyes in v) {
  1283. if (kyes.indexOf('_field_name') != -1) {
  1284. let key = kyes.split('_field_name')[0]
  1285. newArray.push({ [key]: v[kyes] })
  1286. }
  1287. }
  1288. })
  1289. // console.log('newArray ==> ',newArray);
  1290. for (var i = 0; i < newArray.length; i += attributeLength) {
  1291. materialSpecData.push(newArray.slice(i, i + attributeLength));
  1292. }
  1293. // console.log('materialSpecData ==> ', materialSpecData);
  1294. data.maindataMaterialSkus.map((v : any, i : any) => {
  1295. if (materialSpecData[i]) v.materialSpec = JSON.stringify(materialSpecData[i])
  1296. })
  1297. } else { // 单规格
  1298. data = { maindataMaterialReceiveParam: query, maindataMaterialSkus: (this.$refs.singeTable as any).getValue() }
  1299. // console.log('单规格表格数据 ==> ', data.maindataMaterialSkus);
  1300. for (let v of data.maindataMaterialSkus) {
  1301. // if (!v.price) return this.$message.warning('物料价格必填');
  1302. // if (parseInt(v.price) <= 0) return this.$message.warning('物料价格不能小于1');
  1303. // if (parseInt(v.price) < 0) return this.$message.warning('物料价格不能为负数');
  1304. // if (!v.unit) return this.$message.warning('物料单位必填');
  1305. // if (!v.stock) return this.$message.warning('物料库存必填');
  1306. // if (parseInt(v.stock) <= 0) return this.$message.warning('物料库存必须为自然数');
  1307. // if (!v.shelfLife) return this.$message.warning('物料保质期必填');
  1308. // if (parseInt(v.shelfLife) <= 0) return this.$message.warning('物料保质期必须为自然数');
  1309. // if (!v.weight) return this.$message.warning('物料重量必填');
  1310. // if (parseInt(v.weight) <= 0) return this.$message.warning('物料重量不能小于1');
  1311. // if (!v.length) return this.$message.warning('物料长必填');
  1312. // if (parseInt(v.length) <= 0) return this.$message.warning('物料长不能小于1');
  1313. // if (!v.width) return this.$message.warning('物料宽必填');
  1314. // if (parseInt(v.width) <= 0) return this.$message.warning('物料宽不能小于1');
  1315. // if (!v.height) return this.$message.warning('物料高必填');
  1316. // if (parseInt(v.height) <= 0) return this.$message.warning('物料高不能小于1');
  1317. (this.$refs.singeTable as any).validate();
  1318. if (!v.skuTitle) return this.$message.warning('物料属性的标题需必填');
  1319. if (!v.skuCode) return this.$message.warning('物料属性的物料编码需必填');
  1320. if (!v.barCode) return this.$message.warning('物料属性的69码-商品条码需必填');
  1321. if (!/^\d{1,32}$/.test(v.barCode)){
  1322. return this.$message.warning('69码-商品条码为数字,最大32位');
  1323. }
  1324. // if(v.weight&&v.weight!=0){
  1325. // v.weight = v.weight/1000
  1326. // }
  1327. // v.isDeleted = 1
  1328. v.ismakeup = this.ismakeup
  1329. };
  1330. data.maindataMaterialSkus[0].isDeleted = 0;
  1331. data.maindataMaterialReceiveParam.attributeList = ""
  1332. }
  1333. if (this.ismakeup === 0) {
  1334. // console.log('this.makeupList ==> ', this.makeupList);
  1335. if (this.makeupList.length <= 0) return this.$message.warning('请选择组合商品');
  1336. data.maindataMaterialLinks = this.makeupList;
  1337. // 表格删除
  1338. data.maindataMaterialLinks.map((v : any, i : any) => {
  1339. if (v.isDeleted === 1 && !v.id) {
  1340. data.maindataMaterialLinks.splice(i, 1)
  1341. }
  1342. });
  1343. }
  1344. // console.log('data ==> ', data);
  1345. let loading = this.$loading({ target: '.main-container' });
  1346. if (this.isEdit) { // 编辑
  1347. api.updateList(data, 'maindataMaterial').then((res : any) => {
  1348. loading.close()
  1349. if (res.code === 200) {
  1350. this.isShow = 'home';
  1351. // (this as any).$refs.sideTree.request();
  1352. this.getDataList();
  1353. this.$message.success('保存成功');
  1354. }
  1355. }).catch(() => loading.close());
  1356. } else {// 新增
  1357. api.saveList(data, 'maindataMaterial').then((res : any) => {
  1358. loading.close()
  1359. if (res.code === 200) {
  1360. this.isShow = 'home';
  1361. // (this as any).$refs.sideTree.request();
  1362. this.getDataList();
  1363. this.$message.success('保存成功');
  1364. }
  1365. }).catch(() => loading.close());
  1366. }
  1367. }).catch(() => {});
  1368. }
  1369. // 打开新增
  1370. onAdd() {
  1371. this.isShow = 'add'; // 展示类型
  1372. this.selectValue = '' // 物料属性名称
  1373. this.towTable = '' // 表格数据
  1374. this.textarea = '' // 描述
  1375. this.tagsData = [] // 标签
  1376. this.attributeList = [] // 属性规格
  1377. this.tableList = [] // 表格数据
  1378. this.materialSpec = 0; // 单规格
  1379. this.status = 0; // 物料状态
  1380. this.ismakeup = 1; // 商品组合
  1381. this.makeupList = [] // 组合商品列表
  1382. this.issued = 0; // 是否公布
  1383. this.isSingle = true; // 显示单表格
  1384. this.isEdit = false; // 是否编辑
  1385. (this as any).$refs.byTool.setTool({ return: true, save: true });
  1386. this.$nextTick(() => {
  1387. (this as any).$refs.form.setValue(); // 设置表单数据
  1388. (this as any).$refs.singeTable.setValue([{}]) // 设置单表格数据
  1389. });
  1390. }
  1391. // 打开编辑
  1392. getDetail(e : any) {
  1393. // console.log('编辑 ==> ', e);
  1394. (this as any).$refs.byTool.setTool({ return: true, save: true, delete: true });
  1395. let loading = this.$loading({ target: '.my-container' });
  1396. api.single({ id: e.id }, 'maindataMaterial').then((v : any) => {
  1397. let data = v.data;
  1398. if (data.vmCategoryId) {
  1399. api.single({ id: data.vmCategoryId }, 'maindataMaterialVmcategory').then((res : any) => {
  1400. if (res.code === 200) {
  1401. if (res.data) data.vmCategoryName = res.data.name;
  1402. }
  1403. }).catch(() => loading.close());
  1404. }
  1405. if (data.organizationCategoryId) {
  1406. api.single({ id: data.organizationCategoryId }, 'maindataMaterialOrganizationCategory').then((res : any) => {
  1407. if (res.code === 200) {
  1408. if (res.data) data.organizationCategoryName = res.data.name;
  1409. }
  1410. }).catch(() => loading.close());
  1411. }
  1412. this.intercept = data.attributeId // 拦截物料属性判断
  1413. this.isEdit = true;
  1414. this.editInfo = data;
  1415. this.isShow = 'add';
  1416. // 标签
  1417. if (data.tags) {
  1418. this.tagsData = data.tags.split(",")
  1419. } else this.tagsData = [];
  1420. this.materialSpec = data.materialSpec
  1421. if(this.materialSpec == 1){
  1422. this.ismakeup = 1
  1423. }else{
  1424. this.ismakeup = 0
  1425. }
  1426. this.isSingle = data.materialSpec === 0 ? true : false;
  1427. if (data.attributeList) this.attributeList = JSON.parse(data.attributeList);
  1428. if (data.categoryId) {
  1429. api.single({ id: data.categoryId }, 'maindataMaterialCategory').then((res : any) => {
  1430. if (res.code === 200) data.categoryName = res.data.name;
  1431. if (data.attributeId) {
  1432. api.single({ id: data.attributeId }, 'maindataMaterialAttribute').then((p : any) => {
  1433. if (p.code === 200) {
  1434. if (p.data) this.selectValue = p.data.name
  1435. }
  1436. }).catch(() => loading.close());
  1437. }
  1438. other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
  1439. if (info.code === 200) {
  1440. this.status = data.status
  1441. // console.log(data.ismakeup);
  1442. this.ismakeup = data.ismakeup
  1443. if (data.ismakeup === 0 && data.maindataMaterialLinks.length > 0) {
  1444. (this as any).makeupList = data.maindataMaterialLinks;
  1445. setTimeout(() => {
  1446. (this as any).$refs.makeupTable.setValue(data.maindataMaterialLinks) // 设置组合表格数据
  1447. })
  1448. }
  1449. this.issued = data.issued
  1450. if (this.isSingle) {
  1451. this.selectValue = '' // 物料属性名称
  1452. this.towTable = '' // 表格数据
  1453. this.attributeList = []; // 属性规格
  1454. this.$nextTick(() => {
  1455. // console.log(info.data);
  1456. info.data.map((v : any, i : any) => {
  1457. // if(v.volume&&v.weight!='0.00'&&v.weight!=0&&v.weight!='0'){
  1458. // v.weight = parseFloat(v.weight)*1000
  1459. // }
  1460. if(v.volume&&v.volume!='0.00'&&v.volume!=0&&v.volume!='0'){
  1461. v.volume = parseFloat(v.volume).toFixed(2)
  1462. }
  1463. });
  1464. (this as any).$refs.singeTable.setValue(info.data);
  1465. });
  1466. } else {
  1467. this.forFun(this.attributeList[0], 0) // 生成sku
  1468. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1469. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1470. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1471. info.data.map((v : any, i : any) => {
  1472. v = Object.assign(v, skuRuleList[i])
  1473. v.dataIndex = i
  1474. // if(v.volume&&v.weight!='0.00'&&v.weight!=0&&v.weight!='0'){
  1475. // v.weight = parseFloat(v.weight)*1000
  1476. // }
  1477. if(v.volume&&v.volume!='0.00'&&v.volume!=0&&v.volume!='0'){
  1478. v.volume = parseFloat(v.volume).toFixed(2)
  1479. }
  1480. });
  1481. newColumns.map((v : any) => {
  1482. tableConfig.columns.unshift({
  1483. width: '80px',
  1484. title: v.title,
  1485. field: v.field,
  1486. })
  1487. });
  1488. this.tableList = (this as any).$lodash.cloneDeep(info.data);
  1489. // console.log('表格配置 ==> ', tableConfig);
  1490. // console.log('skuRuleList ==> ', skuRuleList);
  1491. // console.log('表格数据 ==> ', this.tableList);
  1492. this.setTableConfig = tableConfig;
  1493. this.$nextTick(() => {
  1494. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1495. (this as any).$refs.table.setValue(this.tableList) // 设置表格数据
  1496. });
  1497. }
  1498. }
  1499. (this as any).$refs.form.setValue(data)
  1500. loading.close()
  1501. }).catch(() => loading.close());
  1502. }).catch(() => loading.close());
  1503. } else {
  1504. // loading.close();
  1505. // this.$message.error('该数据没有物料分类id')
  1506. other.selectByMaterialId({ id: data.id }, 'maindataMaterialSku').then((info : any) => {
  1507. if (info.code === 200) {
  1508. this.status = data.status
  1509. // console.log(data.ismakeup);
  1510. this.ismakeup = data.ismakeup
  1511. if (data.ismakeup === 0 && data.maindataMaterialLinks.length > 0) {
  1512. (this as any).makeupList = data.maindataMaterialLinks;
  1513. setTimeout(() => {
  1514. (this as any).$refs.makeupTable.setValue(data.maindataMaterialLinks) // 设置组合表格数据
  1515. })
  1516. }
  1517. this.issued = data.issued
  1518. if (this.isSingle) {
  1519. this.selectValue = '' // 物料属性名称
  1520. this.towTable = '' // 表格数据
  1521. this.attributeList = []; // 属性规格
  1522. this.$nextTick(() => {
  1523. (this as any).$refs.singeTable.setValue(info.data);
  1524. });
  1525. } else {
  1526. this.forFun(this.attributeList[0], 0) // 生成sku
  1527. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1528. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1529. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1530. info.data.map((v : any, i : any) => {
  1531. v = Object.assign(v, skuRuleList[i])
  1532. v.dataIndex = i
  1533. });
  1534. newColumns.map((v : any) => {
  1535. tableConfig.columns.unshift({
  1536. width: '80px',
  1537. title: v.title,
  1538. field: v.field,
  1539. })
  1540. });
  1541. this.tableList = (this as any).$lodash.cloneDeep(info.data);
  1542. // console.log('表格配置 ==> ', tableConfig);
  1543. // console.log('skuRuleList ==> ', skuRuleList);
  1544. // console.log('表格数据 ==> ', this.tableList);
  1545. this.setTableConfig = tableConfig;
  1546. this.$nextTick(() => {
  1547. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1548. (this as any).$refs.table.setValue(this.tableList) // 设置表格数据
  1549. });
  1550. }
  1551. }
  1552. (this as any).$refs.form.setValue(data)
  1553. loading.close()
  1554. }).catch(() => loading.close());
  1555. }
  1556. }).catch(() => loading.close());
  1557. }
  1558. // 同步金蝶物料
  1559. syncSystem() {
  1560. (this as any).dateDialogVisible = true
  1561. }
  1562. dateConfirm(){
  1563. if((this as any).stime){
  1564. (this as any).dateLoading = true;
  1565. var data = {
  1566. stime: (this as any).stime,
  1567. etime: (this as any).etime
  1568. }
  1569. // console.log(data)
  1570. api.syncMaterialByKingdeeToOms(data).then((res : any) => {
  1571. if(res.code === 200){
  1572. (this as any).dateDialogVisible = false;
  1573. (this as any).dateLoading = false;
  1574. this.$message.success('同步金蝶物料成功');
  1575. }else{
  1576. (this as any).dateLoading = false;
  1577. this.$message.error(res.msg);
  1578. }
  1579. }).catch(()=>{
  1580. (this as any).dateLoading = false;
  1581. })
  1582. }else{
  1583. this.$message.warning('请选择时间');
  1584. }
  1585. }
  1586. // 立即生成
  1587. generateNow() {
  1588. this.forFun(this.attributeList[0], 0) // 生成sku
  1589. let newArray : any = []
  1590. let materialSpecData : any = []
  1591. let attributeLength = this.attributeList.length
  1592. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1593. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1594. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1595. let tableList = (this as any).$refs.table.getValue();
  1596. tableList.map((v : any) => {
  1597. for (let key in v) {
  1598. if (key.indexOf('_field_name') != -1) {
  1599. delete v[key]
  1600. }
  1601. }
  1602. })
  1603. skuRuleList.map((v : any) => {
  1604. for (let kyes in v) {
  1605. if (kyes.indexOf('_field_name') != -1) {
  1606. let key = kyes.split('_field_name')[0]
  1607. newArray.push({ [key]: v[kyes] })
  1608. }
  1609. }
  1610. })
  1611. // console.log('skuRuleList ==> ', skuRuleList);
  1612. for (var i = 0; i < newArray.length; i += attributeLength) {
  1613. materialSpecData.push(newArray.slice(i, i + attributeLength));
  1614. }
  1615. // console.log('materialSpecData ==> ', materialSpecData);
  1616. skuRuleList.map((v : any, i : any) => {
  1617. v.materialSpec = JSON.stringify(materialSpecData[i]);
  1618. v.dataIndex = i;
  1619. v.isDeleted = 0;
  1620. if (tableList[i] && v.materialSpec.indexOf(tableList[i].materialSpec != -1)) {
  1621. v = Object.assign(v, tableList[i])
  1622. };
  1623. })
  1624. newColumns.map((v : any) => {
  1625. tableConfig.columns.unshift({
  1626. width: '80px',
  1627. title: v.title,
  1628. field: v.field,
  1629. })
  1630. });
  1631. // console.log('旧表格数据 ==> ', tableList);
  1632. // console.log('新表格数据 ==> ', skuRuleList);
  1633. this.tableList = skuRuleList;
  1634. this.setTableConfig = tableConfig;
  1635. this.$nextTick(() => {
  1636. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1637. (this as any).$refs.table.setValue(this.tableList); // 设置表格数据
  1638. });
  1639. }
  1640. // 更换物料属性数据
  1641. getSelectValue(e : any) {
  1642. if (this.intercept === e) return console.log('拦截!');
  1643. this.$confirm('确定更换物料属性吗?确定之后原表格数据会被清除', '注意', {
  1644. confirmButtonText: '确定',
  1645. cancelButtonText: '取消',
  1646. type: 'warning',
  1647. center: true
  1648. }).then(() => {
  1649. api.single({ id: e }, 'maindataMaterialAttribute').then((res : any) => {
  1650. if (res.code === 200) {
  1651. this.selectList.map((v : any) => {
  1652. if (v.id === e) {
  1653. v.id = e
  1654. this.selectValue = v.name
  1655. }
  1656. });
  1657. this.intercept = e
  1658. this.attributeList = JSON.parse(res.data.attributeValue);
  1659. this.attributeId = e
  1660. this.forFun(this.attributeList[0], 0) // 生成sku
  1661. let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
  1662. let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
  1663. let newColumns = (this as any).$lodash.cloneDeep(this.attributeList).reverse();
  1664. let giveInfo = (this as any).$refs.form.getValue();
  1665. skuRuleList.map((v : any, i : any) => {
  1666. v.dataIndex = i;
  1667. v.isDeleted = 0;
  1668. v.skuTitle = giveInfo.name;
  1669. v.skuSubtitle = giveInfo.shortName;
  1670. v.price = giveInfo.basePrice
  1671. })
  1672. newColumns.map((v : any) => {
  1673. tableConfig.columns.unshift({
  1674. width: '80px',
  1675. title: v.title,
  1676. field: v.field,
  1677. })
  1678. });
  1679. // console.log('表格配置 ==> ', tableConfig);
  1680. // console.log('表格数据 ==> ', skuRuleList);
  1681. this.setTableConfig = tableConfig;
  1682. this.tableList = skuRuleList;
  1683. this.$nextTick(() => {
  1684. (this as any).$refs.table.setConfig(tableConfig); // 设置表格配置
  1685. (this as any).$refs.table.setValue(skuRuleList); // 设置表格数据
  1686. });
  1687. }
  1688. }).catch(() => {});
  1689. }).catch(() => { });
  1690. }
  1691. // 关联金蝶财务系统物料选择
  1692. handleSelectionChange(row: any){
  1693. // console.log(row)
  1694. this.tableRadio = row
  1695. }
  1696. // 关联金蝶财务系统物料列表搜索
  1697. tableSearchOnSubmit(){
  1698. this.getFinancialCode()
  1699. }
  1700. // 关联金蝶财务系统物料列表重置
  1701. resetTableSearch(){
  1702. var t = new Date();
  1703. var y = t.getFullYear();
  1704. var m:any = t.getMonth()+1;
  1705. if(m<10){m='0'+m}
  1706. var d:any = t.getDate()
  1707. if(d<10){d='0'+d}
  1708. this.tableSearchForm.fname = null;
  1709. this.tableSearchForm.fnumber = null;
  1710. this.tableSearchForm.stime = '2020-01-01';
  1711. this.tableSearchForm.etime = y+'-'+m+'-'+d;
  1712. this.getFinancialCode()
  1713. }
  1714. // 关联金蝶财务系统物料表格分页
  1715. currentChange(e: any){
  1716. this.newtableData = this.tableData.slice((e-1)*this.tablePageSize, e*this.tablePageSize)
  1717. }
  1718. // 打开关联金蝶财务系统物料选择
  1719. openVxeData(){
  1720. this.vxeValue = true;
  1721. if(this.tableData.length==0){
  1722. setTimeout(()=>{
  1723. this.getFinancialCode();
  1724. },0)
  1725. }
  1726. }
  1727. // 获取关联金蝶财务系统物料列表
  1728. getFinancialCode(){
  1729. this.tableloading = true;
  1730. api.getFinancialCode(this.tableSearchForm).then((res : any) => {
  1731. if(res.code==200){
  1732. this.tableloading = false;
  1733. this.tableData = res.data
  1734. if(this.tableSearchForm.fname || this.tableSearchForm.fnumber){
  1735. let newData = [];
  1736. if(this.tableSearchForm.fname){
  1737. newData = this.tableData.filter((v : any) => v.fname.indexOf(this.tableSearchForm.fname) != -1);
  1738. }
  1739. if(this.tableSearchForm.fnumber){
  1740. newData = this.tableData.filter((v : any) => v.fnumber.indexOf(this.tableSearchForm.fnumber) != -1);
  1741. }
  1742. if(this.tableSearchForm.fname && this.tableSearchForm.fnumber){
  1743. newData = this.tableData.filter((v : any) => v.fname.indexOf(this.tableSearchForm.fname) != -1 && v.fnumber.indexOf(this.tableSearchForm.fnumber) != -1);
  1744. }
  1745. this.tableDataTotal = newData.length
  1746. this.newtableData = newData.slice(0, this.tablePageNum*this.tablePageSize)
  1747. }else{
  1748. this.tableDataTotal = this.tableData.length
  1749. this.newtableData = this.tableData.slice(0, this.tablePageNum*this.tablePageSize)
  1750. }
  1751. }else{
  1752. this.$message.error(res.msg);
  1753. this.tableloading = false;
  1754. }
  1755. }).catch(() => {});
  1756. }
  1757. // 确定关联金蝶财务系统物料
  1758. doConfirm() {
  1759. if(JSON.stringify(this.tableRadio) === "{}" || this.tableRadio === null || this.tableRadio === {}) { return this.$message.warning('请选择物料'); }
  1760. // 表单赋值赋值
  1761. var val2 = (this as any).$refs.form.getValue();
  1762. val2.name = this.tableRadio.fname;
  1763. val2.shortName = this.tableRadio.fname;
  1764. // 物料属性赋值
  1765. var val = (this as any).$refs.singeTable.getValue();
  1766. if(JSON.stringify(val[0]) === "{}" || val[0] === null){
  1767. val = [{
  1768. skuTitle: this.tableRadio.fname,
  1769. skuSubtitle: this.tableRadio.fname,
  1770. // skuCode: '',
  1771. financialCode: this.tableRadio.fnumber,
  1772. // price: '0',
  1773. unit: this.tableRadio.fbaseUnitName,
  1774. unitCode: this.tableRadio.fbaseUnitCode,
  1775. // shelfLife: '0',
  1776. // weight: '0',
  1777. // length: '0',
  1778. // width: '0',
  1779. // height: '0',
  1780. // volume: '0',
  1781. }];
  1782. this.$message.success('关联物料 '+this.tableRadio.fname+' 成功');
  1783. }else{
  1784. this.$message.success('物料 '+val[0].skuTitle+' 信息变更为 '+this.tableRadio.fname);
  1785. val[0].skuTitle = this.tableRadio.fname;
  1786. val[0].skuSubtitle = this.tableRadio.fname;
  1787. val[0].financialCode = this.tableRadio.fnumber;
  1788. val[0].unit = this.tableRadio.fbaseUnitName;
  1789. val[0].unitCode = this.tableRadio.fbaseUnitCode;
  1790. }
  1791. (this as any).$refs.singeTable.setValue(val);
  1792. (this as any).$refs.form.setValue(val2);
  1793. this.vxeValue = false;
  1794. }
  1795. // 切换组合商品
  1796. openMakeup() {
  1797. (this.$refs.product as any).setShow(true); // 打开sku弹窗
  1798. }
  1799. // 切换商品规格
  1800. changeSingle() {
  1801. if(this.materialSpec == 1){
  1802. this.ismakeup = 1
  1803. }
  1804. if (this.isSingle) {
  1805. if ((this as any).$refs.singeTable) this.singeTable = (this as any).$refs.singeTable.getValue()
  1806. this.isSingle = false;
  1807. this.$nextTick(() => {
  1808. // 设置表格数据
  1809. if (this.towTable) {
  1810. if ((this as any).$refs.table) {
  1811. this.tableList = this.towTable;
  1812. (this as any).$refs.table.setConfig(this.setTableConfig); // 设置表格配置
  1813. (this as any).$refs.table.setValue(this.towTable); // 设置表格数据
  1814. }
  1815. }
  1816. });
  1817. } else {
  1818. if ((this as any).$refs.table) this.towTable = (this as any).$refs.table.getValue()
  1819. this.isSingle = true;
  1820. this.$nextTick(() => {
  1821. // 设置单表格数据
  1822. if (this.singeTable) {
  1823. // console.log('单表格数据 ==> ', this.singeTable);
  1824. (this as any).$refs.singeTable.setValue(this.singeTable);
  1825. } else (this as any).$refs.singeTable.setValue([{}]);
  1826. });
  1827. }
  1828. }
  1829. // 添加规格
  1830. showInput(index : any) {
  1831. this.$confirm('确定添加吗!确定后将可能影响原表格数据', '注意', {
  1832. confirmButtonText: '确定',
  1833. cancelButtonText: '取消',
  1834. type: 'warning',
  1835. center: true
  1836. }).then(() => {
  1837. let inputValue = (this as any).$refs['getValue_' + index][0].getValue();
  1838. if (!inputValue) return (this as any).$message.warning('请输入内容');
  1839. if (!/^\S*$/.test(inputValue)) return (this as any).$message.warning('输入内容不能有空格');
  1840. if (this.attributeList[index].list.indexOf(inputValue) !== -1) return (this as any).$refs['getValue_' + index][0].clearValue();
  1841. if (inputValue) {
  1842. this.attributeList[index].list.push(inputValue);
  1843. }
  1844. (this as any).$refs['getValue_' + index][0].clearValue();
  1845. this.generateNow();
  1846. this.$message.success('添加成功');
  1847. }).catch(() => this.$message.info('已取消添加'));
  1848. }
  1849. // 添加sku规格
  1850. doComfirm() {
  1851. if (!this.normsValue || !this.norms) return (this as any).$message.warning('请添加完整的规格');
  1852. if (!/^\S*$/.test(this.normsValue) || !/^\S*$/.test(this.norms)) return this.$message.warning('输入内容不能有空格');
  1853. this.$confirm('确定添加吗!确定后将可能影响原表格数据', '注意', {
  1854. confirmButtonText: '确定',
  1855. cancelButtonText: '取消',
  1856. type: 'warning',
  1857. center: true
  1858. }).then(() => {
  1859. let obj : any = {
  1860. title: this.norms,
  1861. field: this.norms + '_field_name',
  1862. list: [this.normsValue]
  1863. };
  1864. this.attributeList.push(obj);
  1865. this.norms = '';
  1866. this.normsValue = '';
  1867. this.isAdd = false;
  1868. this.generateNow();
  1869. this.$message.success('添加成功');
  1870. }).catch(() => this.$message.info('已取消添加'));
  1871. }
  1872. // 监听表格数据
  1873. getInputValue(e : any) {
  1874. // console.log('监听表格 ==> ', e);
  1875. if (e.length && e.width && e.height) {
  1876. e.volume = (e.length * e.width * e.height).toFixed(2);
  1877. }
  1878. }
  1879. // 监听组合商品表格数据
  1880. getMakeupTableValue(e : any) {
  1881. // console.log('监听表格 ==> ', e);
  1882. // console.log(this.productDataList)
  1883. this.volumeCount()
  1884. }
  1885. volumeCount(){
  1886. let nowData:any = (this.$refs.makeupTable as any).getValue();
  1887. var data:any = {
  1888. weight: 0,
  1889. length: 0,
  1890. width: 0,
  1891. height: 0
  1892. }
  1893. for (let i in this.productDataList) {
  1894. for (let j in nowData) {
  1895. if(this.productDataList[i].id==nowData[j].materialSkuId){
  1896. var number:any = 1;
  1897. if(nowData[j].number){
  1898. var number:any = parseFloat(nowData[j].number).toFixed(2);
  1899. }
  1900. if(this.productDataList[i].weight){
  1901. var weight:any = parseFloat(this.productDataList[i].weight).toFixed(2);
  1902. data.weight += weight*number;
  1903. }
  1904. if(this.productDataList[i].length){
  1905. var length:any = parseFloat(this.productDataList[i].length).toFixed(2);
  1906. data.length += length*number;
  1907. }
  1908. if(this.productDataList[i].width){
  1909. var width:any = parseFloat(this.productDataList[i].width).toFixed(2);
  1910. data.width += width*number;
  1911. }
  1912. if(this.productDataList[i].height){
  1913. var height:any = parseFloat(this.productDataList[i].height).toFixed(2);
  1914. data.height += height*number;
  1915. }
  1916. }
  1917. }
  1918. }
  1919. var val = (this as any).$refs.singeTable.getValue();
  1920. val[0].weight = data.weight;
  1921. val[0].length = data.length;
  1922. val[0].width = data.width;
  1923. val[0].height = data.height;
  1924. (this as any).$refs.singeTable.setValue(val);
  1925. }
  1926. // 排序生成
  1927. forFun(data : any, i : number, v ?: any) {
  1928. if (data.list) {
  1929. let d : Array<any> = [];
  1930. data.list.forEach((item : any) => {
  1931. if (i == 0) { // 第一次循环
  1932. let obj : any = {}
  1933. obj[data.field] = item
  1934. d.push(obj);
  1935. } else {
  1936. v.forEach((ele : any) => {
  1937. let obj : any = {};
  1938. obj = (this as any).$lodash.clone(ele);
  1939. obj[data.field] = item
  1940. d.push(obj);
  1941. });
  1942. }
  1943. });
  1944. i++
  1945. if (this.attributeList[i]) {
  1946. this.forFun(this.attributeList[i], i, d);
  1947. }
  1948. else {
  1949. this.skuRuleList = d;
  1950. }
  1951. }
  1952. }
  1953. // 添加标签
  1954. getTagsValue() {
  1955. let value = (this as any).$refs.tagsValue.getValue().trim();
  1956. if (!value) return this.$message.warning('请输入标签值');
  1957. this.tagsData.push(value);
  1958. (this as any).$refs.tagsValue.clearValue();
  1959. }
  1960. // 删除标签
  1961. handleClose2(index : any) {
  1962. this.$confirm('确定删除吗!', '注意', {
  1963. confirmButtonText: '确定',
  1964. cancelButtonText: '取消',
  1965. type: 'warning',
  1966. center: true
  1967. }).then(() => {
  1968. this.tagsData.splice(index, 1)
  1969. this.$message.success('删除成功');
  1970. }).catch(() => this.$message.info('已取消删除'));
  1971. }
  1972. // 删除标签
  1973. handleClose(tag : any, index : any) {
  1974. this.$confirm('确定删除吗!确定后将可能影响原表格数据', '注意', {
  1975. confirmButtonText: '确定',
  1976. cancelButtonText: '取消',
  1977. type: 'warning',
  1978. center: true
  1979. }).then(() => {
  1980. this.attributeList[index].list.splice(this.attributeList[index].list.indexOf(tag), 1);
  1981. this.generateNow();
  1982. this.$message.success('删除成功');
  1983. }).catch(() => this.$message.info('已取消删除'));
  1984. }
  1985. // 删除数组
  1986. closeGroup(index : any) {
  1987. this.$confirm('确定删除吗!确定后将可能影响原表格数据', '注意', {
  1988. confirmButtonText: '确定',
  1989. cancelButtonText: '取消',
  1990. type: 'warning',
  1991. center: true
  1992. }).then(() => {
  1993. this.attributeList.splice(index, 1);
  1994. this.generateNow();
  1995. this.$message.success('删除成功');
  1996. }).catch(() => this.$message.info('已取消删除'));
  1997. }
  1998. // 删除表格数据
  1999. doDeleteTable(item : any) {
  2000. if((this as any).tableList.length>1){
  2001. this.$confirm('确定删除吗!', '注意', {
  2002. confirmButtonText: '确定',
  2003. cancelButtonText: '取消',
  2004. type: 'warning',
  2005. center: true
  2006. }).then(() => {
  2007. // console.log(this.tableList);
  2008. (this as any).tableList.map((v : any) => {
  2009. if (v.dataIndex === item.dataIndex) v.isDeleted = 1;
  2010. })
  2011. let filterList = this.tableList.filter((v : any) => v.isDeleted !== 1);
  2012. (this as any).$refs.table.setValue(filterList); // 设置表格数据
  2013. this.$message.success('删除成功');
  2014. }).catch(() => this.$message.info('已取消删除'));
  2015. }else{
  2016. this.$message.warning('物料属性不能为空,无法删除!')
  2017. }
  2018. }
  2019. // 获取物料属性
  2020. getAttribute() {
  2021. api.pageList({
  2022. pageSize: 999,
  2023. status: 0
  2024. }, 'maindataMaterialAttribute').then((res : any) => {
  2025. if (res.code === 200) {
  2026. this.selectList = res.data.records
  2027. } else this.$message.error(res.msg);
  2028. }).catch(() => {});
  2029. }
  2030. // 获取列表数据
  2031. getDataList() {
  2032. if (!this.$refs.moduleView) {
  2033. if (this.timeNum > 5) {
  2034. clearInterval(this.timer)
  2035. }
  2036. this.timeNum++;
  2037. return
  2038. }
  2039. clearInterval(this.timer)
  2040. let query = (this.$refs.moduleView as any).getQuery();
  2041. if (this.categoryIds) query.categoryIds = this.categoryIds;
  2042. // console.log('表单字段 ==> ', query);
  2043. this.getPageList(query)
  2044. }
  2045. getPageList(query : any) {
  2046. let loading = this.$loading({ target: '.main-container' });
  2047. api.treeList('maindataMaterialCategory').then((treeRes : any) => {
  2048. if(treeRes.code==200){
  2049. api.pageList(query, 'maindataMaterial').then((res : any) => {
  2050. if (res.code === 200) {
  2051. var data:any = [{
  2052. id: 0,
  2053. name: '物料分类',
  2054. children: treeRes.data
  2055. }];
  2056. (this as any).$refs.sideTree.setData(data);
  2057. (this.$refs.moduleView as any).setTableValue(res.data.records);
  2058. let page = {
  2059. pageNo: res.data.current, //当前页
  2060. pageSize: res.data.size, //每页条数
  2061. total: res.data.total //总条数
  2062. };
  2063. (this.$refs.moduleView as any).setPage(page);
  2064. loading.close();
  2065. } else this.$message.error(res.msg);
  2066. }).catch(() => loading.close());
  2067. }
  2068. }).catch(() => loading.close());
  2069. }
  2070. // 工具栏方法
  2071. clickHandle(e : any) {
  2072. if (e === 'onAdd') this.onAdd();
  2073. if (e === 'onDelete') this.doDelete();
  2074. }
  2075. // 内页工具栏方法
  2076. insideTools(e : any) {
  2077. // console.log(e);
  2078. if (e === 'onReturn') this.isShow = 'home';
  2079. if (e === 'onSave') this.doFormData();
  2080. if (e === 'onDelete') this.pageDelete(this.editInfo);
  2081. }
  2082. // 组合商品删除
  2083. deleteMakeup(item : any) {
  2084. this.$confirm('确定删除吗', '注意', {
  2085. confirmButtonText: '确定',
  2086. cancelButtonText: '取消',
  2087. type: 'warning',
  2088. center: true
  2089. }).then((res) => {
  2090. // console.log(res)
  2091. let data = (this.$refs.makeupTable as any).getValue();// 获取表格数据
  2092. // let i = -1;
  2093. // let j = -1;
  2094. // for (const v of data) {
  2095. // i++;
  2096. // if (v.id == item.id) {
  2097. // break
  2098. // }
  2099. // };
  2100. // for (const v of this.makeupList) {
  2101. // j++;
  2102. // if (v.id == item.id && item.isDeleted === 0) {
  2103. // break
  2104. // }
  2105. // };
  2106. // this.makeupList[j].isDeleted = 1;
  2107. // data.splice(i, 1);
  2108. // this.productDataList.splice(i, 1);
  2109. for (var i = 0; i < data.length; i++) {
  2110. if(data[i].materialSkuId == item.materialSkuId){
  2111. if(item.isDeleted == 0){
  2112. this.makeupList[i].isDeleted = 1;
  2113. }
  2114. data.splice(i, 1);
  2115. this.productDataList.splice(i, 1)
  2116. }
  2117. };
  2118. (this.$refs.makeupTable as any).setValue(data);// 设置表格数据
  2119. this.$message.success('删除成功');
  2120. // setTimeout(()=> {
  2121. // this.volumeCount()
  2122. // }, 10);
  2123. }).catch((err) => {
  2124. this.$message.info('已取消删除');
  2125. // console.log(err)
  2126. });
  2127. }
  2128. // 内页删除
  2129. pageDelete(item : any) {
  2130. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  2131. confirmButtonText: '确定',
  2132. cancelButtonText: '取消',
  2133. type: 'warning',
  2134. center: true
  2135. }).then(() => {
  2136. other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
  2137. if (res.code === 200) {
  2138. this.$message.success('删除成功');
  2139. this.isShow = 'home';
  2140. // (this as any).$refs.sideTree.request();
  2141. this.getDataList();
  2142. } else this.$message.error(res.msg);
  2143. }).catch(() => {});
  2144. }).catch(() => this.$message.info('已取消删除'));
  2145. }
  2146. // 工具栏删除
  2147. doDelete() {
  2148. let selectData = (this.$refs.moduleView as any).getSelectData()
  2149. let ids = '';
  2150. if (selectData.length > 0) {
  2151. selectData.map((v : any) => {
  2152. ids += v.id + ','
  2153. })
  2154. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  2155. ids = ids.slice(0, ids.length - 1);
  2156. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  2157. confirmButtonText: '确定',
  2158. cancelButtonText: '取消',
  2159. type: 'warning',
  2160. center: true
  2161. }).then(() => {
  2162. other.deleteSpuAndSku({ ids: ids }, 'maindataMaterial').then((res : any) => {
  2163. if (res.code === 200) {
  2164. // (this as any).$refs.sideTree.request();
  2165. this.getDataList();
  2166. this.$message.success('删除成功');
  2167. } else this.$message.error(res.msg);
  2168. }).catch(() => {});
  2169. }).catch(() => this.$message.info('已取消删除'));
  2170. }
  2171. // 操作删除
  2172. doDelete2(item : any) {
  2173. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  2174. confirmButtonText: '确定',
  2175. cancelButtonText: '取消',
  2176. type: 'warning',
  2177. center: true
  2178. }).then(() => {
  2179. other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
  2180. if (res.code === 200) {
  2181. // (this as any).$refs.sideTree.request();
  2182. this.getDataList();
  2183. this.$message.success('删除成功');
  2184. } else this.$message.error(res.msg);
  2185. }).catch(() => {});
  2186. }).catch(() => this.$message.info('已取消删除'));
  2187. }
  2188. // 刷新
  2189. onRefresh() {
  2190. (this as any).$refs.moduleView.clearSearch();
  2191. // (this as any).$refs.sideTree.request();
  2192. this.categoryIds = '';
  2193. this.getDataList();
  2194. }
  2195. }
  2196. </script>
  2197. <style>
  2198. .el-tree{max-height: 100%;overflow-y: auto;}
  2199. </style>
  2200. <style lang="scss" scoped>
  2201. .my-container {
  2202. width: 100%;
  2203. box-sizing: border-box;
  2204. display: flex;
  2205. padding: 16px;
  2206. height: 100%;
  2207. .bill-left {
  2208. position: relative;
  2209. border-right: solid #EEE 1px;
  2210. padding-right: 16px;
  2211. flex-shrink: 0;
  2212. .bill-tab {
  2213. width: 210px;
  2214. height: 100%;
  2215. transition: all .5s;
  2216. overflow: auto;
  2217. }
  2218. .tab-title {
  2219. font-size: 16px;
  2220. padding-bottom: 16px;
  2221. width: 200px;
  2222. }
  2223. }
  2224. .item-tab {
  2225. margin-right: 16px;
  2226. }
  2227. .bill-main {
  2228. width: calc(100% - 16px);
  2229. box-sizing: border-box;
  2230. margin-left: 16px;
  2231. position: relative;
  2232. height: 100%;
  2233. overflow-y: hidden;
  2234. }
  2235. .detil {
  2236. width: 100%;
  2237. .box-shadow {
  2238. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  2239. padding: 20px;
  2240. border-radius: 4px;
  2241. border: 1px solid #e6ebf5;
  2242. background-color: #fff;
  2243. overflow: hidden;
  2244. color: #303133;
  2245. -webkit-transition: .3s;
  2246. transition: .3s;
  2247. margin-top: 20px;
  2248. }
  2249. }
  2250. }
  2251. </style>