index.vue 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221
  1. <template>
  2. <div class="app-container">
  3. <el-dialog
  4. :title="upload.title"
  5. :visible.sync="upload.open"
  6. width="400px"
  7. append-to-body
  8. >
  9. <el-upload
  10. ref="upload"
  11. :limit="1"
  12. accept=".xlsx, .xls"
  13. :headers="upload.headers"
  14. :action="
  15. upload.url +
  16. '?updateSupport=' +
  17. upload.updateSupport +
  18. '&tableName=' +
  19. tableName +
  20. '&sqlKey=' +
  21. tableKey
  22. "
  23. v-loading="upload.isUploading"
  24. :disabled="upload.isUploading"
  25. :on-progress="handleFileUploadProgress"
  26. :on-success="handleFileSuccess"
  27. :auto-upload="false"
  28. :onChange="handleChange"
  29. drag
  30. >
  31. <i class="el-icon-upload"></i>
  32. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  33. <div class="el-upload__tip text-center" slot="tip">
  34. <!-- <div class="el-upload__tip" slot="tip">-->
  35. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  36. <!-- 是否更新已经存在的用户数据-->
  37. <!-- </div>-->
  38. <span>仅允许导入xls、xlsx格式文件。</span>
  39. <el-link
  40. type="primary"
  41. :underline="false"
  42. style="font-size: 12px; vertical-align: baseline"
  43. @click="importTemplate"
  44. >下载模板
  45. </el-link>
  46. </div>
  47. </el-upload>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  50. <el-button @click="upload.open = false">取 消</el-button>
  51. </div>
  52. </el-dialog>
  53. <Queryfrom
  54. :form-vals="templateInfo.where"
  55. :statisticList="statisticList"
  56. :showCount="showCount"
  57. :showSearch="showSearch"
  58. @getList="getList"
  59. ref="mychild"
  60. />
  61. <el-row :gutter="10" class="mb8">
  62. <el-col :span="1.5">
  63. <el-button
  64. type="primary"
  65. plain
  66. icon="el-icon-plus"
  67. size="mini"
  68. @click="addHandler"
  69. >新增
  70. </el-button>
  71. </el-col>
  72. <!-- <el-col :span="1.5" v-if="false">
  73. <el-button
  74. type="success"
  75. plain
  76. icon="el-icon-edit"
  77. size="mini"
  78. :disabled="single"
  79. @click="handleUpdate"
  80. >修改
  81. </el-button>
  82. </el-col> -->
  83. <el-col :span="1.5">
  84. <el-button
  85. type="danger"
  86. plain
  87. icon="el-icon-delete"
  88. size="mini"
  89. :disabled="multiple"
  90. @click="batchDelete"
  91. >删除
  92. </el-button>
  93. </el-col>
  94. <el-col :span="1.5">
  95. <el-button
  96. plain
  97. icon="el-icon-upload2"
  98. size="mini"
  99. @click="upload.open = true"
  100. >导入
  101. </el-button>
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="warning"
  106. plain
  107. icon="el-icon-download"
  108. size="mini"
  109. @click="handleExport"
  110. >导出
  111. </el-button>
  112. </el-col>
  113. <right-toolbar
  114. :showCount.sync="showCount"
  115. :showSearch.sync="showSearch"
  116. :counts="true"
  117. @queryTable="pageList"
  118. ></right-toolbar>
  119. </el-row>
  120. <el-table
  121. v-loading="loading"
  122. :data="tableList"
  123. @selection-change="handleSelectionChange"
  124. ref="tableRef"
  125. :cell-style="cellStyle"
  126. :reserve-selection="true"
  127. :row-key="getRowKey"
  128. >
  129. <el-table-column
  130. type="selection"
  131. width="55"
  132. reserve-selection
  133. align="center"
  134. >
  135. </el-table-column>
  136. <!-- <span v-for="(key, val) in columns" :key="key">
  137. <el-table-column :label="key" align="center" :prop="val" />
  138. </span> -->
  139. <el-table-column
  140. v-for="item in columns"
  141. :key="item.key"
  142. :label="item.value"
  143. align="center"
  144. :prop="item.key"
  145. >
  146. <template slot-scope="scope">
  147. <!-- 存在字段样式或字典样式 -->
  148. <template
  149. v-if="
  150. scope.row.styleFieldObj != undefined &&
  151. scope.row.styleFieldObj[item.key]
  152. "
  153. >
  154. <!-- 字段样式 -->
  155. <template v-if="scope.row.styleFieldObj[item.key].styleType == 1">
  156. <!-- 一般字体样式 -->
  157. <template
  158. v-if="scope.row.styleFieldObj[item.key].fieldStyleType == 0"
  159. >
  160. <span
  161. :style="`color:${
  162. scope.row.styleFieldObj[item.key].fontColor
  163. }`"
  164. >{{ scope.row[item.key] }}</span
  165. >
  166. </template>
  167. <!-- 标签字体样式 -->
  168. <template
  169. v-else-if="
  170. scope.row.styleFieldObj[item.key].fieldStyleType == 1
  171. "
  172. >
  173. <el-tag
  174. :type="scope.row.styleFieldObj[item.key].tagType"
  175. :effect="
  176. scope.row.styleFieldObj[item.key].isTagFullBg
  177. ? 'dark'
  178. : 'light'
  179. "
  180. >
  181. {{ scope.row[item.key] }}
  182. </el-tag>
  183. </template>
  184. </template>
  185. <!-- 字典样式 -->
  186. <template
  187. v-else-if="scope.row.styleFieldObj[item.key].styleType == 2"
  188. >
  189. <span
  190. v-if="
  191. scope.row.styleFieldObj[item.key].listClass == '' ||
  192. scope.row.styleFieldObj[item.key].listClass == 'default'
  193. "
  194. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
  195. >
  196. <el-tag
  197. v-else
  198. :type="
  199. scope.row.styleFieldObj[item.key].listClass == 'primary'
  200. ? ''
  201. : scope.row.styleFieldObj[item.key].listClass
  202. "
  203. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</el-tag
  204. >
  205. </template>
  206. </template>
  207. <!-- 显示默认值 -->
  208. <template v-else>
  209. {{ scope.row[item.key] }}
  210. </template>
  211. </template>
  212. </el-table-column>
  213. <el-table-column
  214. v-if="isShowExcuteCol"
  215. label="操作"
  216. align="center"
  217. class-name="small-padding fixed-width"
  218. >
  219. <template slot-scope="scope">
  220. <el-button
  221. type="info"
  222. size="default"
  223. @click="handleEdit(scope.$index, scope.row)"
  224. >编辑</el-button
  225. >
  226. <Menu
  227. :row="scope.row"
  228. v-for="btnObj in excuteBtnArr"
  229. :key="btnObj.id"
  230. :listAll="btnObj"
  231. @excuteHandler="excuteHandler"
  232. ></Menu>
  233. </template>
  234. </el-table-column>
  235. </el-table>
  236. <pagination
  237. v-show="total > 0"
  238. :total="total"
  239. :page.sync="queryParams.pageNum"
  240. :limit.sync="queryParams.pageSize"
  241. @pagination="pageList"
  242. />
  243. <!-- k-form-build 组件渲染弹窗-->
  244. <el-dialog :title="title" :visible.sync="kOpen" append-to-body>
  245. <k-form-build
  246. v-if="jsonData"
  247. class="formBuild"
  248. ref="addFromRef"
  249. :dynamicData="dynamicData"
  250. :defaultValue="defaultValue"
  251. @submit="tempSubBtn"
  252. @change="formChangeHandler"
  253. :value="jsonData"
  254. />
  255. <div slot="footer" class="dialog-footer">
  256. <el-button type="primary" @click="editConfirmHandler">确 定</el-button>
  257. <el-button @click="kCancel">取 消</el-button>
  258. </div>
  259. </el-dialog>
  260. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  261. <el-dialog :title="title" :visible.sync="open" append-to-body>
  262. <!-- <iframe
  263. :src="iframeUrl"
  264. width="100%"
  265. height="600px"
  266. style="border: none"
  267. scrolling="no"
  268. >
  269. </iframe> -->
  270. <!-- <k-form-build
  271. v-if="jsonData"
  272. class="formBuild"
  273. ref="addFromRef"
  274. :dynamicData="dynamicData"
  275. :defaultValue="defaultValue"
  276. @submit="tempSubBtn"
  277. @change="formChangeHandler"
  278. :value="jsonData"
  279. /> -->
  280. <el-row :gutter="20">
  281. <el-form
  282. :model="formData"
  283. ref="formDataRef"
  284. :rules="rules"
  285. label-width="100px"
  286. :inline="true"
  287. size="normal"
  288. >
  289. <!-- <el-form-item prop="saleNo" label="合同号:">
  290. <el-input size="small" v-model="formData.saleNo"></el-input>
  291. </el-form-item> -->
  292. <el-col :span="12">
  293. <el-form-item prop="saleDate" label="日期:">
  294. <el-date-picker
  295. size="small"
  296. v-model="formData.saleDate"
  297. value-format="yyyy-MM-dd"
  298. format="yyyy-MM-dd"
  299. type="date"
  300. placeholder="选择日期"
  301. >
  302. </el-date-picker>
  303. </el-form-item>
  304. </el-col>
  305. <el-col :span="12">
  306. <el-form-item prop="saleCustomNo" label="客户名称:">
  307. <el-select
  308. size="small"
  309. v-model="formData.saleCustomNo"
  310. placeholder="请选择客户"
  311. clearable
  312. filterable
  313. @change="customChangeHandler"
  314. >
  315. <el-option
  316. v-for="item in customerOptions"
  317. :key="item.customNo"
  318. :label="item.customName"
  319. :value="item.customNo"
  320. >
  321. </el-option>
  322. </el-select>
  323. </el-form-item>
  324. </el-col>
  325. <el-col :span="12">
  326. <el-form-item label="联系人:" size="normal">
  327. {{ formData.contactPerson }}
  328. </el-form-item>
  329. <el-form-item label="客户地址:" size="normal">
  330. {{ formData.customAddress }}
  331. </el-form-item>
  332. <el-form-item label="客户国别:" size="normal">
  333. {{ formData.customCountryType }}
  334. </el-form-item>
  335. </el-col>
  336. <el-col :span="12">
  337. <el-form-item
  338. label-width="120px"
  339. prop="saleDate"
  340. label="预计下单时间:"
  341. >
  342. <el-date-picker
  343. size="small"
  344. v-model="formData.saleOrderEstimatedTime"
  345. value-format="yyyy-MM-dd"
  346. format="yyyy-MM-dd"
  347. type="date"
  348. placeholder="选择日期"
  349. >
  350. </el-date-picker>
  351. </el-form-item>
  352. </el-col>
  353. <el-col :span="12">
  354. <el-form-item label="交货周期:" size="normal">
  355. <el-input size="small" v-model="formData.saleLeadTime"></el-input>
  356. </el-form-item>
  357. </el-col>
  358. <el-col :span="24">
  359. <el-divider>货品明细</el-divider>
  360. </el-col>
  361. <el-table
  362. :data="productionTableData"
  363. border
  364. show-summary
  365. :summary-method="getSummaries"
  366. sum-text="小计"
  367. style="width: 100%"
  368. >
  369. <el-table-column prop="productName" label="品名" width="180">
  370. <template slot-scope="scope">
  371. <!-- <el-input
  372. v-model="scope.row.productName"
  373. size="small"
  374. clearable
  375. ></el-input> -->
  376. <el-select
  377. v-model="scope.row.productNo"
  378. placeholder=""
  379. clearable
  380. filterable
  381. >
  382. <el-option
  383. v-for="item in productionOptions"
  384. :key="item.productNo"
  385. :label="item.productName"
  386. :value="item.productNo"
  387. >
  388. </el-option>
  389. </el-select>
  390. </template>
  391. </el-table-column>
  392. <el-table-column prop="productNumber" label="数量/kg">
  393. <template slot-scope="scope">
  394. <el-input
  395. v-model="scope.row.productNumber"
  396. size="small"
  397. clearable
  398. @change="computedPrice(scope.row)"
  399. ></el-input>
  400. </template>
  401. </el-table-column>
  402. <el-table-column prop="productUnitPrice" label="单价">
  403. <template slot-scope="scope">
  404. <el-input
  405. v-model="scope.row.productUnitPrice"
  406. size="small"
  407. @change="computedPrice(scope.row)"
  408. clearable
  409. ></el-input>
  410. </template>
  411. </el-table-column>
  412. <el-table-column prop="productAmounts" label="金额">
  413. <template slot-scope="scope">
  414. <!-- <el-input
  415. v-model="scope.row.productAmounts"
  416. size="small"
  417. clearable
  418. ></el-input> -->
  419. {{ scope.row.productAmounts }}
  420. </template>
  421. </el-table-column>
  422. <el-table-column prop="remark" label="备注">
  423. <template slot-scope="scope">
  424. <el-input
  425. v-model="scope.row.remark"
  426. size="small"
  427. clearable
  428. ></el-input>
  429. </template>
  430. </el-table-column>
  431. <el-table-column label="操作">
  432. <template slot-scope="scope">
  433. <el-button
  434. type="danger"
  435. size="small"
  436. @click="deleteProduct(scope.$index)"
  437. >删除</el-button
  438. >
  439. </template>
  440. </el-table-column>
  441. </el-table>
  442. <el-button
  443. class="mt5"
  444. type="primary"
  445. style="width: 100%"
  446. size="small"
  447. @click="addProduct"
  448. >添加货品</el-button
  449. >
  450. <el-col :span="12">
  451. <el-form-item label-width="120px" label="合计金额(大写)">
  452. <el-input
  453. v-model="formData.saleAmountInWords"
  454. size="small"
  455. clearable
  456. ></el-input>
  457. </el-form-item>
  458. </el-col>
  459. <el-col :span="12">
  460. <el-form-item label="付款方式">
  461. <el-input
  462. v-model="formData.salePayType"
  463. size="small"
  464. clearable
  465. ></el-input>
  466. </el-form-item>
  467. </el-col>
  468. <el-col :span="24">
  469. <el-divider>工艺要求</el-divider>
  470. </el-col>
  471. <el-col :span="12">
  472. <el-form-item label="网格:">
  473. <el-input
  474. v-model="formData.craftGrid"
  475. size="small"
  476. clearable
  477. ></el-input>
  478. </el-form-item>
  479. </el-col>
  480. <el-col :span="12">
  481. <el-form-item label="油剂:">
  482. <el-input
  483. v-model="formData.craftOil"
  484. size="small"
  485. clearable
  486. ></el-input>
  487. </el-form-item>
  488. </el-col>
  489. <el-col :span="12">
  490. <el-form-item label="卷装:">
  491. <el-input
  492. v-model="formData.craftPackage"
  493. size="small"
  494. clearable
  495. ></el-input>
  496. </el-form-item>
  497. </el-col>
  498. <el-col :span="12">
  499. <el-form-item label="色牢度:">
  500. <el-input
  501. v-model="formData.craftColorFastness"
  502. size="small"
  503. clearable
  504. ></el-input>
  505. </el-form-item>
  506. </el-col>
  507. <el-col :span="12">
  508. <el-form-item label="其它:">
  509. <el-input
  510. v-model="formData.craftOther"
  511. size="small"
  512. clearable
  513. ></el-input>
  514. </el-form-item>
  515. </el-col>
  516. <el-col :span="12">
  517. <el-form-item label="包装/贴唛:">
  518. <el-input
  519. v-model="formData.craftMark"
  520. size="small"
  521. clearable
  522. ></el-input>
  523. </el-form-item>
  524. </el-col>
  525. <el-col :span="12">
  526. <el-form-item label="运输方式:">
  527. <el-input
  528. v-model="formData.shippingMethod"
  529. size="small"
  530. clearable
  531. ></el-input>
  532. </el-form-item>
  533. </el-col>
  534. <el-col :span="24">
  535. <el-divider>审计人员数据</el-divider>
  536. </el-col>
  537. <el-col :span="12">
  538. <el-form-item label="业务员:">
  539. <!-- <el-input
  540. v-model="formData.salesman"
  541. size="small"
  542. clearable
  543. ></el-input> -->
  544. {{ nickName }}
  545. </el-form-item>
  546. </el-col>
  547. </el-form>
  548. </el-row>
  549. <div slot="footer" class="dialog-footer">
  550. <el-button type="primary" @click="editConfirm">确 定</el-button>
  551. <el-button @click="cancel">取 消</el-button>
  552. </div>
  553. </el-dialog>
  554. <!-- 绑定按钮dialog -->
  555. <el-dialog
  556. title="提示"
  557. :visible.sync="btnDialogVisible"
  558. :before-close="handleClose"
  559. >
  560. <DialogTemplate
  561. ref="dialogRef"
  562. :groupKey="groupKey"
  563. :rowobj="rowobj"
  564. :subCount="subCount"
  565. :tableCount="tableCount"
  566. :subTableName="subTableName"
  567. @addList="addListHandler"
  568. >
  569. </DialogTemplate>
  570. <span slot="footer" class="dialog-footer">
  571. <el-button @click="btnDialogVisible = false">取 消</el-button>
  572. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  573. </span>
  574. </el-dialog>
  575. <!-- 自定义弹窗 -->
  576. <el-dialog
  577. title="提示"
  578. :visible.sync="btnDialogVisible"
  579. :before-close="handleClose"
  580. >
  581. <DialogTemplate
  582. ref="dialogRef"
  583. :groupKey="groupKey"
  584. :rowobj="rowobj"
  585. :subCount="subCount"
  586. :tableCount="tableCount"
  587. :subTableName="subTableName"
  588. @addList="addListHandler"
  589. >
  590. </DialogTemplate>
  591. <span slot="footer" class="dialog-footer">
  592. <el-button @click="btnDialogVisible = false">取 消</el-button>
  593. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  594. </span>
  595. </el-dialog>
  596. </div>
  597. </template>
  598. <script>
  599. import {
  600. delTableData,
  601. dragTableInfo,
  602. listTable,
  603. unionListTableData,
  604. getInfoBySqlKey,
  605. btnCommonApi,
  606. addTableData,
  607. batchEdit,
  608. getStatisticList,
  609. } from "@/api/tablelist/commonTable";
  610. import { listData } from "@/api/system/tenant/data";
  611. import { getToken } from "@/utils/auth";
  612. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  613. import { camelCase, toUnderline } from "@/utils";
  614. import { inputDisableComplete } from "@/utils/other";
  615. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  616. import { checkRole } from "@/utils/permission";
  617. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  618. import { queryDropDownBoxData } from "@/api/dragform/form";
  619. import { v4 as uuidv4 } from "uuid";
  620. import { mapState } from "vuex";
  621. import moment from "moment";
  622. export default {
  623. name: "listInfo",
  624. components: { Queryfrom, Menu, DialogTemplate },
  625. data() {
  626. return {
  627. // k-form-build组件渲染弹窗
  628. kOpen: false,
  629. // 新的自定义数据 start
  630. productIds: [], //货品Ids
  631. isEdit: false,
  632. formData: {
  633. //订单表数据
  634. saleNo: "", //合同号
  635. saleCustomNo: "", //客户编号
  636. saleDate: "", //销售单日期
  637. saleOrderEstimatedTime: "", //预计下单时间
  638. saleLeadTime: "", //交货周期
  639. saleAmounts: "", //合计金额 小写
  640. saleAmountInWords: "", //合计金额 大写
  641. salePayType: "", //支付方式
  642. salesman: "", //业务员
  643. saleLeader: "", //业务主管
  644. finance: "", //财务部
  645. production: "", //生产部
  646. saleApprover: "", //批准人
  647. customAddress: "", //客户地址
  648. customCountryType: "", //国家类型
  649. contactPerson: "", //联系人
  650. // 货品明细表数据
  651. productNo: "", //货品号
  652. productName: "", //货品名称
  653. productNumber: "", //销售数量
  654. productWeight: "", //销售重量kg
  655. productUnitPrice: "", //单价
  656. productAmounts: "", //金额
  657. remark: "", //备注
  658. // 工艺表
  659. craftGrid: "", //网格
  660. craftOil: "", //油剂
  661. craftPackage: "", //卷装
  662. craftColorFastness: "", //色牢度
  663. craftOther: "", //其它工艺要求
  664. craftMark: "", //包装/贴唛
  665. shippingMethod: "", //运输方式
  666. },
  667. productionOptions: [],
  668. customerOptions: [],
  669. productionTableData: [
  670. // {
  671. // productNo: "", //货品名称
  672. // productNumber: 2, //销售数量
  673. // productWeight: 1, //销售重量kg
  674. // productUnitPrice: 20, //单价
  675. // productAmounts: 20, //金额
  676. // remark: "", //备注
  677. // },
  678. ],
  679. rules: {},
  680. // end
  681. // 绑定按钮dialog
  682. btnDialogVisible: false,
  683. // 绑定修改dialog
  684. groupKey: "",
  685. // 遮罩层
  686. loading: true,
  687. // 选中数组
  688. ids: [],
  689. // 非单个禁用
  690. single: true,
  691. // 非多个禁用
  692. multiple: true,
  693. // 显示统计
  694. showCount: true,
  695. // 显示搜索条件
  696. showSearch: true,
  697. // 总条数
  698. total: 0,
  699. // 用户表格数据
  700. tableList: [],
  701. // 弹出层标题
  702. title: "",
  703. // 日期范围
  704. dateRange: [],
  705. // 表单参数
  706. form: {},
  707. rules: {},
  708. // cru 弹窗
  709. open: false,
  710. // excel共通导入数据
  711. upload: {
  712. // 是否显示弹出层
  713. open: false,
  714. // 弹出层标题(
  715. title: "",
  716. // 是否禁用上传
  717. isUploading: false,
  718. // 是否更新已经存在的数据
  719. updateSupport: 0,
  720. // 设置上传的请求头部
  721. headers: { Authorization: "Bearer " + getToken() },
  722. // 上传的地址
  723. url: process.env.VUE_APP_BASE_API3 + "common/uploadData",
  724. },
  725. // 排序方式 默认降序
  726. sortOrder: true,
  727. // 共通查询参数接受子组件的参数
  728. queryParams: {
  729. pageNum: 1, // 第几页
  730. pageSize: 10, // 每页大小
  731. orderByColumn: "", // 根据某列排序
  732. isAsc: "", // desc(降序)或 asc(升序)
  733. // 基本查询参数
  734. basicMap: {
  735. tableName: "drag_form",
  736. },
  737. // 当前表字段筛选参数
  738. queryMap: {
  739. // 当前查询基本参数
  740. // ... key : value 当前页面的筛选条件
  741. // 超级查询的唯一值
  742. queryCriteriaValue: "",
  743. },
  744. },
  745. // 列信息
  746. columns: {},
  747. // 当前模版信息
  748. templateInfo: {},
  749. // 查询条件
  750. queryFromWhere: {},
  751. // 当前table唯一标识
  752. tableKey: null,
  753. // 当前表名称
  754. tableName: null,
  755. //存放html代码块
  756. iframeUrl: "",
  757. //存放表单渲染数据
  758. jsonData: {},
  759. // 回显表格数据,
  760. defaultValue: {},
  761. // 统计card
  762. statisticList: [],
  763. // 样式表
  764. styleList: [],
  765. // 字典样式对象
  766. dictStyleObj: {},
  767. // 操作列 按钮数据
  768. excuteBtnArr: [],
  769. // 下拉框动态数据
  770. dynamicData: {},
  771. // 当前点击按钮的数据
  772. currentBtnData: {},
  773. // 修改选中行
  774. rowobj: {},
  775. // 该行的统计信息
  776. subCount: [],
  777. tableCount: [],
  778. // 弹窗新增数据
  779. addLists: [],
  780. subTableName: "",
  781. // 当前点击行的数据
  782. currentRow: {},
  783. };
  784. },
  785. created() {
  786. // 得到当前展示的table的唯一标识
  787. this.tableKey = this.$route.query.tableKey;
  788. },
  789. watch: {},
  790. computed: {
  791. isShowExcuteCol() {
  792. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  793. },
  794. ...mapState({
  795. nickName: (state) => state.user.nickName,
  796. }),
  797. },
  798. methods: {
  799. // 重置审计表单数据
  800. resetFormData() {
  801. Object.assign(this.formData, {
  802. //订单表数据
  803. saleNo: "", //合同号
  804. saleCustomNo: "", //客户编号
  805. saleDate: "", //销售单日期
  806. saleOrderEstimatedTime: "", //预计下单时间
  807. saleLeadTime: "", //交货周期
  808. saleAmounts: "", //合计金额 小写
  809. saleAmountInWords: "", //合计金额 大写
  810. salePayType: "", //支付方式
  811. salesman: "", //业务员
  812. saleLeader: "", //业务主管
  813. finance: "", //财务部
  814. production: "", //生产部
  815. saleApprover: "", //批准人
  816. customAddress: "", //客户地址
  817. customCountryType: "", //国家类型
  818. contactPerson: "", //联系人
  819. // 货品明细表数据
  820. productNo: "", //货品号
  821. productName: "", //货品名称
  822. productNumber: "", //销售数量
  823. productWeight: "", //销售重量kg
  824. productUnitPrice: "", //单价
  825. productAmounts: "", //金额
  826. remark: "", //备注
  827. // 工艺表
  828. craftGrid: "", //网格
  829. craftOil: "", //油剂
  830. craftPackage: "", //卷装
  831. craftColorFastness: "", //色牢度
  832. craftOther: "", //其它工艺要求
  833. craftMark: "", //包装/贴唛
  834. shippingMethod: "", //运输方式
  835. });
  836. this.productionTableData = [];
  837. },
  838. // 自定义的小计计算方法
  839. getSummaries(param) {
  840. const { columns, data } = param;
  841. console.log(columns, data);
  842. const sums = [];
  843. columns.forEach((column, index) => {
  844. if (index === 0) {
  845. sums[index] = "小计";
  846. return;
  847. }
  848. const values = data.map((item) => Number(item[column.property]));
  849. if (index === 4 || index === 5) {
  850. sums[index] = "";
  851. } else if (!values.every((value) => isNaN(value))) {
  852. sums[index] = values.reduce((prev, curr) => {
  853. const value = Number(curr);
  854. if (!isNaN(value)) {
  855. return prev + curr;
  856. } else {
  857. return prev;
  858. }
  859. }, 0);
  860. sums[index];
  861. } else {
  862. sums[index] = "N/A";
  863. }
  864. });
  865. return sums;
  866. },
  867. // 货品表格数据删除回调
  868. deleteProduct(index) {
  869. this.productionTableData.splice(index, 1);
  870. },
  871. // 货品表格数据新增回调
  872. addProduct() {
  873. this.productionTableData.push({
  874. saleProductNo: uuidv4(),
  875. productNo: "", //货品编号
  876. productName: "", //货品名称
  877. productNumber: "", //销售数量
  878. productWeight: "", //销售重量kg
  879. productUnitPrice: "", //单价
  880. productAmounts: "", //金额
  881. remark: "", //备注
  882. });
  883. },
  884. // 客户名称改变回调
  885. customChangeHandler(val) {
  886. // if (!val) return;
  887. let customData = this.customerOptions.find(
  888. (item) => item.customNo == val
  889. );
  890. this.formData.customAddress = customData?.customAddress || "无";
  891. this.formData.customCountryType = customData?.customCountryType || "无";
  892. this.formData.contactPerson = customData?.contactPerson || "无";
  893. },
  894. //审计新增
  895. async addHandler() {
  896. this.isEdit = false;
  897. await this.getDropDownData();
  898. this.resetFormData();
  899. this.title = "新增审计单";
  900. this.open = true;
  901. },
  902. // 获取下拉框数据
  903. async getDropDownData() {
  904. try {
  905. let payLoad = [
  906. {
  907. basicMap: {
  908. tableName: "production",
  909. },
  910. },
  911. {
  912. basicMap: {
  913. tableName: "customer",
  914. },
  915. },
  916. ];
  917. let res = await queryDropDownBoxData(payLoad);
  918. if (res.code == 200) {
  919. let { production, customer } = res.data.resultMap;
  920. this.productionOptions = production || [];
  921. this.customerOptions = customer || [];
  922. } else {
  923. throw Error("获取下拉框数据失败");
  924. }
  925. } catch (error) {
  926. console.log(error);
  927. }
  928. },
  929. // 获取row-key
  930. getRowKey(row) {
  931. return row[
  932. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  933. ];
  934. },
  935. /** 查询列表 */
  936. getList(queryParams) {
  937. this.loading = true;
  938. // 序列化当前查询参数列表
  939. queryParams && (this.queryParams.queryMap = queryParams.queryMap);
  940. // 获取当前表单结构信息
  941. dragTableInfo({ queryMap: { tableKey: this.tableKey } })
  942. .then((res) => {
  943. // 得到当前模版信息 --- sql columns queryWhere
  944. this.templateInfo = res.data.resultMap;
  945. this.styleList = res.data.resultMap.style?.map((item) => {
  946. item.styleField = camelCase(
  947. item.styleField.replace(".", "_") || ""
  948. );
  949. return item;
  950. });
  951. // 获取操作列的按钮数据
  952. this.excuteBtnArr = res.data.resultMap.button;
  953. this.queryParams.orderByColumn =
  954. res.data.resultMap.querySql.orderByColumn;
  955. this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
  956. // 根据拖拽时设置当前列表排列顺序
  957. this.queryParams.isAsc = this.sortOrder ? "DESC" : "ASC";
  958. this.tableName = this.templateInfo.template.dtTableName;
  959. // 得到查询条件
  960. this.queryFromWhere = res.data.resultMap.where;
  961. // 得到当前列表信息
  962. this.columns = this.columnsHandler(
  963. JSON.parse(this.templateInfo.template.dtColumnName)
  964. );
  965. })
  966. .finally((fes) => {
  967. if (this.templateInfo == {}) return;
  968. // 调用查询需要携带当前table的唯一标识
  969. this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
  970. this.queryParams.orderByColumn = camelCase(
  971. this.queryParams.orderByColumn || ""
  972. );
  973. // 根据sql语句查询当前表数据
  974. unionListTableData(this.queryParams).then(async (res) => {
  975. this.tableList = [];
  976. res.rows.forEach((item) => {
  977. this.tableList.push(item.resultMap);
  978. });
  979. // 驼峰转换
  980. let tempTableList = [];
  981. tempTableList = this.tableList.map((item) => {
  982. let kv = {};
  983. for (let itemKey in item) {
  984. kv[camelCase(itemKey)] = item[itemKey];
  985. }
  986. return kv;
  987. });
  988. // this.setDictStyleData().then(() => {
  989. // this.tableList = this.setFieldStyleData(this.tableList);
  990. // });
  991. this.tableList = await this.setFieldStyleData(tempTableList);
  992. this.total = res.total;
  993. // this.$nextTick(() => {
  994. // this.$refs.tableRef?.clearSelection();
  995. // });
  996. this.loading = false;
  997. });
  998. // 查询统计信息
  999. getStatisticList({
  1000. queryMap: {
  1001. tableKey: this.templateInfo.template.tableKey,
  1002. queryCriteriaValue: this.queryParams.queryMap.queryCriteriaValue,
  1003. },
  1004. }).then((res) => {
  1005. this.statisticList = res.data;
  1006. });
  1007. });
  1008. },
  1009. // 审计 提交编辑结果按钮回调
  1010. async editConfirm() {
  1011. this.$refs.formDataRef.validate(async (valid) => {
  1012. if (valid) {
  1013. let {
  1014. //订单表数据
  1015. saleCustomNo,
  1016. saleDate,
  1017. saleOrderEstimatedTime,
  1018. saleLeadTime,
  1019. saleAmounts,
  1020. saleAmountInWords,
  1021. salePayType,
  1022. salesman,
  1023. saleLeader,
  1024. finance,
  1025. production,
  1026. saleApprover,
  1027. // 工艺表数据
  1028. craftGrid,
  1029. craftOil,
  1030. craftPackage,
  1031. craftColorFastness,
  1032. craftOther,
  1033. craftMark,
  1034. shippingMethod,
  1035. } = this.formData;
  1036. let saleCraftNo = this.isEdit ? this.formData.saleCraftNo : uuidv4(),
  1037. saleNo = this.isEdit ? this.formData.saleNo : uuidv4();
  1038. let saleProductsNo = this.productionTableData
  1039. .map((item) => item.saleProductNo)
  1040. .join(","); //销售单表sale_products_no字段存货品表的sale_product_no,逗号分割
  1041. let saleValue = {
  1042. status: 1, //新增销售单时 默认为1
  1043. saleNo,
  1044. saleProductsNo,
  1045. saleOrderTechnologyNo: saleCraftNo,
  1046. saleCustomNo,
  1047. saleDate: moment(new Date(saleDate)).format("YYYY-MM-DD"),
  1048. saleOrderEstimatedTime: moment(
  1049. new Date(saleOrderEstimatedTime)
  1050. ).format("YYYY-MM-DD"),
  1051. saleLeadTime,
  1052. // saleAmounts, //合计金额 小写
  1053. saleAmountInWords,
  1054. salePayType,
  1055. salesman: this.nickName,
  1056. saleLeader,
  1057. finance,
  1058. production,
  1059. saleApprover,
  1060. };
  1061. let craftValue = {
  1062. saleOrderNo: saleNo,
  1063. saleCraftNo,
  1064. craftGrid,
  1065. craftOil,
  1066. craftPackage,
  1067. craftColorFastness,
  1068. craftOther,
  1069. craftMark,
  1070. shippingMethod,
  1071. };
  1072. let saleData = {
  1073. //订单表新增数据
  1074. basicMap: {
  1075. tableName: "sale_order",
  1076. },
  1077. // addListMap: [saleValue],
  1078. conditionMap: {},
  1079. commMap: {},
  1080. btnParametersMap: {},
  1081. };
  1082. let craftData = {
  1083. //工艺表新增数据
  1084. basicMap: {
  1085. tableName: "sale_craft",
  1086. },
  1087. // addListMap: [craftValue],
  1088. conditionMap: {},
  1089. commMap: {},
  1090. btnParametersMap: {},
  1091. };
  1092. this.productionTableData.forEach((item) => {
  1093. item.saleOrderNo = saleNo;
  1094. delete item.id;
  1095. });
  1096. let productData = {
  1097. //货品表新增数据
  1098. basicMap: {
  1099. tableName: "sale_products",
  1100. },
  1101. addListMap: [...this.productionTableData],
  1102. conditionMap: {},
  1103. commMap: {},
  1104. btnParametersMap: {},
  1105. };
  1106. if (this.isEdit) {
  1107. //修改
  1108. Object.keys(saleValue).map((k) => {
  1109. saleData.commMap[k] = saleValue[k];
  1110. });
  1111. Object.keys(craftValue).map((k) => {
  1112. craftData.commMap[k] = craftValue[k];
  1113. });
  1114. saleData.conditionMap.saleNo = saleValue.saleNo;
  1115. craftData.conditionMap.saleCraftNo = craftValue.saleCraftNo;
  1116. // for(let i = 0;i<this.)
  1117. let deletPayload = {
  1118. //删除货品数据的接口
  1119. basicMap: {
  1120. tableName: "sale_products",
  1121. },
  1122. conditionMap: {
  1123. saleProductNo: this.productIds,
  1124. },
  1125. };
  1126. let delRes = { code: 200 };
  1127. if (this.productIds.length) {
  1128. delRes = await delTableData(deletPayload); //删除旧数据
  1129. }
  1130. let updateSaleRes = await batchEdit(saleData);
  1131. let updateCraftRes = await batchEdit(craftData);
  1132. let addProductRes = { code: 200 };
  1133. if (productData.addListMap.length) {
  1134. addProductRes = await addTableData(productData);
  1135. }
  1136. console.log(delRes, updateSaleRes, updateCraftRes, addProductRes);
  1137. if (
  1138. delRes?.code === 200 &&
  1139. updateSaleRes?.code === 200 &&
  1140. updateCraftRes?.code === 200 &&
  1141. addProductRes?.code === 200
  1142. ) {
  1143. this.$message.success("修改成功");
  1144. this.open = false;
  1145. this.getList();
  1146. } else {
  1147. this.$message.error("修改失败");
  1148. }
  1149. } else {
  1150. //新增
  1151. saleData.addListMap = [saleValue];
  1152. craftData.addListMap = [craftValue];
  1153. let saleRes = await addTableData(saleData);
  1154. let craftRes = await addTableData(craftData);
  1155. let productRes = { code: 200 };
  1156. if (productData.addListMap.length) {
  1157. productRes = await addTableData(productData);
  1158. }
  1159. if (
  1160. saleRes.code === 200 &&
  1161. craftRes.code === 200 &&
  1162. productRes.code === 200
  1163. ) {
  1164. this.$message.success("添加成功");
  1165. this.open = false;
  1166. this.getList();
  1167. } else {
  1168. this.$message.error("添加失败");
  1169. }
  1170. }
  1171. // Object.keys(saleValue).map((k) => {
  1172. // saleData.commMap[k] = saleValue[k];
  1173. // });
  1174. }
  1175. });
  1176. },
  1177. // 审计 编辑回调
  1178. async handleEdit(index, row) {
  1179. console.log(row);
  1180. let { saleOrderSaleNo } = row;
  1181. try {
  1182. let payLoad = [
  1183. {
  1184. basicMap: {
  1185. tableName: "sale_order",
  1186. },
  1187. conditionMap: {
  1188. sale_no: [saleOrderSaleNo],
  1189. },
  1190. },
  1191. {
  1192. basicMap: {
  1193. tableName: "sale_products",
  1194. },
  1195. conditionMap: {
  1196. sale_order_no: [saleOrderSaleNo],
  1197. },
  1198. },
  1199. {
  1200. basicMap: {
  1201. tableName: "sale_craft",
  1202. },
  1203. conditionMap: {
  1204. sale_order_no: [saleOrderSaleNo],
  1205. },
  1206. },
  1207. ];
  1208. let res = await queryDropDownBoxData(payLoad);
  1209. if (res.code == 200) {
  1210. this.isEdit = true;
  1211. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1212. Object.assign(this.formData, {
  1213. ...sale_craft[0],
  1214. ...sale_order[0],
  1215. });
  1216. let { saleDate, saleOrderEstimatedTime } = sale_order[0];
  1217. saleDate && (this.formData.saleDate = new Date(saleDate));
  1218. saleOrderEstimatedTime &&
  1219. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1220. this.productionTableData = sale_products;
  1221. this.productIds = sale_products.map((item) => item.saleProductNo);
  1222. await this.getDropDownData();
  1223. this.title = "编辑审计单";
  1224. this.open = true;
  1225. }
  1226. } catch (error) {
  1227. console.log(error);
  1228. }
  1229. },
  1230. // 审计 批量删除回调
  1231. async batchDelete() {
  1232. if (!this.ids.length) return;
  1233. try {
  1234. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1235. confirmButtonText: "确定",
  1236. cancelButtonText: "取消",
  1237. type: "warning",
  1238. });
  1239. let orderPayload = {
  1240. basicMap: {
  1241. tableName: "sale_order",
  1242. },
  1243. conditionMap: {
  1244. saleNo: this.ids,
  1245. },
  1246. };
  1247. let productsPayload = {
  1248. basicMap: {
  1249. tableName: "sale_products",
  1250. },
  1251. conditionMap: {
  1252. saleOrderNo: this.ids,
  1253. },
  1254. };
  1255. let craftPayload = {
  1256. basicMap: {
  1257. tableName: "sale_craft",
  1258. },
  1259. conditionMap: {
  1260. saleOrderNo: this.ids,
  1261. },
  1262. };
  1263. let orderRes = await delTableData(orderPayload);
  1264. // let productRes = await delTableData(productsPayload);
  1265. // let craftRes = await delTableData(craftPayload);
  1266. if (orderRes.code == 200) {
  1267. this.$message.success("删除成功");
  1268. this.getList();
  1269. } else {
  1270. this.$message.error("删除失败");
  1271. throw Error("删除失败");
  1272. }
  1273. this.ids = [];
  1274. this.$refs.tableRef.clearSelection();
  1275. } catch (error) {
  1276. console.log(error);
  1277. }
  1278. },
  1279. // 计算金额
  1280. computedPrice(row) {
  1281. let { productNumber, productUnitPrice } = row;
  1282. row.productAmounts = Number(productNumber) * Number(productUnitPrice);
  1283. },
  1284. isUpperCase(char) {
  1285. return char === char.toUpperCase();
  1286. },
  1287. // 下划线命名转驼峰命名
  1288. toUnderScoreCase(str) {
  1289. if (str === null) {
  1290. return null;
  1291. }
  1292. let sb = "";
  1293. // 前置字符是否大写
  1294. let preCharIsUpperCase = true;
  1295. // 当前字符是否大写
  1296. let curreCharIsUpperCase = true;
  1297. // 下一字符是否大写
  1298. let nexteCharIsUpperCase = true;
  1299. for (let i = 0; i < str.length; i++) {
  1300. let c = str.charAt(i);
  1301. if (i > 0) {
  1302. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  1303. } else {
  1304. preCharIsUpperCase = false;
  1305. }
  1306. curreCharIsUpperCase = isUpperCase(c);
  1307. if (i < str.length - 1) {
  1308. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  1309. }
  1310. if (
  1311. preCharIsUpperCase &&
  1312. curreCharIsUpperCase &&
  1313. !nexteCharIsUpperCase
  1314. ) {
  1315. sb += SEPARATOR;
  1316. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  1317. sb += SEPARATOR;
  1318. }
  1319. sb += c.toLowerCase();
  1320. }
  1321. return sb;
  1322. },
  1323. // 处理列表信息
  1324. columnsHandler(columns) {
  1325. let resArr = [];
  1326. columns.forEach((item) => {
  1327. for (const key in item) {
  1328. let tempObj = {};
  1329. tempObj.key = camelCase(key);
  1330. tempObj.value = item[key];
  1331. resArr.push(tempObj);
  1332. }
  1333. });
  1334. return resArr;
  1335. },
  1336. // 取消按钮
  1337. cancel() {
  1338. this.open = false;
  1339. // this.reset();
  1340. },
  1341. // k-form-build 取消按钮
  1342. kCancel() {
  1343. this.kOpen = false;
  1344. // this.reset();
  1345. },
  1346. // 分页查询
  1347. pageList(row) {
  1348. // 调用子组件-》携带子组件参数请求后台
  1349. this.$refs.mychild.pageList(
  1350. row == undefined
  1351. ? {
  1352. limit: this.queryParams.pageSize,
  1353. page: this.queryParams.pageNum,
  1354. }
  1355. : row
  1356. );
  1357. },
  1358. // 多选框选中数据
  1359. handleSelectionChange(selection) {
  1360. // this.ids = selection.map(
  1361. // (item) =>
  1362. // item[
  1363. // camelCase(
  1364. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  1365. // )
  1366. // ]
  1367. // );
  1368. this.ids = selection.map((item) => item.saleOrderSaleNo);
  1369. this.single = selection.length != 1;
  1370. this.multiple = !selection.length;
  1371. },
  1372. // 更多操作触发
  1373. handleCommand(command, row) {
  1374. switch (command) {
  1375. case "handleResetPwd":
  1376. this.handleResetPwd(row);
  1377. break;
  1378. case "handleAuthRole":
  1379. this.handleAuthRole(row);
  1380. break;
  1381. default:
  1382. break;
  1383. }
  1384. },
  1385. /** 新增按钮操作 */
  1386. handleAdd(row) {
  1387. // this.reset();
  1388. this.defaultValue = {};
  1389. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1390. if (!data || !data.dfVueTemplate) {
  1391. this.jsonData = false;
  1392. this.$message.error("当前表格未绑定表单!");
  1393. return;
  1394. }
  1395. if (data.dfFormSql) {
  1396. let dynamicData = JSON.parse(data.dfFormSql);
  1397. Object.assign(this.dynamicData, dynamicData);
  1398. }
  1399. this.jsonData = JSON.parse(data.dfVueTemplate);
  1400. this.open = true;
  1401. this.title = "添加信息";
  1402. this.form.password = this.initPassword;
  1403. this.$nextTick(() => {
  1404. this.$refs.addFromRef.reset();
  1405. inputDisableComplete();
  1406. });
  1407. });
  1408. },
  1409. longestCommonSubstring(strs) {
  1410. if (!strs || strs.includes("")) return "";
  1411. let str1_Length = strs[0].length;
  1412. let str_Nums = strs.length;
  1413. let flag = 0;
  1414. for (let i = 0; i < str1_Length && flag == 0; i++) {
  1415. let char = strs[0][i];
  1416. for (var j = 1; j < str_Nums; j++) {
  1417. if (char !== strs[j][i] || i == strs[j].length) {
  1418. return strs[1].substring(0, i);
  1419. }
  1420. }
  1421. }
  1422. return strs[0];
  1423. },
  1424. // 绑定dialog对话框关闭
  1425. handleClose() {
  1426. this.btnDialogVisible = false;
  1427. },
  1428. getLastUppercaseWord(text) {
  1429. const pattern = /\b[A-Z][a-z]*\b/g;
  1430. const matches = [...text.matchAll(pattern)];
  1431. if (matches.length > 0) {
  1432. const lastMatch = matches[matches.length - 1][0];
  1433. return lastMatch;
  1434. } else {
  1435. return null;
  1436. }
  1437. },
  1438. /** 修改按钮操作 */
  1439. async handleUpdate(row, btnData) {
  1440. let nameTable = this.templateInfo.template.dtTableName;
  1441. this.rowobj = {};
  1442. let obj = {};
  1443. for (let key in row) {
  1444. let modifiedTable = key
  1445. .replace(/[A-Z]/g, (match) => `_${match}`)
  1446. .toLowerCase();
  1447. this.rowobj[modifiedTable] = row[key];
  1448. let str = modifiedTable.substring(nameTable.length + 1);
  1449. obj[str] = row[key];
  1450. }
  1451. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1452. // if (!data || !data.dfVueTemplate) {
  1453. // this.$message.error("当前表格未绑定表单!");
  1454. // return;
  1455. // }});
  1456. // 新的修改请求
  1457. try {
  1458. let payLoad = {
  1459. basicMap: {
  1460. btnType: this.currentBtnData.btnType,
  1461. btnKey: this.currentBtnData.btnKey,
  1462. visible: "false",
  1463. sqlKey: this.templateInfo.template.sqlKey,
  1464. tableName: this.tableName,
  1465. },
  1466. conditionMap: {},
  1467. };
  1468. let primary = camelCase(
  1469. this.tableName + "_" + this.templateInfo.template?.primaryKey
  1470. );
  1471. payLoad.conditionMap[this.templateInfo.template?.primaryKey] =
  1472. row[primary];
  1473. let res = await btnCommonApi(payLoad);
  1474. // 判断是否绑定dialog弹窗
  1475. if (!this.currentBtnData.btnTableFormGroupKey) {
  1476. if (!res.data || !res.data.template) {
  1477. this.$message.error("当前按钮未绑定表单!");
  1478. return;
  1479. }
  1480. res.data.template.dfFormSql &&
  1481. (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
  1482. this.addRealFieldName(res.data.result.resultMap);
  1483. let resultMap = res.data.result.resultMap;
  1484. Object.assign(this.defaultValue, resultMap);
  1485. this.jsonData = JSON.parse(res.data.template.dfVueTemplate);
  1486. this.kOpen = true;
  1487. this.title = "修改信息";
  1488. this.form.password = this.initPassword;
  1489. this.$nextTick(() => {
  1490. this.$refs.addFromRef.setData(res.data.result.resultMap);
  1491. });
  1492. } else {
  1493. this.subTableName = res.data.result.dragTables[1].dtTableName;
  1494. this.btnDialogVisible = true;
  1495. this.groupKey = this.currentBtnData.btnTableFormGroupKey;
  1496. this.$nextTick(() => {
  1497. let refChild = this.$refs.dialogRef;
  1498. refChild.getLists(this.groupKey);
  1499. });
  1500. let tablesubKey = res.data.result.dragTables[1].tableKey;
  1501. // 查询统计信息
  1502. getStatisticList({
  1503. queryMap: {
  1504. tableKey: tablesubKey,
  1505. },
  1506. }).then((res) => {
  1507. this.subCount = res.data;
  1508. });
  1509. let prmKey = this.templateInfo.template.primaryKey;
  1510. let pkey = prmKey.replace(/_([a-z])/g, (match, p1) =>
  1511. p1.toUpperCase()
  1512. );
  1513. let data = {
  1514. queryMap: {
  1515. tableKey: res.data.result.dragTables[2].tableKey,
  1516. },
  1517. };
  1518. let key =
  1519. "#{" +
  1520. this.templateInfo.template.dtTableName +
  1521. "." +
  1522. this.templateInfo.template.primaryKey;
  1523. data.queryMap[key] =
  1524. "'" + obj[this.templateInfo.template.primaryKey] + "'";
  1525. getStatisticList(data).then((res) => {
  1526. this.tableCount = res.data;
  1527. });
  1528. }
  1529. // let fieldList = Object.keys(resultMap);
  1530. // let tableName = this.longestCommonSubstring(fieldList);
  1531. // fieldList.forEach((field) => {
  1532. // let realField = field.replace(tableName, "");
  1533. // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1534. // resultMap[realField] = resultMap[field];
  1535. // });
  1536. } catch (error) {
  1537. this.$message.error("网络异常,请稍后再试");
  1538. console.log(error);
  1539. }
  1540. return;
  1541. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1542. // if (!data || !data.dfVueTemplate) {
  1543. // this.$message.error("当前表格未绑定表单!");
  1544. // return;
  1545. // }
  1546. // // let fieldList = Object.keys(row);
  1547. // // let tableName = this.longestCommonSubstring(fieldList);
  1548. // // fieldList.forEach((field) => {
  1549. // // let realField = field.replace(tableName, "");
  1550. // // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1551. // // row[realField] = row[field];
  1552. // // });
  1553. // this.addRealFieldName(row);
  1554. // Object.assign(this.defaultValue, row);
  1555. // this.jsonData = JSON.parse(data.dfVueTemplate);
  1556. // this.open = true;
  1557. // this.title = "修改信息";
  1558. // this.form.password = this.initPassword;
  1559. // this.$nextTick(() => {
  1560. // this.$refs.addFromRef.setData(row);
  1561. // });
  1562. // });
  1563. // return;
  1564. this.reset();
  1565. const userId = row.userId || this.ids;
  1566. getUser(userId).then((response) => {
  1567. this.form = response.data;
  1568. this.postOptions = response.posts;
  1569. this.roleOptions = response.roles;
  1570. this.$set(this.form, "postIds", response.postIds);
  1571. this.$set(this.form, "roleIds", response.roleIds);
  1572. this.open = true;
  1573. this.title = "修改当前信息";
  1574. this.form.password = "";
  1575. });
  1576. },
  1577. // 添加真正的字段名
  1578. addRealFieldName(row) {
  1579. let fieldList = Object.keys(row);
  1580. // let tableName = this.longestCommonSubstring(fieldList);
  1581. let tableName = camelCase(this.tableName);
  1582. fieldList.forEach((field) => {
  1583. let realField = field.replace(tableName, "");
  1584. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1585. row[realField] = row[field];
  1586. });
  1587. },
  1588. /** 提交按钮 */
  1589. submitForm: function () {
  1590. this.$refs["form"].validate((valid) => {
  1591. if (valid) {
  1592. if (this.form.userId != undefined) {
  1593. updateUser(this.form).then((response) => {
  1594. this.$modal.msgSuccess("修改成功");
  1595. this.open = false;
  1596. this.getList();
  1597. });
  1598. } else {
  1599. addUser(this.form).then((response) => {
  1600. this.$modal.msgSuccess("新增成功");
  1601. this.open = false;
  1602. this.getList();
  1603. });
  1604. }
  1605. }
  1606. });
  1607. },
  1608. /** 删除按钮操作
  1609. *
  1610. * 删除提示信息语句(标识)
  1611. * */
  1612. handleDelete(row, btnData) {
  1613. let delIds = this.ids;
  1614. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1615. // let realyKey=
  1616. this.addRealFieldName(row);
  1617. if (row[primary] != undefined && row[primary] != null) {
  1618. delIds = [];
  1619. delIds.push(row[primary]);
  1620. }
  1621. let data = {
  1622. basicMap: {
  1623. btnType: btnData.btnType,
  1624. btnKey: btnData.btnKey,
  1625. tableName: this.tableName,
  1626. },
  1627. conditionMap: {
  1628. // id: delIds,
  1629. },
  1630. btnParametersMap: {},
  1631. };
  1632. if (this.currentBtnData.btnParams) {
  1633. let btnParams =
  1634. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  1635. let conditionData =
  1636. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1637. conditionData.forEach((item) => {
  1638. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  1639. ? item.fieldValue
  1640. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1641. });
  1642. btnParams.forEach((item) => {
  1643. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  1644. ? item.fieldValue
  1645. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1646. });
  1647. }
  1648. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1649. this.$modal
  1650. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1651. .then(function () {
  1652. // return delTableData(data);
  1653. return btnCommonApi(data);
  1654. })
  1655. .then(() => {
  1656. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1657. this.$refs.mychild.pageList();
  1658. this.$modal.msgSuccess("删除成功");
  1659. })
  1660. .catch(() => {});
  1661. },
  1662. // 批量删除接口
  1663. handleBatchDelete() {
  1664. let delIds = this.ids;
  1665. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1666. // if (row && row[primary] != undefined && row[primary] != null) {
  1667. // delIds = [];
  1668. // delIds.push(row[primary]);
  1669. // }
  1670. let data = {
  1671. basicMap: {
  1672. tableName: this.tableName,
  1673. },
  1674. conditionMap: {
  1675. // id: delIds,
  1676. },
  1677. };
  1678. // if (this.currentBtnData.btnParams) {
  1679. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  1680. // btnParams.forEach((item) => {
  1681. // data.btnParametersMap[
  1682. // this.formatField(item.fieldName, camelCase(this.tableName))
  1683. // ] = item.fieldValue
  1684. // ? item.fieldValue
  1685. // : this.currentRow[item.fieldName];
  1686. // });
  1687. // }
  1688. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1689. this.$modal
  1690. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1691. .then(function () {
  1692. return delTableData(data);
  1693. // return btnCommonApi(data);
  1694. })
  1695. .then(() => {
  1696. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1697. this.$refs.mychild.pageList();
  1698. this.$modal.msgSuccess("删除成功");
  1699. })
  1700. .catch(() => {});
  1701. },
  1702. /** 导出按钮操作 */
  1703. handleExport() {
  1704. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1705. let realyKey = camelCase(this.tableName + "_" + primary);
  1706. if (this.ids.length > 0) {
  1707. this.queryParams["execlMap"] = [];
  1708. this.ids.forEach((item) => {
  1709. this.queryParams.execlMap.push(
  1710. this.tableList.find((ttem) => {
  1711. return ttem[realyKey] === item;
  1712. })
  1713. );
  1714. });
  1715. } else {
  1716. this.$message.warning("请至少勾选一条导出数据");
  1717. return;
  1718. }
  1719. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  1720. this.download(
  1721. process.env.VUE_APP_BASE_API3 + "common/export",
  1722. {
  1723. ...this.queryParams,
  1724. },
  1725. `文件名称_${new Date().getTime()}.xlsx`
  1726. );
  1727. },
  1728. /** 导入按钮操作 */
  1729. handleImport() {
  1730. this.upload.title = "当前导入";
  1731. this.upload.open = true;
  1732. },
  1733. /** 下载模板操作 */
  1734. importTemplate() {
  1735. this.download(
  1736. process.env.VUE_APP_BASE_API3 +
  1737. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  1738. {},
  1739. `下载模版名称${new Date().getTime()}.xlsx`
  1740. );
  1741. },
  1742. // 文件上传中处理
  1743. handleFileUploadProgress(event, file, fileList) {
  1744. this.upload.isUploading = true;
  1745. },
  1746. // 文件上传成功处理
  1747. handleFileSuccess(response, file, fileList) {
  1748. this.upload.open = false;
  1749. this.upload.isUploading = false;
  1750. this.$refs.upload.clearFiles();
  1751. this.$alert(
  1752. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  1753. response.msg +
  1754. "</div>",
  1755. "导入结果",
  1756. { dangerouslyUseHTMLString: true }
  1757. );
  1758. this.$refs.mychild.pageList({
  1759. limit: this.queryParams.pageSize,
  1760. page: this.queryParams.pageNum,
  1761. });
  1762. },
  1763. //重点在这里
  1764. handleChange(file, fileList) {
  1765. file.name = this.tableName + "." + file.name.split(".")[1];
  1766. fileList.forEach((item) => {
  1767. item.name = this.tableName + "." + file.name.split(".")[1];
  1768. });
  1769. let newFile = new File(
  1770. [file],
  1771. this.tableName + "." + file.name.split(".")[1]
  1772. ); //创建出来也是不可编辑的file对象
  1773. },
  1774. // 提交上传文件
  1775. submitFileForm() {
  1776. this.$refs.upload.submit();
  1777. },
  1778. // 弹窗新增的数
  1779. addListHandler(val) {
  1780. this.addLists.push(...val);
  1781. },
  1782. // 绑定弹窗Dialog确定按钮
  1783. btnComfirm() {
  1784. // let data = {
  1785. // addListMap:[],
  1786. // basicMap:{
  1787. // btnType: 10,
  1788. // tableName: this.subTableName,
  1789. // visible: true,
  1790. // },
  1791. // commMap: {},
  1792. // conditionMap: {},
  1793. // }
  1794. // // data.addListMap =
  1795. // btnCommonApi(data).then(res => {
  1796. // console.log('弹窗确定', res);
  1797. // })
  1798. },
  1799. // 去掉表名 开头字母小写
  1800. formatField(field = "", tableName) {
  1801. let temp = field.replace(tableName, "");
  1802. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  1803. },
  1804. //提交编辑结果按钮回调
  1805. async editConfirmHandler() {
  1806. if (this.$refs.addFromRef) {
  1807. this.$refs.addFromRef
  1808. .getData()
  1809. .then(async (values) => {
  1810. let data = {
  1811. basicMap: {
  1812. tableName: this.tableName,
  1813. // btnKey: btnData.btnKey,
  1814. btnKey: this.currentBtnData.btnKey,
  1815. },
  1816. addListMap: [values],
  1817. conditionMap: {},
  1818. commMap: {},
  1819. btnParametersMap: {},
  1820. };
  1821. if (this.currentBtnData.btnParams) {
  1822. let btnParams =
  1823. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  1824. [];
  1825. let conditionData =
  1826. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1827. // let
  1828. btnParams.forEach((item) => {
  1829. data.btnParametersMap[item.fieldName.split(".")[1]] =
  1830. item.fieldValue
  1831. ? item.fieldValue
  1832. : this.currentRow[
  1833. camelCase(item.fieldName.replace(".", "_"))
  1834. ];
  1835. });
  1836. conditionData.forEach((item) => {
  1837. data.conditionMap[item.fieldName.split(".")[1]] =
  1838. item.fieldValue
  1839. ? item.fieldValue
  1840. : this.currentRow[
  1841. camelCase(item.fieldName.replace(".", "_"))
  1842. ];
  1843. });
  1844. }
  1845. if (Object.keys(this.defaultValue).length) {
  1846. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  1847. // this.defaultValue[this.templateInfo.template?.primaryKey];
  1848. Object.keys(values).map((k) => {
  1849. data.commMap[k] = values[k];
  1850. });
  1851. data.basicMap.btnType = this.currentBtnData.btnType;
  1852. data.basicMap.visible = true;
  1853. } else {
  1854. data.basicMap.btnType = "INSERT";
  1855. data.basicMap.visible = true;
  1856. }
  1857. try {
  1858. let res = await btnCommonApi(data);
  1859. if (res.code == 200) {
  1860. this.$message.success("操作成功");
  1861. } else {
  1862. this.$message.error("网络异常,请稍后再试");
  1863. }
  1864. } catch (error) {
  1865. console.log(error);
  1866. this.$message.error("网络异常,请稍后再试");
  1867. }
  1868. this.getList();
  1869. this.defaultValue = {};
  1870. this.kOpen = false;
  1871. })
  1872. .catch((res) => {
  1873. console.log(res);
  1874. this.$modal.msgError("表单校验失败,请规范填写数据");
  1875. });
  1876. } else {
  1877. // 没有绑定表单
  1878. let data = {
  1879. basicMap: {
  1880. tableName: this.tableName,
  1881. // btnKey: btnData.btnKey,
  1882. btnKey: this.currentBtnData.btnKey,
  1883. btnType: this.currentBtnData.btnType,
  1884. visible: true,
  1885. },
  1886. addListMap: [],
  1887. conditionMap: {},
  1888. commMap: {},
  1889. btnParametersMap: {},
  1890. };
  1891. if (this.currentBtnData.btnParams) {
  1892. let btnParams =
  1893. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  1894. let conditionData =
  1895. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1896. conditionData.forEach((item) => {
  1897. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  1898. ? item.fieldValue
  1899. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1900. });
  1901. btnParams.forEach((item) => {
  1902. data.btnParametersMap[item.fieldName.split(".")[1]] =
  1903. item.fieldValue
  1904. ? item.fieldValue
  1905. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1906. });
  1907. }
  1908. // data.basicMap.btnType = this.currentBtnData.btnType;
  1909. // data.basicMap.visible = true;
  1910. try {
  1911. let res = await btnCommonApi(data);
  1912. if (res.code == 200) {
  1913. this.$message.success("操作成功");
  1914. } else {
  1915. this.$message.error("网络异常,请稍后再试");
  1916. }
  1917. } catch (error) {
  1918. console.log(error);
  1919. this.$message.error("网络异常,请稍后再试");
  1920. }
  1921. this.getList();
  1922. this.defaultValue = {};
  1923. this.kOpen = false;
  1924. }
  1925. },
  1926. // 使用提交数据类型的按钮获取数据
  1927. tempSubBtn(getData) {
  1928. getData()
  1929. .then((values) => {
  1930. console.log("验证通过", values);
  1931. })
  1932. .catch(() => {
  1933. console.log("验证未通过,获取失败");
  1934. });
  1935. },
  1936. // 判断是否生效行样式
  1937. cellStyle({ row, column, rowIndex, columnIndex }) {
  1938. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  1939. if (!rowStyleList.length) return "";
  1940. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  1941. for (let i = 0; i < rowStyleList.length; i++) {
  1942. let item = rowStyleList[i];
  1943. let judgeRes = this.determineCondition(item.styleCondtion, row);
  1944. if (judgeRes) {
  1945. let styleCode = JSON.parse(item.styleCode);
  1946. return `background-color:${styleCode.rowBgColor};`;
  1947. }
  1948. }
  1949. },
  1950. // 获取生效条件组结果
  1951. determineCondition(conditionStr, row) {
  1952. let conditionList = JSON.parse(conditionStr);
  1953. if (!conditionList.length) return false;
  1954. return conditionList.every((item) => this.judgeOneCondition(item, row));
  1955. },
  1956. // 获取单个判断条件结果
  1957. judgeOneCondition(item, row) {
  1958. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  1959. switch (item.condition) {
  1960. case 1:
  1961. return row[fullField] > item.flagValue;
  1962. case 2:
  1963. return row[fullField] < item.flagValue;
  1964. case 3:
  1965. return row[fullField] == item.flagValue;
  1966. case 4:
  1967. return row[fullField] >= item.flagValue;
  1968. case 5:
  1969. return row[fullField] <= item.flagValue;
  1970. default:
  1971. return true; //默认为true
  1972. }
  1973. },
  1974. // 设置表格字段样式
  1975. async setFieldStyleData(tableList) {
  1976. console.log(JSON.parse(JSON.stringify(tableList)));
  1977. let fieldConditionList = this.styleList.filter(
  1978. (item) => item.styleType == 1 || item.styleType == 2
  1979. );
  1980. if (!fieldConditionList.length) return tableList;
  1981. let res = await this.setDictStyleData();
  1982. this.dictStyleObj = res.reduce((pre, item) => {
  1983. return {
  1984. ...pre,
  1985. ...item,
  1986. };
  1987. }, {});
  1988. // console.log("this.dictStyleObj", this.dictStyleObj);
  1989. tableList.forEach((row) => {
  1990. // if (!row.styleFieldObj) row.styleFieldObj = {};
  1991. for (let i = 0; i < fieldConditionList.length; i++) {
  1992. let item = fieldConditionList[i];
  1993. if (item.styleType == 1) {
  1994. //字段样式
  1995. let judgeRes = this.determineCondition(item.styleCondtion, row);
  1996. if (judgeRes) {
  1997. let styleCode = JSON.parse(item.styleCode);
  1998. if (!row.styleFieldObj) row.styleFieldObj = {};
  1999. row.styleFieldObj[item.styleField] = {
  2000. styleType: item.styleType,
  2001. fieldStyleType: styleCode.fieldStyleType,
  2002. fontColor: styleCode.fontColor,
  2003. isTagFullBg: styleCode.isTagFullBg,
  2004. tagType: styleCode.tagType,
  2005. };
  2006. // row.styleField = item.styleField; //样式生效字段
  2007. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  2008. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  2009. // row.fontColor = styleCode.fontColor;
  2010. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  2011. // row.tagType = styleCode.tagType; //string
  2012. }
  2013. } else {
  2014. //字典样式
  2015. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  2016. return dict.dictValue == row[item.styleField];
  2017. });
  2018. if (dicStyle) {
  2019. if (!row.styleFieldObj) row.styleFieldObj = {};
  2020. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  2021. row.styleFieldObj[item.styleField].styleType = 2;
  2022. }
  2023. }
  2024. }
  2025. });
  2026. return tableList;
  2027. },
  2028. //设置表格字典相关数据
  2029. setDictStyleData() {
  2030. let fieldConditionList = this.styleList.filter(
  2031. (item) => item.styleType == 2
  2032. );
  2033. if (!fieldConditionList.length) return;
  2034. let PromiseList = fieldConditionList.map((item) => {
  2035. return new Promise((resolve, reject) => {
  2036. let temp = {};
  2037. try {
  2038. listData({
  2039. isEnablePaging: false,
  2040. dictType: item.styleCondtion,
  2041. }).then((res) => {
  2042. temp[item.styleField] = res.rows;
  2043. resolve(temp);
  2044. });
  2045. } catch (error) {
  2046. reject(error);
  2047. }
  2048. });
  2049. });
  2050. return Promise.all(PromiseList);
  2051. },
  2052. // 内链页面跳转
  2053. routerHandler(btnData, type) {
  2054. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  2055. let tempArr = [];
  2056. if (commonFieldData) {
  2057. let queryArr = JSON.parse(commonFieldData);
  2058. tempArr = queryArr.map((item) => {
  2059. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  2060. let value = item.fieldValue
  2061. ? item.fieldValue
  2062. : this.currentRow[item.fieldName];
  2063. return key + "=" + value;
  2064. });
  2065. }
  2066. if (tempArr.length) {
  2067. url += "?" + tempArr.join("&");
  2068. }
  2069. // let link = btnData.btnParams;
  2070. if (type == "INNERLINK") {
  2071. this.$router.push(url);
  2072. } else {
  2073. window.open("http://" + url, "_blank");
  2074. }
  2075. },
  2076. // 操作列回调
  2077. excuteHandler(btnData, row) {
  2078. let { btnType, btnParams, btnFormType } = btnData;
  2079. this.currentBtnData = btnData;
  2080. this.currentRow = JSON.parse(JSON.stringify(row));
  2081. console.log("btnData", btnType, btnData, row);
  2082. // 无表单
  2083. if (btnFormType == "noNeed") {
  2084. this.noNeedHandler(btnData, row);
  2085. return;
  2086. }
  2087. switch (btnType) {
  2088. case "INNERLINK":
  2089. this.routerHandler(btnData, btnType);
  2090. break;
  2091. case "OUTLINK":
  2092. this.routerHandler(btnData, btnType);
  2093. break;
  2094. case "UPDATE":
  2095. this.handleUpdate(row, btnData);
  2096. break;
  2097. case "EXECUTE":
  2098. this.handleUpdate(row, btnData);
  2099. break;
  2100. case "INITIATED":
  2101. this.handleUpdate(row, btnData);
  2102. break;
  2103. case "DELETE":
  2104. this.handleDelete(row, btnData);
  2105. break;
  2106. default:
  2107. break;
  2108. }
  2109. },
  2110. noNeedHandler(btnData, row) {
  2111. this.$modal
  2112. .confirm("是否确认执行该操作?")
  2113. .then(async () => {
  2114. // 获取默认参数
  2115. let data = {
  2116. basicMap: {
  2117. tableName: this.tableName,
  2118. // btnKey: btnData.btnKey,
  2119. btnKey: this.currentBtnData.btnKey,
  2120. },
  2121. conditionMap: {},
  2122. commMap: {},
  2123. btnParametersMap: {},
  2124. };
  2125. console.log(this.currentBtnData, this.currentRow);
  2126. if (this.currentBtnData.btnParams) {
  2127. let conditionData =
  2128. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2129. // let
  2130. let commonData =
  2131. JSON.parse(this.currentBtnData.btnParams).commonFieldData || [];
  2132. conditionData.forEach((item) => {
  2133. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2134. ? item.fieldValue
  2135. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2136. });
  2137. commonData.forEach((item) => {
  2138. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2139. item.fieldValue
  2140. ? item.fieldValue
  2141. : this.currentRow[
  2142. camelCase(item.fieldName.replace(".", "_"))
  2143. ];
  2144. });
  2145. }
  2146. data.basicMap.btnType = this.currentBtnData.btnType;
  2147. data.basicMap.visible = true;
  2148. try {
  2149. let res = await btnCommonApi(data);
  2150. if (res.code == 200) {
  2151. this.$message.success(res.msg);
  2152. } else {
  2153. this.$message.error("网络异常,请稍后再试");
  2154. }
  2155. } catch (error) {
  2156. console.log(error);
  2157. this.$message.error("网络异常,请稍后再试");
  2158. }
  2159. })
  2160. .then(() => {
  2161. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2162. this.$refs.mychild.pageList();
  2163. // this.$modal.msgSuccess("操作成功");
  2164. })
  2165. .catch(() => {});
  2166. },
  2167. // k-form-build表单变化回调
  2168. formChangeHandler(value, label) {
  2169. // console.log(value, label);
  2170. },
  2171. },
  2172. };
  2173. </script>
  2174. <style scoped lang="scss">
  2175. ::v-deep .el-dialog:not(.is-fullscreen) {
  2176. min-width: 610px !important;
  2177. }
  2178. </style>