c0c00479d80080c07b990baac364cc8464004a2f.svn-base 126 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736
  1. <template>
  2. <div ref="appContainer" class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <div class="recipeTemplate">
  6. <p>配方模板表</p>
  7. </div>
  8. <div class="search">
  9. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  10. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  11. </el-select>
  12. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  13. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  14. </el-select>
  15. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  16. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  17. </el-select>
  18. <div ref="selectInput" class="filter-item selectInput">
  19. <el-input v-model="table.getdataListParm.parammaps.all" type="text" placeholder="请点击选择搜索条件" class="Input" />
  20. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  21. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  22. <ul v-if="arrowUp" class="selectUl">
  23. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" clearable style="width: 245px;" /></li>
  24. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" clearable style="width: 245px;" /></li>
  25. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" clearable style="width: 245px;" /></li>
  26. <li>
  27. <div style="float: right;">
  28. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  29. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  30. </div>
  31. </li>
  32. </ul>
  33. </div>
  34. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  35. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  36. </div>
  37. <div class="operation">
  38. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  39. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  40. <el-button v-if="isRoleEdit" class="copy" icon="el-icon-copy-document" @click="handleCopy">复制</el-button>
  41. <el-upload style="float: right;margin-right: 15px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  42. <el-button v-if="isRoleEdit" class="export" icon="el-icon-download" style="float: right;">导入</el-button>
  43. </el-upload>
  44. <el-dropdown style="float: right;">
  45. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  46. <el-dropdown-menu slot="dropdown">
  47. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  48. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. <el-button class="export" style="float: right;" @click="handleRecipeRecord">配方记录</el-button>
  52. </div>
  53. <div ref="table" class="table">
  54. <el-table
  55. :key="table.tableKey"
  56. v-loading="table.listLoading"
  57. element-loading-text="给我一点时间"
  58. :data="table.list"
  59. border
  60. fit
  61. highlight-current-row
  62. style="width: 98%;"
  63. :row-style="rowStyle"
  64. :cell-style="cellStyle"
  65. class="elTable table-fixed"
  66. :height="myheight"
  67. @row-click="tableRowClick"
  68. @selection-change="handleSelectionChange"
  69. >
  70. <el-table-column type="selection" align="center" width="50" />
  71. <el-table-column label="序号" align="center" type="index" width="50px" />
  72. <el-table-column label="配方名称" min-width="90px" align="center">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  75. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="配方编码" min-width="90px" align="center">
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.NoEdit">{{ scope.row.tcode }}</span>
  81. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tcode" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="配方颜色" min-width="70px" align="center">
  85. <template slot-scope="scope">
  86. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="scope.row.NoEdit" />
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="牲畜类别" min-width="130px" align="center">
  90. <template slot-scope="scope">
  91. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  92. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  93. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  94. </el-select>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="配方类型" min-width="130px" align="center">
  98. <template slot-scope="scope">
  99. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  100. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  101. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  102. </el-select>
  103. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  104. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  105. </el-select>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="来源" min-width="90px" align="center">
  109. <template slot-scope="scope">
  110. <span>{{ scope.row.source }}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="备注" min-width="90px" align="center">
  114. <template slot-scope="scope">
  115. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  116. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="版本号" min-width="90px" align="center">
  120. <template slot-scope="scope">
  121. <span>{{ scope.row.version }}</span>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="是否启用" min-width="90px" align="center">
  125. <template slot-scope="scope">
  126. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
  130. <template slot-scope="{row}">
  131. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData(row)" />
  132. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  133. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  134. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  135. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  136. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  137. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData(row)" />
  138. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  139. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel(row)" />
  140. <span v-if="row.NoEdit && isRoleEdit && ispastureuse ==0" icon="el-icon-data-line" class="centerSpan">|</span>
  141. <el-button v-if="row.NoEdit && isRoleEdit && ispastureuse==0" icon="el-icon-data-line" class="miniSuccess" @click="handleFormulationEvaluation(row)" />
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. </div>
  146. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;margin-bottom: 10px;font-size: 14px;">共{{ table.total }}条</span>
  147. </div>
  148. <!-- 配方详情表 -->
  149. <div v-if="isDetail" ref="detail" class="detail">
  150. <div class="recipeTemplate">
  151. <p>配方详情表</p>
  152. </div>
  153. <div class="operation">
  154. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-plus" class="success" @click="handleCreate2">新增</el-button>
  155. <el-button v-if="isRoleEdit" style="float: left;" icon="el-icon-delete" class="danger" @click="handleDelete2">删除</el-button>
  156. <el-button v-if="isRoleEdit" style="float: left;" class="success" icon="el-icon-takeaway-box" @click="handleSyntheticPremix">合成预混料</el-button>
  157. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" style="float: left;" class="success" @click="handleChangeOrder">更改顺序</el-button>
  158. <div v-else style="float: left;margin-left: 10px;">
  159. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  160. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  161. </div>
  162. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  163. <el-input v-model="table2.getdataListParm.parammaps.all" type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  164. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  165. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  166. <ul v-if="arrowUp2" class="selectUl">
  167. <li>
  168. <a style="width: 130px;">饲料名称</a>
  169. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:190px;">
  170. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  171. </el-select>
  172. </li>
  173. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 190px;" /></li>
  174. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 190px;" /></li>
  175. <li>
  176. <a style="width: 130px;">搅拌延时</a>
  177. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:190px;" clearable>
  178. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  179. </el-select>
  180. </li>
  181. <li>
  182. <a style="width: 130px;">是否锁定牛头数比例</a>
  183. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:190px;" clearable>
  184. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  185. </el-select>
  186. </li>
  187. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 190px;" /></li>
  188. <li>
  189. <div style="float: right;">
  190. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  191. <el-button class="miniPrimary" @click="handleSearch2">搜索</el-button>
  192. </div>
  193. </li>
  194. </ul>
  195. </div>
  196. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  197. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  198. <el-button class="hide" @click="handleCloseTable2">隐藏</el-button>
  199. </div>
  200. <div class="table2" style="height: 250px;overflow-y: auto;">
  201. <el-table
  202. id="table2"
  203. ref="table2"
  204. :key="table2.tableKey"
  205. v-loading="table2.listLoading"
  206. element-loading-text="给我一点时间"
  207. :data="table2.list"
  208. border
  209. fit
  210. highlight-current-row
  211. style="width: 98%;"
  212. :row-style="rowStyle"
  213. :cell-style="cellStyle"
  214. class="elTable"
  215. row-key="id"
  216. show-summary
  217. :summary-method="getSummaries"
  218. @selection-change="handleSelectionChange2"
  219. >
  220. <el-table-column type="selection" width="50" />
  221. <el-table-column label="序号" align="center" type="index" width="50px" />
  222. <el-table-column label="饲料组" min-width="120px" align="center">
  223. <template slot-scope="scope">
  224. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  225. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  226. </template>
  227. </el-table-column>
  228. <el-table-column label="饲料名称" min-width="120px" align="center">
  229. <template slot-scope="scope">
  230. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  231. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  232. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  233. </el-select>
  234. </template>
  235. </el-table-column>
  236. <el-table-column label="重量(KG)" prop="fweight" width="120px" align="center">
  237. <template slot-scope="scope">
  238. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  239. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  240. </template>
  241. </el-table-column>
  242. <el-table-column label="搅拌延时(min)" min-width="80px" align="center">
  243. <template slot-scope="scope">
  244. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  245. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  246. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  247. </el-select>
  248. </template>
  249. </el-table-column>
  250. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="80px" align="center">
  251. <template slot-scope="scope">
  252. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  253. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  254. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  255. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  256. </el-select>
  257. </template>
  258. </el-table-column>
  259. <el-table-column label="顺序" min-width="70px" align="center">
  260. <template slot-scope="scope">
  261. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  262. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  263. </template>
  264. </el-table-column>
  265. <el-table-column label="操作" align="center" width="120" class-name="small-padding fixed-width" fixed="right">
  266. <template slot-scope="{row}">
  267. <el-button v-if="row.isCreate && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="createData2(row)" />
  268. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  269. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  270. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  271. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  272. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  273. <el-button v-if="row.isUpdateSave && isRoleEdit" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="updateData2(row)" />
  274. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  275. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" icon="el-icon-close" @click="updateCancel2(row)" />
  276. <span v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" class="centerSpan">|</span>
  277. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false && isRoleEdit" icon="el-icon-connection" class="miniSuccess" @click="handleSplitPremix(row)" />
  278. </template>
  279. </el-table-column>
  280. </el-table>
  281. </div>
  282. </div>
  283. <!-- 配方模板表 -->
  284. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  285. <div class="dialogMinHeight" style="overflow-y: auto;margin-bottom: 0px;overflow-x: hidden;">
  286. <div ref="templateDialog" class="templateDialog">
  287. <div class="recipeTemplate">
  288. <p>配方模板表</p>
  289. </div>
  290. <div class="operation">
  291. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  292. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  293. </div>
  294. <div class="search">
  295. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  296. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  297. </el-select>
  298. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  299. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  300. </el-select>
  301. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  302. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  303. </el-select>
  304. <div ref="selectInput" class="filter-item selectInput">
  305. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  306. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  307. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  308. <ul v-if="arrowUp" class="selectUl">
  309. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  310. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  311. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  312. <li>
  313. <div style="float: right;">
  314. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  315. <el-button class="miniPrimary" @click="handleDialogSearch">搜索</el-button>
  316. </div>
  317. </li>
  318. </ul>
  319. </div>
  320. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  321. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  322. </div>
  323. <div class="table">
  324. <el-table
  325. :key="template.table.tableKey"
  326. v-loading="template.table.listLoading"
  327. element-loading-text="给我一点时间"
  328. :data="template.table.list"
  329. border
  330. fit
  331. highlight-current-row
  332. style="width: 98%;"
  333. :row-style="rowStyle"
  334. :height="myheight2"
  335. :cell-style="cellStyle"
  336. class="elTable table-fixed"
  337. @row-click="tableRowClickDialog"
  338. >
  339. <el-table-column v-if="template.dialogStatus == 'RecipeRecord'" label="序号" align="center" type="index" width="50px" />
  340. <el-table-column v-else label="序号" align="center" type="index" width="50px">
  341. <template slot-scope="scope">
  342. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  343. </template>
  344. </el-table-column>
  345. <el-table-column label="配方名称" min-width="130px" align="center">
  346. <template slot-scope="scope">
  347. <span>{{ scope.row.tname }}</span>
  348. </template>
  349. </el-table-column>
  350. <el-table-column label="配方编码" min-width="90px" align="center">
  351. <template slot-scope="scope">
  352. <span v-if="scope.row.NoEdit">{{ scope.row.tcode }}</span>
  353. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tcode" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:98%;padding:10px 0;" />
  354. </template>
  355. </el-table-column>
  356. <el-table-column label="配方颜色" min-width="110px" align="center">
  357. <template slot-scope="scope">
  358. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" />
  359. </template>
  360. </el-table-column>
  361. <el-table-column label="牲畜类别" min-width="110px" align="center">
  362. <template slot-scope="scope">
  363. <span>{{ scope.row.ccname }}</span>
  364. </template>
  365. </el-table-column>
  366. <el-table-column label="配方类型" min-width="110px" align="center">
  367. <template slot-scope="scope">
  368. <span>{{ scope.row.fttype }}</span>
  369. </template>
  370. </el-table-column>
  371. <el-table-column label="来源" min-width="90px" align="center">
  372. <template slot-scope="scope">
  373. <span>{{ scope.row.source }}</span>
  374. </template>
  375. </el-table-column>
  376. <el-table-column label="备注" min-width="90px" align="center">
  377. <template slot-scope="scope">
  378. <span>{{ scope.row.remark }}</span>
  379. </template>
  380. </el-table-column>
  381. <el-table-column label="版本号" min-width="90px" align="center">
  382. <template slot-scope="scope">
  383. <span>{{ scope.row.version }}</span>
  384. </template>
  385. </el-table-column>
  386. <el-table-column label="版本时间" min-width="90px" align="center">
  387. <template slot-scope="scope">
  388. <span>{{ scope.row.versiontime }}</span>
  389. </template>
  390. </el-table-column>
  391. <el-table-column label="是否启用" min-width="90px" align="center">
  392. <template slot-scope="scope">
  393. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  394. </template>
  395. </el-table-column>
  396. </el-table>
  397. </div>
  398. </div>
  399. <div v-if="isDetailDialog" id="detailDialog2" ref="detailDialog2" class="detailDialog" style="margin-top: 30px;height: 200px;overflow-y: auto;overflow-x: hidden;">
  400. <div class="recipeTemplate">
  401. <p>配方详情表</p>
  402. </div>
  403. <div class="operation">
  404. <div ref="selectInput2" class="filter-item selectInput">
  405. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  406. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  407. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  408. <ul v-if="arrowUp2" class="selectUl">
  409. <li>
  410. <a style="width: 130px;">饲料名称</a>
  411. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  412. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  413. </el-select>
  414. </li>
  415. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  416. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  417. <li>
  418. <a style="width: 130px;">搅拌延时</a>
  419. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  420. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  421. </el-select>
  422. </li>
  423. <li>
  424. <a style="width: 130px;">是否锁定牛头数比例</a>
  425. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  426. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  427. </el-select>
  428. </li>
  429. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  430. <li>
  431. <div style="float: right;">
  432. <el-button class="downminCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  433. <el-button class="miniPrimary" @click="handleDialogSearch2">搜索</el-button>
  434. </div>
  435. </li>
  436. </ul>
  437. </div>
  438. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  439. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  440. <el-button class="hide" @click="handleDialogCloseTable2">隐藏</el-button>
  441. </div>
  442. <div class="table2">
  443. <el-table
  444. id="templateTable2"
  445. :key="template.table2.tableKey"
  446. v-loading="template.table2.listLoading"
  447. element-loading-text="给我一点时间"
  448. :data="template.table2.list"
  449. border
  450. fit
  451. highlight-current-row
  452. style="width: 98%;"
  453. :summary-method="getTemplateTable2Summaries"
  454. show-summary
  455. :row-style="rowStyle"
  456. :cell-style="cellStyle"
  457. class="elTable table-fixed"
  458. row-key="id"
  459. >
  460. <el-table-column label="饲料组" min-width="130px" align="center">
  461. <template slot-scope="scope">
  462. <span>{{ scope.row.feedgroup }}</span>
  463. </template>
  464. </el-table-column>
  465. <el-table-column label="饲料名称" min-width="130px" align="center">
  466. <template slot-scope="scope">
  467. <span>{{ scope.row.fname }}</span>
  468. </template>
  469. </el-table-column>
  470. <el-table-column label="重量(KG)" prop="fweight" min-width="200px" align="center">
  471. <template slot-scope="scope">
  472. <span>{{ scope.row.fweight }}</span>
  473. </template>
  474. </el-table-column>
  475. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  476. <template slot-scope="scope">
  477. <span>{{ scope.row.autosecondname }}</span>
  478. </template>
  479. </el-table-column>
  480. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  481. <template slot-scope="scope">
  482. <span v-if="scope.row.islockcount == '0'">否</span>
  483. <span v-if="scope.row.islockcount == '1'">是</span>
  484. </template>
  485. </el-table-column>
  486. <el-table-column label="顺序" min-width="130px" align="center">
  487. <template slot-scope="scope">
  488. <span>{{ scope.row.sort }}</span>
  489. </template>
  490. </el-table-column>
  491. </el-table>
  492. </div>
  493. </div>
  494. </div>
  495. <div slot="footer" class="dialog-footer">
  496. <el-button class="cancelClose cancelClose1" @click="template.dialogFormVisible = false; ">关闭</el-button>
  497. </div>
  498. </el-dialog>
  499. <!-- 合成预混料 -->
  500. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  501. <div class="detailDialog">
  502. <h2>饲料</h2>
  503. <div class="table1">
  504. <el-table
  505. :key="detail.tableKey"
  506. v-loading="detail.listLoading"
  507. element-loading-text="给我一点时间"
  508. :data="detail.list"
  509. fit
  510. highlight-current-row
  511. style="width: 100%;"
  512. :row-style="rowStyle"
  513. :cell-style="cellStyle"
  514. class="elTable table-fixed"
  515. show-summary
  516. >
  517. <el-table-column label="序号" align="center" type="index" width="50px" />
  518. <el-table-column label="饲料名称" min-width="130px" align="center">
  519. <template slot-scope="scope">
  520. <span>{{ scope.row.fname }}</span>
  521. </template>
  522. </el-table-column>
  523. <el-table-column prop="fweight" label="重量(KG)" />
  524. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  525. <template slot-scope="scope">
  526. <span>{{ scope.row.autosecond }}</span>
  527. </template>
  528. </el-table-column>
  529. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  530. <template slot-scope="scope">
  531. <span v-if="scope.row.islockcount == '0'">否</span>
  532. <span v-if="scope.row.islockcount == '1'">是</span>
  533. </template>
  534. </el-table-column>
  535. <el-table-column label="顺序" min-width="110px" align="center">
  536. <template slot-scope="scope">
  537. <span>{{ scope.row.sort }}</span>
  538. </template>
  539. </el-table-column>
  540. </el-table>
  541. </div>
  542. <h2>合成预混料</h2>
  543. <div class="table2" style="margin-bottom: 50px;">
  544. <el-table
  545. :key="detail.tableKey2"
  546. v-loading="detail.listLoading2"
  547. element-loading-text="给我一点时间"
  548. :data="detail.list2"
  549. border
  550. fit
  551. highlight-current-row
  552. style="width: 100%;"
  553. :row-style="rowStyle"
  554. :cell-style="cellStyle"
  555. class="elTable table-fixed"
  556. >
  557. <el-table-column label="配方名称" min-width="130px" align="center">
  558. <template slot-scope="scope">
  559. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  560. </template>
  561. </el-table-column>
  562. <el-table-column label="配方颜色" min-width="130px" align="center">
  563. <template slot-scope="scope">
  564. <el-color-picker v-model="scope.row.tcolor" size="mini" :predefine="predefineColors" style="vertical-align: middle;" :disabled="detail.disabled" />
  565. </template>
  566. </el-table-column>
  567. <el-table-column label="牲畜类别" min-width="130px" align="center">
  568. <template slot-scope="scope">
  569. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  570. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  571. </el-select>
  572. </template>
  573. </el-table-column>
  574. <el-table-column label="配方类型" min-width="110px" align="center">
  575. <template slot-scope="scope">
  576. <span>{{ scope.row.fttype }}</span>
  577. </template>
  578. </el-table-column>
  579. <el-table-column label="来源" min-width="110px" align="center">
  580. <template slot-scope="scope">
  581. <span>{{ scope.row.source }}</span>
  582. </template>
  583. </el-table-column>
  584. <el-table-column label="备注" min-width="130px" align="center">
  585. <template slot-scope="scope">
  586. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  587. </template>
  588. </el-table-column>
  589. <el-table-column label="是否启用" min-width="130px" align="center">
  590. <template slot-scope="scope">
  591. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  592. </template>
  593. </el-table-column>
  594. </el-table>
  595. </div>
  596. <div slot="footer" class="dialog-footer">
  597. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  598. <el-button class="save" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  599. </div>
  600. </div>
  601. </el-dialog>
  602. <!-- 历史记录 -->
  603. <el-dialog :title="textMap[historyRecord.dialogStatus]" :destroy-on-close="true" :visible.sync="historyRecord.dialogFormVisible" :close-on-click-modal="false" width="90%">
  604. <div class="historyRecord">
  605. <keep-alive>
  606. <component :is="historyRecord.myComponent" ref="historyRecord" />
  607. </keep-alive>
  608. </div>
  609. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  610. <el-button class="cancelClose1" @click="historyRecord.dialogFormVisible = false; ">关闭</el-button>
  611. </div>
  612. </el-dialog>
  613. </div>
  614. </template>
  615. <script>
  616. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, checkButtons, ExecDataByConfig, formatNum } from '@/api/common'
  617. import Sortable from 'sortablejs'
  618. import { MessageBox } from 'element-ui'
  619. import Cookies from 'js-cookie'
  620. import { json2excel } from '@/utils/index.js'
  621. import axios from 'axios'
  622. import { getToken } from '@/utils/auth'
  623. import { parseTime } from '@/utils/index.js'
  624. export default {
  625. name: 'RecipeTemplate',
  626. data() {
  627. return {
  628. predefineColors: [
  629. '#E57373', '#F06292', '#BA68C8', '#9575CD', '#7986CB', '#64B5F6', '#4FC3F7', '#4DD0E1', '#4DB6AC', '#81C784', '#AED581', '#DCE775', '#FFF176', '#FFD54F', '#FFB74D', '#FF8A65', '#A1887F', '#E0E0E0', '#90A4AE'
  630. ],
  631. isRoleEdit: [],
  632. myheight: '',
  633. requestParams: [
  634. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  635. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  636. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  637. ],
  638. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  639. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  640. livestockTypeList: [], // 牲畜类别
  641. formulaTypeList: [], // 配方类型
  642. feedNameList: [], // 饲料名称
  643. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  644. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  645. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  646. arrowDown: true,
  647. arrowUp: false,
  648. ispastureuse: Cookies.get('ispastureuse'),
  649. table: {
  650. getdataListParm: {
  651. name: 'getFTList',
  652. page: 1,
  653. offset: 1,
  654. pagecount: '',
  655. returntype: 'Map',
  656. parammaps: {
  657. pastureid: Cookies.get('pastureid'),
  658. tname: '',
  659. ccid: '',
  660. ccname: '',
  661. fttypeid: '',
  662. fttype: '',
  663. remark: '',
  664. enable: '',
  665. source: ''
  666. }
  667. },
  668. tableKey: 0,
  669. list: [],
  670. total: 0,
  671. listLoading: true,
  672. temp: {}
  673. },
  674. lockCount: {
  675. getdataListParm: {
  676. name: 'getSysoptEnable',
  677. page: 1,
  678. offset: 1,
  679. pagecount: 30,
  680. returntype: 'Map',
  681. parammaps: {
  682. pastureid: Cookies.get('pastureid'),
  683. inforname: 'isLockCount'
  684. }
  685. },
  686. isLockCount: false // 是否显示是否锁定牛头数比例
  687. },
  688. isDetail: false,
  689. arrowDown2: true,
  690. arrowUp2: false,
  691. table2: {
  692. getDryweightParm: {
  693. name: 'getFTdryweight',
  694. page: 1,
  695. offset: 1,
  696. pagecount: 10,
  697. returntype: 'Map',
  698. parammaps: {
  699. pastureid: '',
  700. ftid: ''
  701. }
  702. },
  703. dryweight: '',
  704. getdataListParm: {
  705. name: 'getFTdetailList',
  706. page: 1,
  707. offset: 1,
  708. pagecount: '',
  709. returntype: 'Map',
  710. parammaps: {
  711. pastureid: Cookies.get('pastureid'),
  712. fname: '',
  713. feedgroup: '',
  714. fweight: '',
  715. autosecondname: '',
  716. islockcount: '',
  717. sort: ''
  718. }
  719. },
  720. tableKey: 0,
  721. list: [],
  722. total: 0,
  723. listLoading: true,
  724. temp: {}
  725. },
  726. isDetailDialog: false,
  727. template: {
  728. dialogFormVisible: false,
  729. dialogStatus: '',
  730. table: {
  731. getdataListParm: {
  732. name: 'getFTListDate',
  733. page: 1,
  734. offset: 1,
  735. pagecount: '',
  736. returntype: 'Map',
  737. parammaps: {
  738. pastureid: Cookies.get('pastureid'),
  739. tname: '',
  740. ccid: '',
  741. ccname: '',
  742. fttype: '',
  743. remark: '',
  744. enable: '',
  745. date: '',
  746. source: ''
  747. }
  748. },
  749. tableKey: 0,
  750. total: 0,
  751. listLoading: true,
  752. list: []
  753. },
  754. table2: {
  755. getdataListParm: {
  756. name: 'getFTdetailListDate',
  757. page: 1,
  758. offset: 1,
  759. pagecount: 10,
  760. returntype: 'Map',
  761. parammaps: {
  762. pastureid: Cookies.get('pastureid'),
  763. fname: '',
  764. fweight: '',
  765. islockcount: '',
  766. sort: '',
  767. feedgroup: '',
  768. autosecondname: ''
  769. }
  770. },
  771. tableKey: 0,
  772. total: 0,
  773. listLoading: true,
  774. list: []
  775. },
  776. // 历史日期
  777. getdataDateParm: {
  778. name: 'getFTMaxDate',
  779. page: 1,
  780. offset: 1,
  781. pagecount: 10,
  782. returntype: 'Map',
  783. parammaps: {
  784. pastureid: Cookies.get('pastureid')
  785. }
  786. }
  787. },
  788. isOrder: true,
  789. detail: {
  790. dialogFormVisible: false,
  791. dialogStatus: '',
  792. tableKey: 0,
  793. total: 0,
  794. listLoading: true,
  795. list: [],
  796. tableKey2: 0,
  797. total2: 0,
  798. listLoading2: false,
  799. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  800. getdataListParm: {
  801. name: 'getFTDetailCompare',
  802. page: 1,
  803. offset: 1,
  804. pagecount: 10,
  805. returntype: 'Map',
  806. parammaps: {}
  807. },
  808. list3: [],
  809. disabled: false,
  810. getdataListParm2: {
  811. name: 'getFTCompare',
  812. page: 1,
  813. offset: 1,
  814. pagecount: 10,
  815. returntype: 'Map',
  816. parammaps: {}
  817. }
  818. },
  819. selectList: [],
  820. selectList2: [],
  821. textMap: {
  822. RecipeRecord: '配方记录',
  823. SyntheticPremix: '合成预混料',
  824. historyRecord: '历史记录',
  825. detail: '饲料详情'
  826. },
  827. requestParam: {},
  828. download: {
  829. getdataListParm: {
  830. name: 'getFTList',
  831. page: 1,
  832. offset: 1,
  833. pagecount: 0,
  834. returntype: 'Map',
  835. parammaps: {
  836. pastureid: Cookies.get('pastureid'),
  837. tname: '',
  838. ccid: '',
  839. ccname: '',
  840. fttypeid: '',
  841. fttype: '',
  842. remark: '',
  843. enable: ''
  844. }
  845. },
  846. list: []
  847. },
  848. historyRecord: {
  849. dialogStatus: '',
  850. dialogFormVisible: false
  851. },
  852. isokDisable: false,
  853. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  854. cellStyle: { padding: 0 + 'px' },
  855. dropState: false
  856. }
  857. },
  858. computed: {
  859. // 设置请求头
  860. headers() {
  861. return {
  862. token: getToken()
  863. }
  864. },
  865. uploadData() {
  866. return {
  867. name: 'checkfttype,checkbigcowclass,checkFeed,insertFTUpload,insertFTdetailUpload',
  868. importParams: '配方名称,牲畜类别,配方类型,备注,饲料组,饲料名称,重量(kg),搅拌延时(min),是否锁定牛头数比例',
  869. sheetname: 'Sheet1',
  870. // 登录牧场
  871. pastureid: Cookies.get('pastureid'),
  872. // 日期参数
  873. dateParams: '',
  874. // 必填参数
  875. requiredParams: '配方名称,牲畜类别,配方类型,饲料名称,重量(kg),搅拌延时(min),是否锁定牛头数比例',
  876. // 为数值的参数
  877. numParams: '重量(kg),搅拌延时(min)'
  878. }
  879. },
  880. // 设置上传地址
  881. uploadExcelUrl() {
  882. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  883. }
  884. },
  885. mounted() {
  886. document.addEventListener('click', (e) => {
  887. if (this.$refs.selectInput !== undefined) {
  888. if (!this.$refs.selectInput.contains(e.target)) {
  889. this.arrowDown = true
  890. this.arrowUp = false
  891. } else {
  892. this.arrowDown = false
  893. this.arrowUp = true
  894. }
  895. }
  896. if (this.$refs.selectInput2 !== undefined) {
  897. if (!this.$refs.selectInput2.contains(e.target)) {
  898. this.arrowDown2 = true
  899. this.arrowUp2 = false
  900. } else {
  901. this.arrowDown2 = false
  902. this.arrowUp2 = true
  903. }
  904. }
  905. })
  906. },
  907. created() {
  908. this.getList()
  909. this.getButtons()
  910. this.getDownList()
  911. this.getIsLockCount()
  912. },
  913. methods: {
  914. getButtons() {
  915. const Edit = 'FormulationEvaluation'
  916. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  917. this.isRoleEdit = isRoleEdit
  918. },
  919. getSummaries(param) {
  920. console.log(param, '====')
  921. const { columns, data } = param
  922. const sums = []
  923. columns.forEach((column, index) => {
  924. if (index === 0) {
  925. sums[index] = '合计'
  926. return
  927. }
  928. if (column.property !== undefined) {
  929. // 加了prop属性的el-table-column 才能找到column.property
  930. const values = data.map(item => Number(item[column.property]))
  931. if (!values.every(value => isNaN(value))) {
  932. sums[index] = values.reduce((prev, curr) => {
  933. const value = Number(curr)
  934. if (!isNaN(value)) {
  935. return prev + curr // 多行相加
  936. } else {
  937. return prev
  938. }
  939. }, 0)
  940. sums[index] = sums[index].toFixed(2) + '(干物质量:' + this.table2.dryweight + ')'
  941. } else {
  942. sums[index] = ''
  943. }
  944. }
  945. })
  946. // console.log(sums, 'sums[index]')
  947. return sums
  948. },
  949. getDryWeight() {
  950. GetDataByName(this.table2.getDryweightParm).then(response => {
  951. console.log('table数据', response.data.list)
  952. if (response.data.list[0].dryweight !== undefined) {
  953. this.table2.dryweight = response.data.list[0].dryweight
  954. } else {
  955. this.table2.dryweight = ''
  956. }
  957. })
  958. },
  959. getTemplateTable2Summaries(param) {
  960. console.log(param, '====')
  961. const { columns, data } = param
  962. const sums = []
  963. columns.forEach((column, index) => {
  964. if (index === 0) {
  965. sums[index] = '合计'
  966. return
  967. }
  968. const values = data.map(item => Number(item[column.property]))
  969. if (!values.every(value => isNaN(value))) {
  970. sums[index] = values.reduce((prev, curr) => {
  971. const value = Number(curr)
  972. if (!isNaN(value)) {
  973. return prev + curr
  974. } else {
  975. return prev
  976. }
  977. }, 0)
  978. // 后台待发
  979. sums[index] += '(干物质量:' + this.template.table2.getdataListParm.parammaps.dryweight + ')'
  980. } else {
  981. sums[index] = ''
  982. }
  983. })
  984. return sums
  985. },
  986. // handleHistory() {
  987. // MessageBox.confirm('是否确认生成历史?', {
  988. // confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  989. // }).then(() => {
  990. // this.requestParam.name = 'creatFTdate'
  991. // this.requestParam.parammaps = {}
  992. // this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  993. // PostDataByName(this.requestParam).then(response => {
  994. // console.log('生成历史保存发送参数', this.requestParam)
  995. // if (response.msg !== 'fail') {
  996. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  997. // } else {
  998. // this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  999. // }
  1000. // })
  1001. // })
  1002. // },
  1003. getDownList() {
  1004. GetDataByNames(this.requestParams).then(response => {
  1005. this.livestockTypeList = response.data.getDictByName.list
  1006. this.formulaTypeList = response.data.getDictByName2.list
  1007. this.feedNameList = response.data.getFeedAndPre.list
  1008. })
  1009. },
  1010. // -------------------模板-----------------------------
  1011. getList() {
  1012. this.table.listLoading = true
  1013. GetDataByName(this.table.getdataListParm).then(response => {
  1014. console.log('table数据', response.data.list)
  1015. if (response.data.list !== null) {
  1016. for (let i = 0; i < response.data.list.length; i++) {
  1017. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1018. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1019. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1020. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1021. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1022. }
  1023. this.table.list = response.data.list
  1024. this.table.pageNum = response.data.pageNum
  1025. this.table.pageSize = response.data.pageSize
  1026. this.table.total = response.data.total
  1027. } else {
  1028. this.table.list = []
  1029. this.isDetail = false
  1030. }
  1031. setTimeout(() => {
  1032. this.table.listLoading = false
  1033. }, 100)
  1034. })
  1035. },
  1036. getList3() {
  1037. this.table.listLoading = true
  1038. GetDataByName(this.table.getdataListParm).then(response => {
  1039. console.log('table数据', response.data.list)
  1040. if (response.data.list !== null) {
  1041. for (let i = 0; i < response.data.list.length; i++) {
  1042. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1043. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1044. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1045. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1046. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1047. }
  1048. this.table.list = response.data.list
  1049. this.table.pageNum = response.data.pageNum
  1050. this.table.pageSize = response.data.pageSize
  1051. this.table.total = response.data.total
  1052. } else {
  1053. this.table.list = []
  1054. this.isDetail = false
  1055. }
  1056. setTimeout(() => {
  1057. this.table.listLoading = false
  1058. }, 100)
  1059. })
  1060. },
  1061. handleSearch() {
  1062. console.log('点击了查询')
  1063. this.table.getdataListParm.offset = 1
  1064. this.getList()
  1065. this.table.getdataListParm.parammaps.all = ''
  1066. var obj = {}
  1067. obj.tname = this.table.getdataListParm.parammaps.tname
  1068. obj.remark = this.table.getdataListParm.parammaps.remark
  1069. obj.source = this.table.getdataListParm.parammaps.source
  1070. Object.getOwnPropertyNames(obj).forEach((key) => {
  1071. console.log(key, obj[key])
  1072. if (obj[key] !== '') {
  1073. this.table.getdataListParm.parammaps.all += obj[key] + '/'
  1074. }
  1075. })
  1076. if (this.table.getdataListParm.parammaps.all.charAt(this.table.getdataListParm.parammaps.all.length - 1) == '/') {
  1077. this.table.getdataListParm.parammaps.all = this.table.getdataListParm.parammaps.all.slice(0, this.table.getdataListParm.parammaps.all.length - 1)
  1078. }
  1079. this.arrowDown = true
  1080. this.arrowUp = false
  1081. },
  1082. handleRefresh() {
  1083. console.log('点击了重置')
  1084. this.table.getdataListParm.offset = 1
  1085. this.table.getdataListParm.parammaps.ccid = ''
  1086. this.table.getdataListParm.parammaps.ccname = ''
  1087. this.table.getdataListParm.parammaps.fttype = ''
  1088. this.table.getdataListParm.parammaps.tname = ''
  1089. this.table.getdataListParm.parammaps.remark = ''
  1090. this.table.getdataListParm.parammaps.enable = ''
  1091. this.table.getdataListParm.parammaps.source = ''
  1092. this.table.getdataListParm.parammaps.all = ''
  1093. this.getList()
  1094. },
  1095. // 模板新增
  1096. handleCreate() {
  1097. console.log('点击了新增')
  1098. // 编辑true/不可编辑false
  1099. // 新增操true,编辑false,编辑保存false
  1100. for (let i = 0; i < this.table.list.length; i++) {
  1101. if (this.table.list[i].Edit === true) {
  1102. console.log(123)
  1103. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1104. return false
  1105. }
  1106. }
  1107. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', tcode: '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  1108. console.log(this.table.list)
  1109. },
  1110. // 畜生类别
  1111. changeLivestockType(item) {
  1112. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  1113. },
  1114. // 配方类型
  1115. changeFormulaType(item) {
  1116. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  1117. },
  1118. createData(row) {
  1119. console.log('点击了新增保存', row)
  1120. this.table.temp.tname = row.tname
  1121. this.table.temp.tcode = row.tcode
  1122. this.table.temp.tcolor = row.tcolor
  1123. this.table.temp.ccid = row.ccid
  1124. this.table.temp.ccname = this.table.temp.ccname
  1125. this.table.temp.fttype = this.table.temp.fttype
  1126. this.table.temp.fttypeid = row.fttypeid
  1127. this.table.temp.source = row.source
  1128. this.table.temp.remark = row.remark
  1129. this.table.temp.enable = row.enable
  1130. this.table.temp.pastureid = Cookies.get('pastureid')
  1131. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1132. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1133. return false
  1134. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1135. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1136. return false
  1137. } else if (this.table.temp.tname == '') {
  1138. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1139. return false
  1140. } else if (this.table.temp.ccid == '') {
  1141. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1142. return false
  1143. } else if (this.table.temp.fttypeid == '') {
  1144. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1145. return false
  1146. }
  1147. // const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1148. // if (pattern.test(this.table.temp.tname)) {
  1149. // this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1150. // return false
  1151. // }
  1152. // if (pattern.test(this.table.temp.tcode)) {
  1153. // this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1154. // return false
  1155. // }
  1156. console.log(this.table.temp)
  1157. this.isokDisable = true
  1158. setTimeout(() => {
  1159. this.isokDisable = false
  1160. }, 1000)
  1161. this.requestParam.name = 'insertFT'
  1162. this.requestParam.parammaps = this.table.temp
  1163. PostDataByName(this.requestParam).then(response => {
  1164. console.log('新增保存发送参数', this.requestParam)
  1165. if (response.msg !== 'fail') {
  1166. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1167. this.getList()
  1168. } else {
  1169. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1170. }
  1171. })
  1172. },
  1173. createCancel(row) {
  1174. console.log('点击了新增取消')
  1175. for (let i = 0; i < this.table.list.length; i++) {
  1176. if (row.myId === this.table.list[i].myId) {
  1177. var listIndex = this.table.list.indexOf(this.table.list[i])
  1178. }
  1179. if (listIndex > -1) {
  1180. this.table.list.splice(listIndex, 1)
  1181. return
  1182. }
  1183. }
  1184. },
  1185. // 模板编辑
  1186. handleUpdate(row) {
  1187. for (let i = 0; i < this.table.list.length; i++) {
  1188. if (this.table.list[i].Edit == true) {
  1189. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1190. return false
  1191. }
  1192. }
  1193. // 编辑true,不可编辑false
  1194. row.Edit = true
  1195. row.NoEdit = false
  1196. // 新增false,编辑false,编辑保存true
  1197. row.isCreate = false
  1198. row.isUpdate = false
  1199. row.isUpdateSave = true
  1200. if (row.ccname !== undefined) {
  1201. row.ccid = String(row.ccid)
  1202. }
  1203. this.table.temp.ccname = row.ccname
  1204. row.fttypeid = String(row.fttypeid)
  1205. this.table.temp.fttype = row.fttype
  1206. },
  1207. updateData(row) {
  1208. console.log('点击了编辑保存', row)
  1209. this.table.temp.tname = row.tname
  1210. this.table.temp.tcode = row.tcode
  1211. this.table.temp.tcolor = row.tcolor
  1212. this.table.temp.ccid = row.ccid
  1213. this.table.temp.fttypeid = row.fttypeid
  1214. this.table.temp.source = row.source
  1215. this.table.temp.remark = row.remark
  1216. this.table.temp.enable = row.enable
  1217. this.table.temp.ccname = this.table.temp.ccname
  1218. this.table.temp.fttype = this.table.temp.fttype
  1219. this.table.temp.pastureid = row.pastureid
  1220. this.table.temp.id = row.id
  1221. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1222. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1223. return false
  1224. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1225. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1226. return false
  1227. } else if (this.table.temp.tname == '') {
  1228. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1229. return false
  1230. } else if (this.table.temp.ccid == '') {
  1231. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1232. return false
  1233. } else if (this.table.temp.fttypeid == '') {
  1234. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1235. return false
  1236. }
  1237. // const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1238. // if (pattern.test(this.table.temp.tname)) {
  1239. // this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1240. // return false
  1241. // }
  1242. // if (pattern.test(this.table.temp.tcode)) {
  1243. // this.$message({ type: 'error', message: '配方编码不可输入特殊字符', duration: 2000 })
  1244. // return false
  1245. // }
  1246. console.log(this.table.temp)
  1247. this.isokDisable = true
  1248. setTimeout(() => {
  1249. this.isokDisable = false
  1250. }, 1000)
  1251. this.requestParam.name = 'updateFT'
  1252. this.requestParam.parammaps = this.table.temp
  1253. PostDataByName(this.requestParam).then(response => {
  1254. console.log('新增保存发送参数', this.requestParam)
  1255. if (response.msg !== 'fail') {
  1256. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1257. this.getList()
  1258. } else {
  1259. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1260. }
  1261. })
  1262. },
  1263. updateCancel(row) {
  1264. console.log('点击了编辑取消')
  1265. // 编辑false,不可编辑true
  1266. row.Edit = false
  1267. row.NoEdit = true
  1268. // 新增false,编辑true,编辑保存false
  1269. row.isCreate = false
  1270. row.isUpdate = true
  1271. row.isUpdateSave = false
  1272. this.getList()
  1273. },
  1274. // 删除
  1275. handleRowDelete(row) {
  1276. console.log('点击了行内删除')
  1277. MessageBox.confirm('是否确认删除此信息?', {
  1278. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1279. }).then(() => {
  1280. this.requestParam.common = { 'returnmap': '0' }
  1281. this.requestParam.data = []
  1282. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1283. pastureid: row.pastureid,
  1284. id: row.id
  1285. }}
  1286. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1287. pastureid: row.pastureid,
  1288. id: row.id
  1289. }}
  1290. ExecDataByConfig(this.requestParam).then(response => {
  1291. console.log('新增保存发送参数', this.requestParam)
  1292. if (response.msg === 'fail') {
  1293. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1294. } else {
  1295. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1296. this.getList()
  1297. this.isDetail = false
  1298. }
  1299. })
  1300. }).catch(() => {
  1301. this.$message({ type: 'info', message: '已取消删除' })
  1302. })
  1303. },
  1304. handleSelectionChange(val) {
  1305. console.log('勾选数据', val)
  1306. this.selectList = val
  1307. },
  1308. handleDelete() {
  1309. console.log('点击了删除')
  1310. if (this.selectList.length == 0) {
  1311. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1312. } else {
  1313. MessageBox.confirm('是否确认删除此信息?', {
  1314. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1315. }).then(() => {
  1316. console.log(this.selectList)
  1317. this.requestParam.common = { 'returnmap': '0' }
  1318. this.requestParam.data = []
  1319. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1320. this.requestParam.data[0].children = []
  1321. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1322. id: '@insertSpotList.id',
  1323. pastureid: '@insertSpotList.pastureid'
  1324. }}
  1325. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1326. id: '@insertSpotList.id',
  1327. pastureid: '@insertSpotList.pastureid'
  1328. }}
  1329. ExecDataByConfig(this.requestParam).then(response => {
  1330. console.log('删除保存发送参数', this.requestParam)
  1331. if (response.msg === 'fail') {
  1332. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1333. } else {
  1334. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1335. this.getList()
  1336. }
  1337. })
  1338. })
  1339. }
  1340. },
  1341. // 复制
  1342. handleCopy() {
  1343. if (this.selectList.length == 0) {
  1344. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1345. } else {
  1346. MessageBox.confirm('是否确认复制此信息?', {
  1347. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1348. }).then(() => {
  1349. console.log(this.selectList)
  1350. this.requestParam.common = { 'returnmap': '0' }
  1351. this.requestParam.data = []
  1352. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1353. this.requestParam.data[0].children = []
  1354. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1355. ftid: '@insertSpotList.id',
  1356. pastureid: '@insertSpotList.pastureid'
  1357. }}
  1358. ExecDataByConfig(this.requestParam).then(response => {
  1359. console.log('复制保存发送参数', this.requestParam)
  1360. if (response.msg === 'fail') {
  1361. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1362. } else {
  1363. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1364. this.getList()
  1365. }
  1366. })
  1367. })
  1368. }
  1369. },
  1370. // 配方记录
  1371. handleRecipeRecord() {
  1372. console.log('点击了配方记录')
  1373. this.template.dialogStatus = 'RecipeRecord'
  1374. this.template.dialogFormVisible = true
  1375. this.template.table.getdataListParm.parammaps.ccname = ''
  1376. this.template.table.getdataListParm.parammaps.fttype = ''
  1377. this.template.table.getdataListParm.parammaps.enable = ''
  1378. this.template.table.getdataListParm.parammaps.tname = ''
  1379. this.template.table.getdataListParm.parammaps.remark = ''
  1380. this.template.table.getdataListParm.parammaps.source = ''
  1381. this.template.table.getdataListParm.offset = 1
  1382. this.getDateList()
  1383. this.isDetailDialog = false
  1384. this.myheight2 = document.documentElement.clientHeight - 85 - 265
  1385. },
  1386. // 历史时间
  1387. getDateList() {
  1388. GetDataByName(this.template.getdataDateParm).then(response => {
  1389. console.log('table数据', response.data.list)
  1390. if (response.data.list !== null) {
  1391. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1392. this.getTemplateDialogList()
  1393. } else {
  1394. this.template.table.getdataListParm.parammaps.date = ''
  1395. }
  1396. })
  1397. },
  1398. // 配方记录-模板
  1399. getTemplateDialogList() {
  1400. this.template.table.listLoading = true
  1401. GetDataByName(this.template.table.getdataListParm).then(response => {
  1402. console.log('table数据', response.data.list)
  1403. if (response.data.list !== null) {
  1404. this.template.table.list = response.data.list
  1405. this.template.table.pageNum = response.data.pageNum
  1406. this.template.table.pageSize = response.data.pageSize
  1407. this.template.table.total = response.data.total
  1408. } else {
  1409. this.template.table.list = []
  1410. this.template.table2.list = []
  1411. }
  1412. setTimeout(() => {
  1413. this.template.table.listLoading = false
  1414. }, 100)
  1415. })
  1416. },
  1417. handleDialogSearch() {
  1418. this.template.table.getdataListParm.offset = 1
  1419. this.getTemplateDialogList()
  1420. this.arrowDown = true
  1421. this.arrowUp = false
  1422. },
  1423. handleDialogRefresh() {
  1424. this.template.table.getdataListParm.parammaps.ccname = ''
  1425. this.template.table.getdataListParm.parammaps.fttype = ''
  1426. this.template.table.getdataListParm.parammaps.enable = ''
  1427. this.template.table.getdataListParm.parammaps.tname = ''
  1428. this.template.table.getdataListParm.parammaps.remark = ''
  1429. this.template.table.getdataListParm.parammaps.source = ''
  1430. this.template.table.getdataListParm.offset = 1
  1431. this.getTemplateDialogList()
  1432. },
  1433. // 配方记录-模板行点击
  1434. tableRowClickDialog(row, column, event) {
  1435. console.log('配方记录-模板行点击')
  1436. this.isDetailDialog = true
  1437. this.template.table2.getdataListParm.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1438. this.template.table2.getdataListParm.parammaps.version = row.version
  1439. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1440. this.template.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1441. this.myheight2 = document.documentElement.clientHeight - 85 - 265 - 185
  1442. this.getDialogList()
  1443. this.getDownList()
  1444. // aiaiaiai
  1445. },
  1446. getDialogList() {
  1447. this.template.table2.listLoading = true
  1448. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1449. console.log('table数据', response.data.list)
  1450. if (response.data.list !== null) {
  1451. this.template.table2.list = response.data.list
  1452. this.template.table2.pageNum = response.data.pageNum
  1453. this.template.table2.pageSize = response.data.pageSize
  1454. this.template.table2.total = response.data.total
  1455. } else {
  1456. this.template.table2.list = []
  1457. }
  1458. this.$nextTick(function() {
  1459. document.querySelector('#detailDialog2').scrollIntoView()
  1460. // window.scrollTo({
  1461. // 'top': this.$refs.detailDialog2.clientHeight
  1462. // })
  1463. })
  1464. setTimeout(() => {
  1465. this.template.table2.listLoading = false
  1466. }, 100)
  1467. })
  1468. },
  1469. handleDialogSearch2() {
  1470. console.log('点击了查询')
  1471. this.arrowDown2 = true
  1472. this.arrowUp2 = false
  1473. this.template.table2.getdataListParm.offset = 1
  1474. this.getDialogList2()
  1475. },
  1476. handleDialogRefresh2() {
  1477. console.log('点击了重置')
  1478. this.template.table2.getdataListParm.parammaps.fname = ''
  1479. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1480. this.template.table2.getdataListParm.parammaps.fweight = ''
  1481. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1482. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1483. this.template.table2.getdataListParm.parammaps.sort = ''
  1484. this.template.table2.getdataListParm.offset = 1
  1485. this.getDialogList2()
  1486. },
  1487. getDialogList2() {
  1488. this.template.table2.listLoading = true
  1489. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1490. console.log('table数据', response.data.list)
  1491. if (response.data.list !== null) {
  1492. this.template.table2.list = response.data.list
  1493. this.template.table2.pageNum = response.data.pageNum
  1494. this.template.table2.pageSize = response.data.pageSize
  1495. this.template.table2.total = response.data.total
  1496. } else {
  1497. this.template.table2.list = []
  1498. }
  1499. this.$nextTick(function() {
  1500. window.scrollTo({
  1501. 'top': this.$refs.templateDialog.clientHeight
  1502. })
  1503. })
  1504. setTimeout(() => {
  1505. this.template.table2.listLoading = false
  1506. }, 100)
  1507. })
  1508. },
  1509. // 导出
  1510. handleExport(item) {
  1511. if (item == 1) {
  1512. console.log('点击了导出模板')
  1513. const requestParam = this.requestParam
  1514. const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/配方计划/配方模板导入模板.xlsx' // 请求下载文件的地址
  1515. console.log(url)
  1516. axios({
  1517. method: 'GET',
  1518. url: url,
  1519. data: requestParam,
  1520. headers: { token: getToken(), optname: 'insertcustomdoc' },
  1521. responseType: 'blob'
  1522. }).then(res => {
  1523. if (!res) return
  1524. this.percentage = 99
  1525. setTimeout(() => {
  1526. this.isPercentage = false
  1527. }, 2000)
  1528. const blob = new Blob([res.data], {
  1529. type: 'application/octet-stream;charset=utf-8'
  1530. })
  1531. const url = window.URL.createObjectURL(blob)
  1532. const aLink = document.createElement('a')
  1533. aLink.style.display = 'none'
  1534. aLink.href = url
  1535. const docname = '配方模板导入模板.xlsx'
  1536. aLink.setAttribute('download', docname) // 下载的文件
  1537. document.body.appendChild(aLink)
  1538. aLink.click()
  1539. document.body.removeChild(aLink)
  1540. window.URL.revokeObjectURL(url)
  1541. })
  1542. } else {
  1543. console.log('点击了导出数据')
  1544. this.download.getdataListParm.name = 'downloadFTList'
  1545. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1546. GetDataByName(this.download.getdataListParm).then(response => {
  1547. if (response.data.list !== null) {
  1548. for (let i = 0; i < response.data.list.length; i++) {
  1549. if (response.data.list[i].islockcount == 0) {
  1550. this.$set(response.data.list[i], 'islockcount', '否')
  1551. } else {
  1552. this.$set(response.data.list[i], 'islockcount', '是')
  1553. }
  1554. if (response.data.list[i].enable == 0) {
  1555. this.$set(response.data.list[i], 'enable', '否')
  1556. } else {
  1557. this.$set(response.data.list[i], 'enable', '是')
  1558. }
  1559. }
  1560. this.download.list = response.data.list
  1561. } else {
  1562. this.download.list = []
  1563. }
  1564. var excelDatas = [
  1565. {
  1566. tHeader: ['配方名称', '配方编码', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1567. filterVal: ['tname', 'tcode', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1568. tableDatas: this.download.list,
  1569. sheetName: 'Sheet1'
  1570. }
  1571. ]
  1572. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1573. })
  1574. }
  1575. },
  1576. beforeImport(file) {
  1577. const isLt2M = file.size / 1024 / 1024 < 2
  1578. if (!isLt2M) {
  1579. this.$message.error('上传文件大小不能超过 2MB!')
  1580. }
  1581. return isLt2M
  1582. },
  1583. handleImportSuccess(res, file) {
  1584. this.getList()
  1585. if (res.msg === 'ok') {
  1586. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1587. if (res.data.err_count > 0) {
  1588. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1589. import('@/vendor/Export2Excel').then(excel => {
  1590. const list1 = res.data.result
  1591. const tHeader = [
  1592. '配方名称', '牲畜类别', '配方类型', '备注', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1593. ]
  1594. const filterVal = [
  1595. '配方名称', '牲畜类别', '配方类型', '备注', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1596. ]
  1597. const data1 = this.formatJson(filterVal, list1)
  1598. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1599. })
  1600. }
  1601. } else {
  1602. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1603. }
  1604. },
  1605. formatJson(filterVal, jsonData) {
  1606. return jsonData.map(v =>
  1607. filterVal.map(j => {
  1608. if (j === 'timestamp') {
  1609. return parseTime(v[j])
  1610. } else {
  1611. return v[j]
  1612. }
  1613. })
  1614. )
  1615. },
  1616. changeDate() {
  1617. this.getTemplateDialogList()
  1618. },
  1619. // 应用
  1620. handleApplication() {
  1621. console.log('点击了应用')
  1622. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1623. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1624. }).then(() => {
  1625. this.requestParam.name = 'applyFTdate'
  1626. this.requestParam.parammaps = {}
  1627. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1628. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1629. PostDataByName(this.requestParam).then(response => {
  1630. if (response.msg === 'fail') {
  1631. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1632. } else {
  1633. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1634. this.getTemplateDialogList()
  1635. this.getList()
  1636. }
  1637. })
  1638. }).catch(() => {
  1639. this.$message({ type: 'info', message: '已取消应用' })
  1640. })
  1641. },
  1642. // 模板行点击
  1643. tableRowClick(row, column, event) {
  1644. console.log(row, column, event)
  1645. for (let i = 0; i < this.table.list.length; i++) {
  1646. if (this.table.list[i].Edit == true) {
  1647. return false
  1648. }
  1649. }
  1650. console.log(this.isOrder)
  1651. if (this.isOrder == false) {
  1652. this.$message({ type: 'error', message: '请保存或取消当前更改顺序操作', duration: 2000 })
  1653. } else {
  1654. if (column.label !== '操作') {
  1655. this.isDetail = true // 点击行显示详情
  1656. this.table2.getdataListParm.parammaps.ftid = row.id
  1657. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1658. this.table2.getdataListParm.parammaps.dryweight = row.dryweight
  1659. if (row.fttype == '预混配方') {
  1660. this.requestParams[2].parammaps.type = '1'
  1661. } else {
  1662. this.requestParams[2].parammaps.type = ''
  1663. }
  1664. this.myheight = document.documentElement.clientHeight - 85 - 265 - 185
  1665. this.getList2()
  1666. this.getDownList()
  1667. }
  1668. }
  1669. },
  1670. handleCloseTable2() {
  1671. this.isDetail = false
  1672. this.myheight = ''
  1673. },
  1674. handleDialogCloseTable2() {
  1675. this.isDetailDialog = false
  1676. this.myheight2 = ''
  1677. },
  1678. // -------------------详情-----------------------------
  1679. // 获取是否显示是否锁定牛头数
  1680. getIsLockCount() {
  1681. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1682. console.log(response.data.list)
  1683. if (response.data.list[0].inforvalue == 0) {
  1684. this.lockCount.isLockCount = false
  1685. } else {
  1686. this.lockCount.isLockCount = true
  1687. }
  1688. })
  1689. },
  1690. // 详情
  1691. getList2() {
  1692. this.table2.listLoading = true
  1693. GetDataByName(this.table2.getdataListParm).then(response => {
  1694. console.log('table数据', response.data.list)
  1695. if (response.data.list !== null) {
  1696. for (let i = 0; i < response.data.list.length; i++) {
  1697. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1698. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1699. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1700. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1701. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1702. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1703. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1704. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1705. console.log(this.table2.getdataListParm.parammaps)
  1706. console.log(this.table2, '===')
  1707. }
  1708. this.table2.getDryweightParm.parammaps = this.table2.getdataListParm.parammaps
  1709. this.getDryWeight()
  1710. this.table2.list = response.data.list
  1711. this.table2.pageNum = response.data.pageNum
  1712. this.table2.pageSize = response.data.pageSize
  1713. this.table2.total = response.data.total
  1714. } else {
  1715. this.table2.list = []
  1716. }
  1717. setTimeout(() => {
  1718. this.table2.listLoading = false
  1719. }, 100)
  1720. })
  1721. },
  1722. // 行拖拽
  1723. rowDrop() {
  1724. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1725. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1726. // this.sorTable()
  1727. const that = this
  1728. // Sortable.create(tbody, {
  1729. var sortable = Sortable.create(tbody, {
  1730. disabled: that.dropState,
  1731. onChoose({ newIndex, oldIndex }) {
  1732. console.log(that.isOrder, 'that.isOrder == false')
  1733. console.log(that.dropState, 'that.dropState')
  1734. if (that.dropState == true || that.isOrder == true) {
  1735. sortable.destroy()
  1736. }
  1737. },
  1738. onEnd({ newIndex, oldIndex }) {
  1739. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1740. that.table2.list.splice(newIndex, 0, currRow)
  1741. console.log('索引', newIndex)
  1742. console.log('拖动数据', currRow)
  1743. console.log('上', that.table2.list[newIndex - 1])
  1744. console.log('下', that.table2.list[newIndex + 1])
  1745. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1746. for (let i = 0; i < that.table2.list.length; i++) {
  1747. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1748. }
  1749. currRow.sort = 0
  1750. currRow.feedgroup = currRow.fname
  1751. console.log('拖动至最上方无值')
  1752. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1753. currRow.sort = that.table2.list[newIndex - 1].sort
  1754. console.log('拖动值顺序等于上值顺序')
  1755. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1756. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1757. currRow.feedgroup = currRow.fname
  1758. console.log('拖动至最下方无值')
  1759. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1760. currRow.sort == that.table2.list[newIndex + 1].sort
  1761. console.log('拖动值顺序等于下值顺序')
  1762. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1763. currRow.sort = that.table2.list[newIndex - 1].sort
  1764. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1765. console.log('拖动至上下顺序一致')
  1766. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1767. console.log('上下')
  1768. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1769. console.log(newIndex)
  1770. for (let i = newIndex; i < that.table2.list.length; i++) {
  1771. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1772. }
  1773. }
  1774. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1775. currRow.feedgroup = currRow.fname
  1776. console.log(that.table2.list[newIndex + 1].sort)
  1777. }
  1778. }
  1779. })
  1780. console.log(sortable.option('disabled'))
  1781. },
  1782. handleChangeOrder() {
  1783. this.isOrder = false
  1784. this.rowDrop()
  1785. },
  1786. saveChangeOrder() {
  1787. // 保存顺序
  1788. console.log(this.table2.list)
  1789. this.requestParam = {}
  1790. this.requestParam.common = { 'returnmap': '0' }
  1791. this.requestParam.data = []
  1792. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.table2.list }}
  1793. this.requestParam.data[0].children = []
  1794. this.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1795. id: '@insertSpotList.id',
  1796. pastureid: '@insertSpotList.pastureid',
  1797. sort: '@insertSpotList.sort',
  1798. feedgroup: '@insertSpotList.feedgroup'
  1799. }}
  1800. ExecDataByConfig(this.requestParam).then(response => {
  1801. console.log('顺序切换保存发送参数', this.requestParam)
  1802. if (response.msg === 'fail') {
  1803. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1804. } else {
  1805. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1806. this.getList2()
  1807. this.getList3()
  1808. this.isOrder = true
  1809. }
  1810. })
  1811. },
  1812. cancelChangeOrder() {
  1813. // 取消顺序
  1814. this.getList2()
  1815. this.isOrder = true
  1816. },
  1817. handleSearch2() {
  1818. console.log('点击了查询')
  1819. this.arrowDown2 = true
  1820. this.arrowUp2 = false
  1821. this.table2.getdataListParm.offset = 1
  1822. // fname, feedgroup, fweight, autosecondname, islockcount, sort
  1823. // this.table2.getdataListParm.parammaps.all = this.table2.getdataListParm.parammaps.fname + ' ' + this.table2.getdataListParm.parammaps.feedgroup + ' ' + this.table2.getdataListParm.parammaps.fweight + ' ' + this.table2.getdataListParm.parammaps.autosecondname + ' ' + this.table2.getdataListParm.parammaps.islockcount + ' ' + this.table2.getdataListParm.parammaps.sort
  1824. this.table2.getdataListParm.parammaps.all = ''
  1825. var obj = {}
  1826. obj.fname = this.table2.getdataListParm.parammaps.fname
  1827. obj.feedgroup = this.table2.getdataListParm.parammaps.feedgroup
  1828. obj.fweight = this.table2.getdataListParm.parammaps.fweight
  1829. obj.autosecondname = this.table2.getdataListParm.parammaps.autosecondname
  1830. if (this.table2.getdataListParm.parammaps.islockcount !== '') {
  1831. if (this.table2.getdataListParm.parammaps.islockcount == 0) {
  1832. this.table2.getdataListParm.parammaps.islockcount = '否'
  1833. } else {
  1834. this.table2.getdataListParm.parammaps.islockcount = '是'
  1835. }
  1836. }
  1837. obj.islockcount = this.table2.getdataListParm.parammaps.islockcount
  1838. obj.sort = this.table2.getdataListParm.parammaps.sort
  1839. Object.getOwnPropertyNames(obj).forEach((key) => {
  1840. console.log(key, obj[key])
  1841. if (obj[key] !== '') {
  1842. this.table2.getdataListParm.parammaps.all += obj[key] + '/'
  1843. }
  1844. })
  1845. if (this.table2.getdataListParm.parammaps.all.charAt(this.table2.getdataListParm.parammaps.all.length - 1) == '/') {
  1846. this.table2.getdataListParm.parammaps.all = this.table2.getdataListParm.parammaps.all.slice(0, this.table2.getdataListParm.parammaps.all.length - 1)
  1847. }
  1848. this.getList2()
  1849. },
  1850. handleRefresh2() {
  1851. console.log('点击了重置')
  1852. this.table2.getdataListParm.parammaps.fname = ''
  1853. this.table2.getdataListParm.parammaps.feedgroup = ''
  1854. this.table2.getdataListParm.parammaps.fweight = ''
  1855. this.table2.getdataListParm.parammaps.autosecondname = ''
  1856. this.table2.getdataListParm.parammaps.islockcount = '0'
  1857. this.table2.getdataListParm.parammaps.sort = ''
  1858. this.table2.getdataListParm.parammaps.all = ''
  1859. this.table2.getdataListParm.offset = 1
  1860. this.getList2()
  1861. },
  1862. // 详情新增
  1863. handleCreate2() {
  1864. console.log('点击了详情新增', this.table2.list)
  1865. // 编辑true/不可编辑false
  1866. // 新增操true,编辑false,编辑保存false
  1867. console.log(11)
  1868. for (let i = 0; i < this.table2.list.length; i++) {
  1869. if (this.table2.list[i].Edit === true) {
  1870. console.log(123)
  1871. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1872. return false
  1873. }
  1874. }
  1875. console.log(this.table2.list)
  1876. if (this.table2.list.length == 0) {
  1877. var mysort = 0
  1878. } else {
  1879. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1880. }
  1881. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1882. console.log(this.table2.list)
  1883. },
  1884. changeFname(item, row) {
  1885. console.log(item, row)
  1886. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1887. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1888. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1889. this.table2.temp.preftid = '0'
  1890. } else {
  1891. this.table2.temp.preftid = item
  1892. }
  1893. if (row.sort == '') {
  1894. row.feedgroup = this.table2.temp.fname
  1895. } else {
  1896. if (row.isCreate == true) { // 新增状态下
  1897. for (let i = 1; i < this.table2.list.length; i++) {
  1898. if (this.table2.list[i].sort == row.sort) {
  1899. console.log(this.table2.list[i])
  1900. row.feedgroup = this.table2.list[i].feedgroup
  1901. break
  1902. } else {
  1903. row.feedgroup = this.table2.temp.fname
  1904. }
  1905. }
  1906. } else if (row.isUpdateSave == true) { // 编辑状态下
  1907. var Arr = []
  1908. for (let i = 0; i < this.table2.list.length; i++) {
  1909. Arr.push(this.table2.list[i].sort)
  1910. }
  1911. var Count = 0
  1912. for (let i = 0; i < Arr.length; i++) {
  1913. if (Arr[i] == row.sort) {
  1914. Count++
  1915. }
  1916. }
  1917. for (let i = 0; i < this.table2.list.length; i++) {
  1918. if (Count > 1) {
  1919. row.feedgroup = this.table2.list[i].feedgroup
  1920. console.log(this.table2.list[i].feedgroup)
  1921. break
  1922. } else if (Count == 1) {
  1923. row.feedgroup = this.table2.temp.fname
  1924. console.log(222, this.table2.temp.fname)
  1925. }
  1926. }
  1927. }
  1928. }
  1929. },
  1930. bort(row) {
  1931. if (row.isCreate == true) {
  1932. if (row.sort !== '') {
  1933. for (let i = 1; i < this.table2.list.length; i++) {
  1934. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1935. row.feedgroup = this.table2.list[i].feedgroup
  1936. return false
  1937. } else {
  1938. row.feedgroup = row.fname
  1939. }
  1940. }
  1941. } else {
  1942. row.feedgroup = row.fname
  1943. }
  1944. } else if (row.isUpdateSave == true) {
  1945. if (row.sort !== '') {
  1946. for (let i = 0; i < this.table2.list.length; i++) {
  1947. if (this.table2.list[i].sort == row.sort) {
  1948. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1949. if (this.table2.list[i].id !== row.id) {
  1950. row.isGroupDisabled = true
  1951. row.feedgroup = this.table2.list[i].feedgroup
  1952. break
  1953. }
  1954. } else {
  1955. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1956. row.isGroupDisabled = true
  1957. row.feedgroup = row.fname
  1958. }
  1959. }
  1960. } else {
  1961. row.feedgroup = row.fname
  1962. }
  1963. }
  1964. },
  1965. createData2(row) {
  1966. console.log('点击了详情新增保存', row)
  1967. this.table2.temp.pastureid = Cookies.get('pastureid')
  1968. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1969. this.table2.temp.fid = row.fid
  1970. this.table2.temp.fname = this.table2.temp.fname
  1971. this.table2.temp.fweight = row.fweight
  1972. this.table2.temp.islockcount = row.islockcount
  1973. this.table2.temp.sort = row.sort
  1974. this.table2.temp.feedgroup = row.feedgroup
  1975. this.table2.temp.preftid = this.table2.temp.preftid
  1976. this.table2.temp.autosecond = row.autosecond
  1977. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1978. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1979. return false
  1980. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1981. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1982. return false
  1983. } else if (this.table2.temp.fid == '') {
  1984. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1985. return false
  1986. } else if (this.table2.temp.fweight == '') {
  1987. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1988. return false
  1989. } else if (this.table2.temp.autosecond == '') {
  1990. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1991. return false
  1992. }
  1993. if (this.table2.temp.sort !== '') {
  1994. this.table2.temp.sort = this.table2.temp.sort
  1995. } else {
  1996. console.log(this.table2.list.length)
  1997. if (this.table2.list.length == 1) {
  1998. this.table2.temp.sort = 0
  1999. } else {
  2000. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2001. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2002. }
  2003. }
  2004. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2005. if (parseInt(this.table2.temp.preftid) > 0) {
  2006. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2007. return false
  2008. }
  2009. }
  2010. // 校验顺序是否>=0
  2011. var ruleSort = /^\d+$/
  2012. if (!ruleSort.test(this.table2.temp.sort)) {
  2013. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2014. return false
  2015. }
  2016. // 检验重量>0
  2017. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  2018. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2019. if (!ruleWeight.test(this.table2.temp.fweight)) {
  2020. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  2021. return false
  2022. }
  2023. this.isokDisable = true
  2024. setTimeout(() => {
  2025. this.isokDisable = false
  2026. }, 1000)
  2027. this.requestParam.common = { 'returnmap': '0' }
  2028. this.requestParam.data = []
  2029. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2030. pastureid: this.table2.temp.pastureid,
  2031. ftid: this.table2.getdataListParm.parammaps.ftid,
  2032. fid: row.fid,
  2033. fname: this.table2.temp.fname,
  2034. fweight: row.fweight,
  2035. islockcount: row.islockcount,
  2036. sort: row.sort,
  2037. feedgroup: row.feedgroup,
  2038. preftid: this.table2.temp.preftid,
  2039. autosecond: row.autosecond
  2040. }}
  2041. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2042. pastureid: this.table2.temp.pastureid,
  2043. ftid: this.table2.getdataListParm.parammaps.ftid,
  2044. type: this.table2.getdataListParm.parammaps.fttypeid
  2045. }}
  2046. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2047. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2048. id: this.table2.getdataListParm.parammaps.ftid
  2049. }}
  2050. ExecDataByConfig(this.requestParam).then(response => {
  2051. console.log('新增保存发送参数', this.requestParam)
  2052. if (response.msg !== 'fail') {
  2053. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2054. this.getList2()
  2055. this.getList3()
  2056. } else {
  2057. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2058. }
  2059. })
  2060. },
  2061. createCancel2(row) {
  2062. console.log('点击了详情新增取消')
  2063. for (let i = 0; i < this.table2.list.length; i++) {
  2064. if (row.myId === this.table2.list[i].myId) {
  2065. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  2066. }
  2067. if (listIndex > -1) {
  2068. this.table2.list.splice(listIndex, 1)
  2069. return
  2070. }
  2071. }
  2072. this.getDialogList()
  2073. },
  2074. // 详情编辑
  2075. handleUpdate2(row) {
  2076. console.log('详情编辑', row)
  2077. this.dropState = true
  2078. row.isGroupDisabled = false
  2079. row.islockcount = String(row.islockcount)
  2080. row.fid = String(row.fid)
  2081. row.autosecond = String(row.autosecond)
  2082. this.table2.temp.fname = row.fname
  2083. this.table2.temp.preftid = row.preftid
  2084. const rowArr = []
  2085. for (let i = 0; i < this.table2.list.length; i++) {
  2086. if (this.table2.list[i].Edit == true) {
  2087. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  2088. return false
  2089. }
  2090. rowArr.push(this.table2.list[i].sort)
  2091. }
  2092. var count = 0
  2093. for (let i = 0; i < rowArr.length; i++) {
  2094. if (rowArr[i] == row.sort) {
  2095. count++
  2096. }
  2097. }
  2098. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  2099. if (count == 1) {
  2100. // 饲料组编辑false,不可编辑true
  2101. row.groupEdit = false
  2102. row.groupNoEdit = true
  2103. // 编辑true,不可编辑false
  2104. row.Edit = true
  2105. row.NoEdit = false
  2106. // 新增false,编辑false,编辑保存true
  2107. row.isCreate = false
  2108. row.isUpdate = false
  2109. row.isUpdateSave = true
  2110. } else if (count > 1) {
  2111. // 饲料组编辑true,不可编辑false
  2112. row.groupEdit = true
  2113. row.groupNoEdit = false
  2114. console.log(222)
  2115. // 编辑true,不可编辑false
  2116. row.Edit = true
  2117. row.NoEdit = false
  2118. // 新增false,编辑false,编辑保存true
  2119. row.isCreate = false
  2120. row.isUpdate = false
  2121. row.isUpdateSave = true
  2122. return false
  2123. }
  2124. },
  2125. updateData2(row) {
  2126. console.log('点击了详情编辑保存', row)
  2127. this.isokDisable = true
  2128. setTimeout(() => {
  2129. this.isokDisable = false
  2130. }, 1000)
  2131. this.table2.temp.pastureid = row.pastureid
  2132. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  2133. this.table2.temp.fid = row.fid
  2134. this.table2.temp.fname = this.table2.temp.fname
  2135. this.table2.temp.fweight = row.fweight
  2136. this.table2.temp.islockcount = row.islockcount
  2137. this.table2.temp.sort = row.sort
  2138. this.table2.temp.feedgroup = row.feedgroup
  2139. this.table2.temp.preftid = this.table2.temp.preftid
  2140. this.table2.temp.autosecond = row.autosecond
  2141. this.table2.temp.id = row.id
  2142. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2143. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  2144. return false
  2145. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  2146. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  2147. return false
  2148. } else if (this.table2.temp.fid == '') {
  2149. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  2150. return false
  2151. } else if (this.table2.temp.fweight == '') {
  2152. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  2153. return false
  2154. } else if (this.table2.temp.autosecond == '') {
  2155. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  2156. return false
  2157. }
  2158. if (this.table2.temp.sort !== '') {
  2159. this.table2.temp.sort = this.table2.temp.sort
  2160. } else {
  2161. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  2162. }
  2163. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2164. if (parseInt(this.table2.temp.preftid) > 0) {
  2165. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  2166. return false
  2167. }
  2168. }
  2169. // 校验顺序是否>=0
  2170. var ruleSort = /^\d+$/
  2171. if (!ruleSort.test(this.table2.temp.sort)) {
  2172. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  2173. return false
  2174. }
  2175. // this.table2.temp.fweight = formatNum(this.table2.temp.fweight, 2) //根据默认参数设置小数位数
  2176. // 检验重量>0
  2177. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  2178. if (!ruleWeight.test(this.table2.temp.fweight)) {
  2179. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  2180. return false
  2181. }
  2182. this.requestParam.common = { 'returnmap': '0' }
  2183. this.requestParam.data = []
  2184. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  2185. pastureid: row.pastureid,
  2186. ftid: this.table2.getdataListParm.parammaps.ftid,
  2187. fid: row.fid,
  2188. fname: this.table2.temp.fname,
  2189. fweight: row.fweight,
  2190. islockcount: row.islockcount,
  2191. sort: row.sort,
  2192. feedgroup: row.feedgroup,
  2193. preftid: this.table2.temp.preftid,
  2194. autosecond: row.autosecond,
  2195. id: row.id
  2196. }}
  2197. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2198. pastureid: row.pastureid,
  2199. ftid: this.table2.getdataListParm.parammaps.ftid,
  2200. type: this.table2.getdataListParm.parammaps.fttypeid
  2201. }}
  2202. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  2203. pastureid: row.pastureid,
  2204. ftid: this.table2.getdataListParm.parammaps.ftid,
  2205. sort: row.sort,
  2206. feedgroup: row.feedgroup
  2207. }}
  2208. this.requestParam.data[3] = { 'name': 'updateFTdetailGroup', 'type': 'e', 'parammaps': {
  2209. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2210. ftid: this.table2.getdataListParm.parammaps.ftid
  2211. }}
  2212. ExecDataByConfig(this.requestParam).then(response => {
  2213. console.log('新增保存发送参数', this.requestParam)
  2214. if (response.msg !== 'fail') {
  2215. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2216. this.getList2()
  2217. this.getList3()
  2218. this.dropState = false
  2219. } else {
  2220. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2221. }
  2222. })
  2223. },
  2224. updateCancel2(row) {
  2225. console.log('点击了详情编辑取消')
  2226. // 饲料组编辑false,不可编辑true
  2227. row.groupEdit = false
  2228. row.groupNoEdit = true
  2229. // 编辑false,不可编辑true
  2230. row.Edit = false
  2231. row.NoEdit = true
  2232. // 新增false,编辑true,编辑保存false
  2233. row.isCreate = false
  2234. row.isUpdate = true
  2235. row.isUpdateSave = false
  2236. this.getList2()
  2237. this.dropState = false
  2238. },
  2239. // 详情删除
  2240. handleRowDelete2(row) {
  2241. console.log('点击了行内删除')
  2242. MessageBox.confirm('是否确认删除此信息?', {
  2243. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2244. }).then(() => {
  2245. console.log(this.table2.list.length)
  2246. if (this.table2.list.length > 1) {
  2247. this.requestParam.common = { 'returnmap': '0' }
  2248. this.requestParam.data = []
  2249. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2250. pastureid: row.pastureid,
  2251. id: row.id
  2252. }}
  2253. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2254. pastureid: row.pastureid,
  2255. ftid: this.table2.getdataListParm.parammaps.ftid,
  2256. type: this.table2.getdataListParm.parammaps.fttypeid
  2257. }}
  2258. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2259. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2260. id: this.table2.getdataListParm.parammaps.ftid
  2261. }}
  2262. } else {
  2263. this.requestParam.common = { 'returnmap': '0' }
  2264. this.requestParam.data = []
  2265. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2266. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2267. id: this.table2.getdataListParm.parammaps.ftid
  2268. }}
  2269. this.requestParam.data[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2270. pastureid: row.pastureid,
  2271. id: row.id
  2272. }}
  2273. this.requestParam.data[2] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  2274. pastureid: row.pastureid,
  2275. ftid: this.table2.getdataListParm.parammaps.ftid,
  2276. type: this.table2.getdataListParm.parammaps.fttypeid
  2277. }}
  2278. this.requestParam.data[3] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2279. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2280. id: this.table2.getdataListParm.parammaps.ftid
  2281. }}
  2282. }
  2283. ExecDataByConfig(this.requestParam).then(response => {
  2284. console.log('新增保存发送参数', this.requestParam)
  2285. if (response.msg === 'fail') {
  2286. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2287. } else {
  2288. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  2289. this.getList2()
  2290. this.getList3()
  2291. }
  2292. })
  2293. }).catch(() => {
  2294. this.$message({ type: 'info', message: '已取消删除' })
  2295. })
  2296. },
  2297. handleSelectionChange2(val) {
  2298. console.log('勾选数据', val)
  2299. this.selectList2 = val
  2300. },
  2301. handleDelete2() {
  2302. console.log('点击了删除')
  2303. if (this.selectList2.length == 0) {
  2304. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  2305. } else {
  2306. MessageBox.confirm('是否确认删除此信息?', {
  2307. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  2308. }).then(() => {
  2309. console.log(this.table2.list.length - this.selectList2.length)
  2310. if (this.table2.list.length - this.selectList2.length > 0) {
  2311. this.requestParam.common = { 'returnmap': '0' }
  2312. this.requestParam.data = []
  2313. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2314. this.requestParam.data[0].children = []
  2315. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2316. id: '@insertSpotList.id',
  2317. pastureid: '@insertSpotList.pastureid'
  2318. }}
  2319. this.requestParam.data[1] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2320. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2321. id: this.table2.getdataListParm.parammaps.ftid
  2322. }}
  2323. } else {
  2324. this.requestParam.common = { 'returnmap': '0' }
  2325. this.requestParam.data = []
  2326. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  2327. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2328. id: this.table2.getdataListParm.parammaps.ftid
  2329. }}
  2330. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  2331. this.requestParam.data[1].children = []
  2332. this.requestParam.data[1].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2333. id: '@insertSpotList.id',
  2334. pastureid: '@insertSpotList.pastureid'
  2335. }}
  2336. this.requestParam.data[2] = { 'name': 'updateftversion', 'type': 'e', 'parammaps': {
  2337. pastureid: this.table2.getdataListParm.parammaps.pastureid,
  2338. id: this.table2.getdataListParm.parammaps.ftid
  2339. }}
  2340. }
  2341. ExecDataByConfig(this.requestParam).then(response => {
  2342. console.log('删除保存发送参数', this.requestParam)
  2343. if (response.msg === 'fail') {
  2344. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  2345. } else {
  2346. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  2347. this.getList2()
  2348. this.getList3()
  2349. }
  2350. })
  2351. })
  2352. }
  2353. },
  2354. // 拆分预混料
  2355. handleSplitPremix(row) {
  2356. console.log('点击了拆分预混料')
  2357. MessageBox.confirm('是否确认拆分当前预混料?', {
  2358. confirmButtonText: '确认',
  2359. cancelButtonText: '取消',
  2360. type: 'warning'
  2361. }).then(() => {
  2362. this.requestParam.name = 'splitFTpre'
  2363. this.requestParam.parammaps = {}
  2364. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  2365. this.requestParam.parammaps.preftid = row.preftid
  2366. this.requestParam.parammaps.ftdid = row.id
  2367. this.requestParam.parammaps.pastureid = row.pastureid
  2368. this.requestParam.parammaps.feedgroup = row.feedgroup
  2369. this.requestParam.parammaps.sort = row.sort
  2370. this.requestParam.parammaps.fweight = row.fweight
  2371. PostDataByName(this.requestParam).then(response => {
  2372. if (response.msg === 'fail') {
  2373. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2374. } else {
  2375. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  2376. this.getList2()
  2377. this.getList3()
  2378. }
  2379. })
  2380. }).catch(() => {
  2381. this.$message({
  2382. type: 'info',
  2383. message: '已取消删除'
  2384. })
  2385. })
  2386. },
  2387. // 合成预混料
  2388. handleSyntheticPremix() {
  2389. console.log('点击了合成预混料', this.selectList2)
  2390. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2391. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2392. return false
  2393. } else {
  2394. if (this.selectList2.length > 1) {
  2395. for (let i = 0; i < this.selectList2.length; i++) {
  2396. if (parseInt(this.selectList2[i].preftid) > 0) {
  2397. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2398. return false
  2399. }
  2400. }
  2401. if (this.selectList2[0].splitftpreid !== undefined) {
  2402. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2403. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2404. GetDataByName(this.detail.getdataListParm).then(response => {
  2405. if (response.data.list !== null) { // 不为空时得到比对数据
  2406. this.detail.list3 = response.data.list
  2407. const sortList = [] // 声明排序数组
  2408. var fweightSum = 0 // 总重量
  2409. for (let i = 0; i < this.selectList2.length; i++) {
  2410. const obj = {}
  2411. obj.fid = this.selectList2[i].fid
  2412. obj.fweight = this.selectList2[i].fweight
  2413. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2414. sortList.push(obj)
  2415. }
  2416. // 排序
  2417. sortList.sort(function(a, b) {
  2418. return a.fid.localeCompare(b.fid)
  2419. })
  2420. var a = 0
  2421. if (this.detail.list3.length == sortList.length) {
  2422. for (let i = 0; i < this.detail.list3.length; i++) {
  2423. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  2424. a++
  2425. }
  2426. }
  2427. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2428. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2429. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2430. GetDataByName(this.detail.getdataListParm2).then(response => {
  2431. if (response.data.list !== null) {
  2432. this.detail.dialogStatus = 'SyntheticPremix'
  2433. this.detail.dialogFormVisible = true
  2434. this.detail.list = this.selectList2
  2435. this.detail.list2 = response.data.list
  2436. this.detail.disabled = true
  2437. setTimeout(() => {
  2438. this.detail.listLoading = false
  2439. }, 100)
  2440. } else {
  2441. this.detail.list2 = []
  2442. }
  2443. })
  2444. } else {
  2445. this.detail.dialogStatus = 'SyntheticPremix'
  2446. this.detail.dialogFormVisible = true
  2447. this.detail.list = this.selectList2
  2448. this.detail.disabled = false
  2449. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2450. setTimeout(() => {
  2451. this.detail.listLoading = false
  2452. }, 100)
  2453. }
  2454. } else {
  2455. this.detail.dialogStatus = 'SyntheticPremix'
  2456. this.detail.dialogFormVisible = true
  2457. this.detail.list = this.selectList2
  2458. this.detail.disabled = false
  2459. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2460. setTimeout(() => {
  2461. this.detail.listLoading = false
  2462. }, 100)
  2463. }
  2464. } else {
  2465. this.detail.list3 = []
  2466. this.detail.dialogStatus = 'SyntheticPremix'
  2467. this.detail.dialogFormVisible = true
  2468. this.detail.list = this.selectList2
  2469. this.detail.disabled = false
  2470. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2471. setTimeout(() => {
  2472. this.detail.listLoading = false
  2473. }, 100)
  2474. }
  2475. })
  2476. } else {
  2477. this.detail.dialogStatus = 'SyntheticPremix'
  2478. this.detail.dialogFormVisible = true
  2479. this.detail.list = this.selectList2
  2480. this.detail.disabled = false
  2481. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2482. setTimeout(() => {
  2483. this.detail.listLoading = false
  2484. }, 100)
  2485. }
  2486. } else {
  2487. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2488. return false
  2489. }
  2490. }
  2491. },
  2492. // 畜生类别
  2493. changeLivestockType2(item) {
  2494. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2495. },
  2496. syntheticPremixData() {
  2497. console.log('点击了合成预混料确认')
  2498. if (this.detail.disabled == true) { // 原预混料
  2499. let sumFweight = 0
  2500. for (let i = 0; i < this.detail.list.length; i++) {
  2501. sumFweight += parseFloat(this.detail.list[i].fweight)
  2502. }
  2503. sumFweight = sumFweight.toFixed(2)
  2504. this.isokDisable = true
  2505. setTimeout(() => {
  2506. this.isokDisable = false
  2507. }, 1000)
  2508. this.requestParam.common = { 'returnmap': '0' }
  2509. this.requestParam.data = []
  2510. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2511. this.requestParam.data[0].children = []
  2512. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2513. pastureid: '@insertSpotList.pastureid',
  2514. id: '@insertSpotList.id'
  2515. }}
  2516. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2517. this.requestParam.data[1].children = []
  2518. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2519. pastureid: Cookies.get('pastureid'),
  2520. ftid: this.table2.getdataListParm.parammaps.ftid,
  2521. fid: this.detail.list2[0].id,
  2522. fname: '@insertSpotList2.tname',
  2523. fweight: sumFweight,
  2524. islockcount: '0',
  2525. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2526. feedgroup: '@insertSpotList2.tname',
  2527. preftid: this.detail.list2[0].id,
  2528. autosecond: this.detail.list[0].autosecond
  2529. }}
  2530. ExecDataByConfig(this.requestParam).then(response => {
  2531. console.log('合成预混料保存发送参数', this.requestParam)
  2532. if (response.msg === 'fail') {
  2533. const tname = new RegExp("key 'tname'")
  2534. if (tname.test(response.data)) {
  2535. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2536. } else {
  2537. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2538. }
  2539. } else {
  2540. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2541. this.detail.dialogFormVisible = false
  2542. this.getList3()
  2543. this.getList2()
  2544. this.getDownList()
  2545. }
  2546. })
  2547. } else { // 现生成预混料
  2548. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2549. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2550. return false
  2551. } else if (this.detail.list2[0].tname == '') {
  2552. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2553. return false
  2554. } else if (this.detail.list2[0].ccid == '') {
  2555. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2556. return false
  2557. }
  2558. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2559. if (pattern.test(this.detail.list2[0].tname)) {
  2560. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2561. return false
  2562. }
  2563. let sumFweight = 0
  2564. for (let i = 0; i < this.detail.list.length; i++) {
  2565. sumFweight += parseFloat(this.detail.list[i].fweight)
  2566. }
  2567. sumFweight = sumFweight.toFixed(2)
  2568. console.log(sumFweight)
  2569. this.isokDisable = true
  2570. setTimeout(() => {
  2571. this.isokDisable = false
  2572. }, 1000)
  2573. if (this.detail.list2[0].tcolor == null) {
  2574. this.detail.list2[0].tcolor = '#CCCCCC'
  2575. }
  2576. this.requestParam.common = { 'returnmap': '0' }
  2577. this.requestParam.data = []
  2578. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2579. pastureid: Cookies.get('pastureid'),
  2580. tcode: this.detail.list2[0].tcode,
  2581. tname: this.detail.list2[0].tname,
  2582. tcolor: this.detail.list2[0].tcolor,
  2583. ccid: this.detail.list2[0].ccid,
  2584. ccname: this.detail.list2[0].ccname,
  2585. fttype: this.detail.list2[0].fttype,
  2586. fttypeid: this.detail.list2[0].fttypeid,
  2587. source: this.detail.list2[0].source,
  2588. remark: this.detail.list2[0].remark,
  2589. enable: this.detail.list2[0].enable
  2590. }}
  2591. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2592. this.requestParam.data[1].children = []
  2593. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2594. pastureid: '@insertSpotList.pastureid',
  2595. ftid: '@insertFT.LastInsertId',
  2596. fid: '@insertSpotList.fid',
  2597. fname: '@insertSpotList.fname',
  2598. fweight: '@insertSpotList.fweight',
  2599. islockcount: '@insertSpotList.islockcount',
  2600. sort: '@insertSpotList.sort',
  2601. feedgroup: '@insertSpotList.feedgroup',
  2602. preftid: '@insertSpotList.preftid',
  2603. autosecond: '@insertSpotList.autosecond'
  2604. }}
  2605. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2606. pastureid: '@insertSpotList.pastureid',
  2607. id: '@insertSpotList.id'
  2608. }}
  2609. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2610. this.requestParam.data[2].children = []
  2611. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2612. pastureid: Cookies.get('pastureid'),
  2613. ftid: this.table2.getdataListParm.parammaps.ftid,
  2614. fid: '@insertFT.LastInsertId',
  2615. fname: '@insertSpotList2.tname',
  2616. fweight: sumFweight,
  2617. islockcount: '0',
  2618. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2619. feedgroup: '@insertSpotList2.tname',
  2620. preftid: '@insertFT.LastInsertId',
  2621. autosecond: this.detail.list[0].autosecond
  2622. }}
  2623. ExecDataByConfig(this.requestParam).then(response => {
  2624. console.log('合成预混料保存发送参数', this.requestParam)
  2625. if (response.msg === 'fail') {
  2626. const tname = new RegExp("key 'tname'")
  2627. if (tname.test(response.data)) {
  2628. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2629. } else {
  2630. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2631. }
  2632. } else {
  2633. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2634. this.detail.dialogFormVisible = false
  2635. this.getList3()
  2636. this.getList2()
  2637. this.getDownList()
  2638. }
  2639. })
  2640. }
  2641. },
  2642. handleFormulationEvaluation(row) {
  2643. console.log(row)
  2644. // this.$router.push({ path: '/statisticalAnalysis/FormulationEvaluation', query: { tname: row.tname }})
  2645. this.$router.push({
  2646. name: 'FormulationEvaluation',
  2647. params: {
  2648. tname: row.tname,
  2649. ftid: row.id,
  2650. pastureid: row.pastureid,
  2651. startTime: parseTime(new Date(), '{y}-{m}-{d}'),
  2652. inputDatetime: [new Date('startTime'), new Date('startTime')], // 日期后台待传
  2653. stopTime: parseTime(new Date(), '{y}-{m}-{d}')
  2654. }
  2655. })
  2656. }
  2657. }
  2658. }
  2659. </script>
  2660. <style lang="scss" scoped>
  2661. .search{margin-top:10px;}
  2662. .table{margin-top:5px;}
  2663. .table2{margin-top:10px;}
  2664. $width:350px;
  2665. $left:325px;
  2666. .selectInput{
  2667. position: relative;
  2668. display: inline-block;
  2669. .Input{width: $width;position: relative;}
  2670. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2671. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2672. .selectUl{
  2673. height:220px;overflow-y: auto;z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2674. li{
  2675. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2676. a{float:left;width: 80px;}
  2677. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2678. }
  2679. }
  2680. }
  2681. .template{
  2682. background: #fff;
  2683. position: relative;
  2684. }
  2685. .detail{
  2686. background: #fff;
  2687. position: fixed;
  2688. bottom: 0;
  2689. right:0;
  2690. z-index: 3;
  2691. width: calc(100% - 210px);
  2692. }
  2693. .templateDialog{
  2694. background: #fff;
  2695. position: relative;
  2696. }
  2697. .detailDialog{
  2698. background: #fff;
  2699. position: relative;
  2700. }
  2701. .hide{float: right;margin-right: 60px;}
  2702. </style>
  2703. <style>
  2704. .el-color-dropdown__main-wrapper{display: none !important;}
  2705. .el-color-dropdown__value{display: none !important;}
  2706. .el-color-dropdown__btns .el-button--text{display: none !important;}
  2707. </style>