index.vue 65 KB

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