approve.vue 78 KB

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