approve.vue 94 KB

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